documentation.d.ts 3.6 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707837088370983710837118371283713837148371583716837178371883719837208372183722837238372483725837268372783728837298373083731837328373383734837358373683737837388373983740837418374283743837448374583746837478374883749837508375183752837538375483755837568375783758837598376083761837628376383764837658376683767837688376983770837718377283773837748377583776837778377883779837808378183782837838378483785837868378783788837898379083791837928379383794837958379683797837988379983800838018380283803838048380583806838078380883809838108381183812838138381483815838168381783818838198382083821838228382383824838258382683827838288382983830838318383283833838348383583836838378383883839838408384183842838438384483845838468384783848838498385083851838528385383854838558385683857838588385983860838618386283863838648386583866838678386883869838708387183872838738387483875838768387783878838798388083881838828388383884838858388683887838888388983890838918389283893838948389583896838978389883899839008390183902839038390483905839068390783908839098391083911839128391383914839158391683917839188391983920839218392283923839248392583926839278392883929839308393183932839338393483935839368393783938839398394083941839428394383944839458394683947839488394983950839518395283953839548395583956839578395883959839608396183962839638396483965839668396783968839698397083971839728397383974839758397683977839788397983980839818398283983839848398583986839878398883989839908399183992839938399483995839968399783998839998400084001840028400384004840058400684007840088400984010840118401284013840148401584016840178401884019840208402184022840238402484025840268402784028840298403084031840328403384034840358403684037840388403984040840418404284043840448404584046840478404884049840508405184052840538405484055840568405784058840598406084061840628406384064840658406684067840688406984070840718407284073840748407584076840778407884079840808408184082840838408484085840868408784088840898409084091840928409384094840958409684097840988409984100841018410284103841048410584106841078410884109841108411184112841138411484115841168411784118841198412084121841228412384124841258412684127841288412984130841318413284133841348413584136841378413884139841408414184142841438414484145841468414784148841498415084151841528415384154841558415684157841588415984160841618416284163841648416584166841678416884169841708417184172841738417484175841768417784178841798418084181841828418384184841858418684187841888418984190841918419284193841948419584196841978419884199842008420184202842038420484205842068420784208842098421084211842128421384214842158421684217842188421984220842218422284223842248422584226842278422884229842308423184232842338423484235842368423784238842398424084241842428424384244842458424684247842488424984250842518425284253842548425584256842578425884259842608426184262842638426484265842668426784268842698427084271842728427384274842758427684277842788427984280842818428284283842848428584286842878428884289842908429184292842938429484295842968429784298842998430084301843028430384304843058430684307843088430984310843118431284313843148431584316843178431884319843208432184322843238432484325843268432784328843298433084331843328433384334843358433684337843388433984340843418434284343843448434584346843478434884349843508435184352843538435484355843568435784358843598436084361843628436384364843658436684367843688436984370843718437284373843748437584376843778437884379843808438184382843838438484385843868438784388843898439084391843928439384394843958439684397843988439984400844018440284403844048440584406844078440884409844108441184412844138441484415844168441784418844198442084421844228442384424844258442684427844288442984430844318443284433844348443584436844378443884439844408444184442844438444484445844468444784448844498445084451844528445384454844558445684457844588445984460844618446284463844648446584466844678446884469844708447184472844738447484475844768447784478844798448084481844828448384484844858448684487844888448984490844918449284493844948449584496844978449884499845008450184502845038450484505845068450784508845098451084511845128451384514845158451684517845188451984520845218452284523845248452584526845278452884529845308453184532845338453484535845368453784538845398454084541845428454384544845458454684547845488454984550845518455284553845548455584556845578455884559845608456184562845638456484565845668456784568845698457084571845728457384574845758457684577845788457984580845818458284583845848458584586845878458884589845908459184592845938459484595845968459784598845998460084601846028460384604846058460684607846088460984610846118461284613846148461584616846178461884619846208462184622846238462484625846268462784628846298463084631846328463384634846358463684637846388463984640846418464284643846448464584646846478464884649846508465184652846538465484655846568465784658846598466084661846628466384664846658466684667846688466984670846718467284673846748467584676846778467884679846808468184682846838468484685846868468784688846898469084691846928469384694846958469684697846988469984700847018470284703847048470584706847078470884709847108471184712847138471484715847168471784718847198472084721847228472384724847258472684727847288472984730847318473284733847348473584736847378473884739847408474184742847438474484745847468474784748847498475084751847528475384754847558475684757847588475984760847618476284763847648476584766847678476884769847708477184772847738477484775847768477784778847798478084781847828478384784847858478684787847888478984790847918479284793847948479584796847978479884799848008480184802848038480484805848068480784808848098481084811848128481384814848158481684817848188481984820848218482284823848248482584826848278482884829848308483184832848338483484835848368483784838848398484084841848428484384844848458484684847848488484984850848518485284853848548485584856848578485884859848608486184862848638486484865848668486784868848698487084871848728487384874848758487684877848788487984880848818488284883848848488584886848878488884889848908489184892848938489484895848968489784898848998490084901849028490384904849058490684907849088490984910849118491284913849148491584916849178491884919849208492184922849238492484925849268492784928849298493084931849328493384934849358493684937849388493984940849418494284943849448494584946849478494884949849508495184952849538495484955849568495784958849598496084961849628496384964849658496684967849688496984970849718497284973849748497584976849778497884979849808498184982849838498484985849868498784988849898499084991849928499384994849958499684997849988499985000850018500285003850048500585006850078500885009850108501185012850138501485015850168501785018850198502085021850228502385024850258502685027850288502985030850318503285033850348503585036850378503885039850408504185042850438504485045850468504785048850498505085051850528505385054850558505685057850588505985060850618506285063850648506585066850678506885069850708507185072850738507485075850768507785078850798508085081850828508385084850858508685087850888508985090850918509285093850948509585096850978509885099851008510185102851038510485105851068510785108851098511085111851128511385114851158511685117851188511985120851218512285123851248512585126851278512885129851308513185132851338513485135851368513785138851398514085141851428514385144851458514685147851488514985150851518515285153851548515585156851578515885159851608516185162851638516485165851668516785168851698517085171851728517385174851758517685177851788517985180851818518285183851848518585186851878518885189851908519185192851938519485195851968519785198851998520085201852028520385204852058520685207852088520985210852118521285213852148521585216852178521885219852208522185222852238522485225852268522785228852298523085231852328523385234852358523685237852388523985240852418524285243852448524585246852478524885249852508525185252852538525485255852568525785258852598526085261852628526385264852658526685267852688526985270852718527285273852748527585276852778527885279852808528185282852838528485285852868528785288852898529085291852928529385294852958529685297852988529985300853018530285303853048530585306853078530885309853108531185312853138531485315853168531785318853198532085321853228532385324853258532685327853288532985330853318533285333853348533585336853378533885339853408534185342853438534485345853468534785348853498535085351853528535385354853558535685357853588535985360853618536285363853648536585366853678536885369853708537185372853738537485375853768537785378853798538085381853828538385384853858538685387853888538985390853918539285393853948539585396853978539885399854008540185402854038540485405854068540785408854098541085411854128541385414854158541685417854188541985420854218542285423854248542585426854278542885429854308543185432854338543485435854368543785438854398544085441854428544385444854458544685447854488544985450854518545285453854548545585456854578545885459854608546185462854638546485465854668546785468854698547085471854728547385474854758547685477854788547985480854818548285483854848548585486854878548885489854908549185492854938549485495854968549785498854998550085501855028550385504855058550685507855088550985510855118551285513855148551585516855178551885519855208552185522855238552485525855268552785528855298553085531855328553385534855358553685537855388553985540855418554285543855448554585546855478554885549855508555185552855538555485555855568555785558855598556085561855628556385564855658556685567855688556985570855718557285573855748557585576855778557885579855808558185582855838558485585855868558785588855898559085591855928559385594855958559685597855988559985600856018560285603856048560585606856078560885609856108561185612856138561485615856168561785618856198562085621856228562385624856258562685627856288562985630856318563285633856348563585636856378563885639856408564185642856438564485645856468564785648856498565085651856528565385654856558565685657856588565985660856618566285663856648566585666856678566885669856708567185672856738567485675856768567785678856798568085681856828568385684856858568685687856888568985690856918569285693856948569585696856978569885699857008570185702857038570485705857068570785708857098571085711857128571385714857158571685717857188571985720857218572285723857248572585726857278572885729857308573185732857338573485735857368573785738857398574085741857428574385744857458574685747857488574985750857518575285753857548575585756857578575885759857608576185762857638576485765857668576785768857698577085771857728577385774857758577685777857788577985780857818578285783857848578585786857878578885789857908579185792857938579485795857968579785798857998580085801858028580385804858058580685807858088580985810858118581285813858148581585816858178581885819858208582185822858238582485825858268582785828858298583085831858328583385834858358583685837858388583985840858418584285843858448584585846858478584885849858508585185852858538585485855858568585785858858598586085861858628586385864858658586685867858688586985870858718587285873858748587585876858778587885879858808588185882858838588485885858868588785888858898589085891858928589385894858958589685897858988589985900859018590285903859048590585906859078590885909859108591185912859138591485915859168591785918859198592085921859228592385924859258592685927859288592985930859318593285933859348593585936859378593885939859408594185942859438594485945859468594785948859498595085951859528595385954859558595685957859588595985960859618596285963859648596585966859678596885969859708597185972859738597485975859768597785978859798598085981859828598385984859858598685987859888598985990859918599285993859948599585996859978599885999860008600186002860038600486005860068600786008860098601086011860128601386014860158601686017860188601986020860218602286023860248602586026860278602886029860308603186032860338603486035860368603786038860398604086041860428604386044860458604686047860488604986050860518605286053860548605586056860578605886059860608606186062860638606486065860668606786068860698607086071860728607386074860758607686077860788607986080860818608286083860848608586086860878608886089860908609186092860938609486095860968609786098860998610086101861028610386104861058610686107861088610986110861118611286113861148611586116861178611886119861208612186122861238612486125861268612786128861298613086131861328613386134861358613686137861388613986140861418614286143861448614586146861478614886149861508615186152861538615486155861568615786158861598616086161861628616386164861658616686167861688616986170861718617286173861748617586176861778617886179861808618186182861838618486185861868618786188861898619086191861928619386194861958619686197861988619986200862018620286203862048620586206862078620886209862108621186212862138621486215862168621786218862198622086221862228622386224862258622686227862288622986230862318623286233862348623586236862378623886239862408624186242862438624486245862468624786248862498625086251862528625386254862558625686257862588625986260862618626286263862648626586266862678626886269862708627186272862738627486275862768627786278862798628086281862828628386284862858628686287862888628986290862918629286293862948629586296862978629886299863008630186302863038630486305863068630786308863098631086311863128631386314863158631686317863188631986320863218632286323863248632586326863278632886329863308633186332863338633486335863368633786338863398634086341863428634386344863458634686347863488634986350863518635286353863548635586356863578635886359863608636186362863638636486365863668636786368863698637086371863728637386374863758637686377863788637986380863818638286383863848638586386863878638886389863908639186392863938639486395863968639786398863998640086401864028640386404864058640686407864088640986410864118641286413864148641586416864178641886419864208642186422864238642486425
  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: 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. isCube: boolean;
  11667. /**
  11668. * Define if the texture is enabled or not (disabled texture will not render)
  11669. */
  11670. isEnabled: boolean;
  11671. /**
  11672. * Define if the texture must be cleared before rendering (default is true)
  11673. */
  11674. autoClear: boolean;
  11675. /**
  11676. * Callback called when the texture is generated
  11677. */
  11678. onGenerated: () => void;
  11679. /**
  11680. * Event raised when the texture is generated
  11681. */
  11682. onGeneratedObservable: Observable<ProceduralTexture>;
  11683. /** @hidden */
  11684. _generateMipMaps: boolean;
  11685. /** @hidden **/
  11686. _effect: Effect;
  11687. /** @hidden */
  11688. _textures: {
  11689. [key: string]: Texture;
  11690. };
  11691. /** @hidden */
  11692. protected _fallbackTexture: Nullable<Texture>;
  11693. private _size;
  11694. private _currentRefreshId;
  11695. private _frameId;
  11696. private _refreshRate;
  11697. private _vertexBuffers;
  11698. private _indexBuffer;
  11699. private _uniforms;
  11700. private _samplers;
  11701. private _fragment;
  11702. private _floats;
  11703. private _ints;
  11704. private _floatsArrays;
  11705. private _colors3;
  11706. private _colors4;
  11707. private _vectors2;
  11708. private _vectors3;
  11709. private _matrices;
  11710. private _fallbackTextureUsed;
  11711. private _fullEngine;
  11712. private _cachedDefines;
  11713. private _contentUpdateId;
  11714. private _contentData;
  11715. /**
  11716. * Instantiates a new procedural texture.
  11717. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  11718. * This is the base class of any Procedural texture and contains most of the shareable code.
  11719. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11720. * @param name Define the name of the texture
  11721. * @param size Define the size of the texture to create
  11722. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11723. * @param scene Define the scene the texture belongs to
  11724. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11725. * @param generateMipMaps Define if the texture should creates mip maps or not
  11726. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11727. */
  11728. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11729. /**
  11730. * The effect that is created when initializing the post process.
  11731. * @returns The created effect corresponding the the postprocess.
  11732. */
  11733. getEffect(): Effect;
  11734. /**
  11735. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11736. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11737. */
  11738. getContent(): Nullable<ArrayBufferView>;
  11739. private _createIndexBuffer;
  11740. /** @hidden */
  11741. _rebuild(): void;
  11742. /**
  11743. * Resets the texture in order to recreate its associated resources.
  11744. * This can be called in case of context loss
  11745. */
  11746. reset(): void;
  11747. protected _getDefines(): string;
  11748. /**
  11749. * Is the texture ready to be used ? (rendered at least once)
  11750. * @returns true if ready, otherwise, false.
  11751. */
  11752. isReady(): boolean;
  11753. /**
  11754. * Resets the refresh counter of the texture and start bak from scratch.
  11755. * Could be useful to regenerate the texture if it is setup to render only once.
  11756. */
  11757. resetRefreshCounter(): void;
  11758. /**
  11759. * Set the fragment shader to use in order to render the texture.
  11760. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11761. */
  11762. setFragment(fragment: any): void;
  11763. /**
  11764. * Define the refresh rate of the texture or the rendering frequency.
  11765. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11766. */
  11767. get refreshRate(): number;
  11768. set refreshRate(value: number);
  11769. /** @hidden */
  11770. _shouldRender(): boolean;
  11771. /**
  11772. * Get the size the texture is rendering at.
  11773. * @returns the size (texture is always squared)
  11774. */
  11775. getRenderSize(): number;
  11776. /**
  11777. * Resize the texture to new value.
  11778. * @param size Define the new size the texture should have
  11779. * @param generateMipMaps Define whether the new texture should create mip maps
  11780. */
  11781. resize(size: number, generateMipMaps: boolean): void;
  11782. private _checkUniform;
  11783. /**
  11784. * Set a texture in the shader program used to render.
  11785. * @param name Define the name of the uniform samplers as defined in the shader
  11786. * @param texture Define the texture to bind to this sampler
  11787. * @return the texture itself allowing "fluent" like uniform updates
  11788. */
  11789. setTexture(name: string, texture: Texture): ProceduralTexture;
  11790. /**
  11791. * Set a float in the shader.
  11792. * @param name Define the name of the uniform as defined in the shader
  11793. * @param value Define the value to give to the uniform
  11794. * @return the texture itself allowing "fluent" like uniform updates
  11795. */
  11796. setFloat(name: string, value: number): ProceduralTexture;
  11797. /**
  11798. * Set a int in the shader.
  11799. * @param name Define the name of the uniform as defined in the shader
  11800. * @param value Define the value to give to the uniform
  11801. * @return the texture itself allowing "fluent" like uniform updates
  11802. */
  11803. setInt(name: string, value: number): ProceduralTexture;
  11804. /**
  11805. * Set an array of floats in the shader.
  11806. * @param name Define the name of the uniform as defined in the shader
  11807. * @param value Define the value to give to the uniform
  11808. * @return the texture itself allowing "fluent" like uniform updates
  11809. */
  11810. setFloats(name: string, value: number[]): ProceduralTexture;
  11811. /**
  11812. * Set a vec3 in the shader from a Color3.
  11813. * @param name Define the name of the uniform as defined in the shader
  11814. * @param value Define the value to give to the uniform
  11815. * @return the texture itself allowing "fluent" like uniform updates
  11816. */
  11817. setColor3(name: string, value: Color3): ProceduralTexture;
  11818. /**
  11819. * Set a vec4 in the shader from a Color4.
  11820. * @param name Define the name of the uniform as defined in the shader
  11821. * @param value Define the value to give to the uniform
  11822. * @return the texture itself allowing "fluent" like uniform updates
  11823. */
  11824. setColor4(name: string, value: Color4): ProceduralTexture;
  11825. /**
  11826. * Set a vec2 in the shader from a Vector2.
  11827. * @param name Define the name of the uniform as defined in the shader
  11828. * @param value Define the value to give to the uniform
  11829. * @return the texture itself allowing "fluent" like uniform updates
  11830. */
  11831. setVector2(name: string, value: Vector2): ProceduralTexture;
  11832. /**
  11833. * Set a vec3 in the shader from a Vector3.
  11834. * @param name Define the name of the uniform as defined in the shader
  11835. * @param value Define the value to give to the uniform
  11836. * @return the texture itself allowing "fluent" like uniform updates
  11837. */
  11838. setVector3(name: string, value: Vector3): ProceduralTexture;
  11839. /**
  11840. * Set a mat4 in the shader from a MAtrix.
  11841. * @param name Define the name of the uniform as defined in the shader
  11842. * @param value Define the value to give to the uniform
  11843. * @return the texture itself allowing "fluent" like uniform updates
  11844. */
  11845. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11846. /**
  11847. * Render the texture to its associated render target.
  11848. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11849. */
  11850. render(useCameraPostProcess?: boolean): void;
  11851. /**
  11852. * Clone the texture.
  11853. * @returns the cloned texture
  11854. */
  11855. clone(): ProceduralTexture;
  11856. /**
  11857. * Dispose the texture and release its asoociated resources.
  11858. */
  11859. dispose(): void;
  11860. }
  11861. }
  11862. declare module BABYLON {
  11863. /**
  11864. * This represents the base class for particle system in Babylon.
  11865. * 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.
  11866. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11867. * @example https://doc.babylonjs.com/babylon101/particles
  11868. */
  11869. export class BaseParticleSystem {
  11870. /**
  11871. * Source color is added to the destination color without alpha affecting the result
  11872. */
  11873. static BLENDMODE_ONEONE: number;
  11874. /**
  11875. * Blend current color and particle color using particle’s alpha
  11876. */
  11877. static BLENDMODE_STANDARD: number;
  11878. /**
  11879. * Add current color and particle color multiplied by particle’s alpha
  11880. */
  11881. static BLENDMODE_ADD: number;
  11882. /**
  11883. * Multiply current color with particle color
  11884. */
  11885. static BLENDMODE_MULTIPLY: number;
  11886. /**
  11887. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11888. */
  11889. static BLENDMODE_MULTIPLYADD: number;
  11890. /**
  11891. * List of animations used by the particle system.
  11892. */
  11893. animations: Animation[];
  11894. /**
  11895. * Gets or sets the unique id of the particle system
  11896. */
  11897. uniqueId: number;
  11898. /**
  11899. * The id of the Particle system.
  11900. */
  11901. id: string;
  11902. /**
  11903. * The friendly name of the Particle system.
  11904. */
  11905. name: string;
  11906. /**
  11907. * Snippet ID if the particle system was created from the snippet server
  11908. */
  11909. snippetId: string;
  11910. /**
  11911. * The rendering group used by the Particle system to chose when to render.
  11912. */
  11913. renderingGroupId: number;
  11914. /**
  11915. * The emitter represents the Mesh or position we are attaching the particle system to.
  11916. */
  11917. emitter: Nullable<AbstractMesh | Vector3>;
  11918. /**
  11919. * The maximum number of particles to emit per frame
  11920. */
  11921. emitRate: number;
  11922. /**
  11923. * If you want to launch only a few particles at once, that can be done, as well.
  11924. */
  11925. manualEmitCount: number;
  11926. /**
  11927. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11928. */
  11929. updateSpeed: number;
  11930. /**
  11931. * The amount of time the particle system is running (depends of the overall update speed).
  11932. */
  11933. targetStopDuration: number;
  11934. /**
  11935. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11936. */
  11937. disposeOnStop: boolean;
  11938. /**
  11939. * Minimum power of emitting particles.
  11940. */
  11941. minEmitPower: number;
  11942. /**
  11943. * Maximum power of emitting particles.
  11944. */
  11945. maxEmitPower: number;
  11946. /**
  11947. * Minimum life time of emitting particles.
  11948. */
  11949. minLifeTime: number;
  11950. /**
  11951. * Maximum life time of emitting particles.
  11952. */
  11953. maxLifeTime: number;
  11954. /**
  11955. * Minimum Size of emitting particles.
  11956. */
  11957. minSize: number;
  11958. /**
  11959. * Maximum Size of emitting particles.
  11960. */
  11961. maxSize: number;
  11962. /**
  11963. * Minimum scale of emitting particles on X axis.
  11964. */
  11965. minScaleX: number;
  11966. /**
  11967. * Maximum scale of emitting particles on X axis.
  11968. */
  11969. maxScaleX: number;
  11970. /**
  11971. * Minimum scale of emitting particles on Y axis.
  11972. */
  11973. minScaleY: number;
  11974. /**
  11975. * Maximum scale of emitting particles on Y axis.
  11976. */
  11977. maxScaleY: number;
  11978. /**
  11979. * Gets or sets the minimal initial rotation in radians.
  11980. */
  11981. minInitialRotation: number;
  11982. /**
  11983. * Gets or sets the maximal initial rotation in radians.
  11984. */
  11985. maxInitialRotation: number;
  11986. /**
  11987. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11988. */
  11989. minAngularSpeed: number;
  11990. /**
  11991. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11992. */
  11993. maxAngularSpeed: number;
  11994. /**
  11995. * The texture used to render each particle. (this can be a spritesheet)
  11996. */
  11997. particleTexture: Nullable<BaseTexture>;
  11998. /**
  11999. * The layer mask we are rendering the particles through.
  12000. */
  12001. layerMask: number;
  12002. /**
  12003. * This can help using your own shader to render the particle system.
  12004. * The according effect will be created
  12005. */
  12006. customShader: any;
  12007. /**
  12008. * By default particle system starts as soon as they are created. This prevents the
  12009. * automatic start to happen and let you decide when to start emitting particles.
  12010. */
  12011. preventAutoStart: boolean;
  12012. private _noiseTexture;
  12013. /**
  12014. * Gets or sets a texture used to add random noise to particle positions
  12015. */
  12016. get noiseTexture(): Nullable<ProceduralTexture>;
  12017. set noiseTexture(value: Nullable<ProceduralTexture>);
  12018. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12019. noiseStrength: Vector3;
  12020. /**
  12021. * Callback triggered when the particle animation is ending.
  12022. */
  12023. onAnimationEnd: Nullable<() => void>;
  12024. /**
  12025. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12026. */
  12027. blendMode: number;
  12028. /**
  12029. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12030. * to override the particles.
  12031. */
  12032. forceDepthWrite: boolean;
  12033. /** 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 */
  12034. preWarmCycles: number;
  12035. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12036. preWarmStepOffset: number;
  12037. /**
  12038. * 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)
  12039. */
  12040. spriteCellChangeSpeed: number;
  12041. /**
  12042. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12043. */
  12044. startSpriteCellID: number;
  12045. /**
  12046. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12047. */
  12048. endSpriteCellID: number;
  12049. /**
  12050. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12051. */
  12052. spriteCellWidth: number;
  12053. /**
  12054. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12055. */
  12056. spriteCellHeight: number;
  12057. /**
  12058. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12059. */
  12060. spriteRandomStartCell: boolean;
  12061. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12062. translationPivot: Vector2;
  12063. /** @hidden */
  12064. protected _isAnimationSheetEnabled: boolean;
  12065. /**
  12066. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12067. */
  12068. beginAnimationOnStart: boolean;
  12069. /**
  12070. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12071. */
  12072. beginAnimationFrom: number;
  12073. /**
  12074. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12075. */
  12076. beginAnimationTo: number;
  12077. /**
  12078. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12079. */
  12080. beginAnimationLoop: boolean;
  12081. /**
  12082. * Gets or sets a world offset applied to all particles
  12083. */
  12084. worldOffset: Vector3;
  12085. /**
  12086. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12087. */
  12088. get isAnimationSheetEnabled(): boolean;
  12089. set isAnimationSheetEnabled(value: boolean);
  12090. /**
  12091. * Get hosting scene
  12092. * @returns the scene
  12093. */
  12094. getScene(): Nullable<Scene>;
  12095. /**
  12096. * You can use gravity if you want to give an orientation to your particles.
  12097. */
  12098. gravity: Vector3;
  12099. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12100. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12101. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12102. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12103. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12104. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12105. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12106. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12107. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12108. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12109. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12110. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12111. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12112. /**
  12113. * Defines the delay in milliseconds before starting the system (0 by default)
  12114. */
  12115. startDelay: number;
  12116. /**
  12117. * Gets the current list of drag gradients.
  12118. * You must use addDragGradient and removeDragGradient to udpate this list
  12119. * @returns the list of drag gradients
  12120. */
  12121. getDragGradients(): Nullable<Array<FactorGradient>>;
  12122. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12123. limitVelocityDamping: number;
  12124. /**
  12125. * Gets the current list of limit velocity gradients.
  12126. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12127. * @returns the list of limit velocity gradients
  12128. */
  12129. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12130. /**
  12131. * Gets the current list of color gradients.
  12132. * You must use addColorGradient and removeColorGradient to udpate this list
  12133. * @returns the list of color gradients
  12134. */
  12135. getColorGradients(): Nullable<Array<ColorGradient>>;
  12136. /**
  12137. * Gets the current list of size gradients.
  12138. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12139. * @returns the list of size gradients
  12140. */
  12141. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12142. /**
  12143. * Gets the current list of color remap gradients.
  12144. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12145. * @returns the list of color remap gradients
  12146. */
  12147. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12148. /**
  12149. * Gets the current list of alpha remap gradients.
  12150. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12151. * @returns the list of alpha remap gradients
  12152. */
  12153. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12154. /**
  12155. * Gets the current list of life time gradients.
  12156. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12157. * @returns the list of life time gradients
  12158. */
  12159. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12160. /**
  12161. * Gets the current list of angular speed gradients.
  12162. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12163. * @returns the list of angular speed gradients
  12164. */
  12165. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12166. /**
  12167. * Gets the current list of velocity gradients.
  12168. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12169. * @returns the list of velocity gradients
  12170. */
  12171. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12172. /**
  12173. * Gets the current list of start size gradients.
  12174. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12175. * @returns the list of start size gradients
  12176. */
  12177. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12178. /**
  12179. * Gets the current list of emit rate gradients.
  12180. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12181. * @returns the list of emit rate gradients
  12182. */
  12183. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12184. /**
  12185. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12186. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12187. */
  12188. get direction1(): Vector3;
  12189. set direction1(value: Vector3);
  12190. /**
  12191. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12192. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12193. */
  12194. get direction2(): Vector3;
  12195. set direction2(value: Vector3);
  12196. /**
  12197. * 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.
  12198. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12199. */
  12200. get minEmitBox(): Vector3;
  12201. set minEmitBox(value: Vector3);
  12202. /**
  12203. * 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.
  12204. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12205. */
  12206. get maxEmitBox(): Vector3;
  12207. set maxEmitBox(value: Vector3);
  12208. /**
  12209. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12210. */
  12211. color1: Color4;
  12212. /**
  12213. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12214. */
  12215. color2: Color4;
  12216. /**
  12217. * Color the particle will have at the end of its lifetime
  12218. */
  12219. colorDead: Color4;
  12220. /**
  12221. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12222. */
  12223. textureMask: Color4;
  12224. /**
  12225. * The particle emitter type defines the emitter used by the particle system.
  12226. * It can be for example box, sphere, or cone...
  12227. */
  12228. particleEmitterType: IParticleEmitterType;
  12229. /** @hidden */
  12230. _isSubEmitter: boolean;
  12231. /**
  12232. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12233. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12234. */
  12235. billboardMode: number;
  12236. protected _isBillboardBased: boolean;
  12237. /**
  12238. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12239. */
  12240. get isBillboardBased(): boolean;
  12241. set isBillboardBased(value: boolean);
  12242. /**
  12243. * The scene the particle system belongs to.
  12244. */
  12245. protected _scene: Nullable<Scene>;
  12246. /**
  12247. * The engine the particle system belongs to.
  12248. */
  12249. protected _engine: ThinEngine;
  12250. /**
  12251. * Local cache of defines for image processing.
  12252. */
  12253. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12254. /**
  12255. * Default configuration related to image processing available in the standard Material.
  12256. */
  12257. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12258. /**
  12259. * Gets the image processing configuration used either in this material.
  12260. */
  12261. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12262. /**
  12263. * Sets the Default image processing configuration used either in the this material.
  12264. *
  12265. * If sets to null, the scene one is in use.
  12266. */
  12267. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12268. /**
  12269. * Attaches a new image processing configuration to the Standard Material.
  12270. * @param configuration
  12271. */
  12272. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12273. /** @hidden */
  12274. protected _reset(): void;
  12275. /** @hidden */
  12276. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12277. /**
  12278. * Instantiates a particle system.
  12279. * 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.
  12280. * @param name The name of the particle system
  12281. */
  12282. constructor(name: string);
  12283. /**
  12284. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12285. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12286. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12287. * @returns the emitter
  12288. */
  12289. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12290. /**
  12291. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12292. * @param radius The radius of the hemisphere to emit from
  12293. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12294. * @returns the emitter
  12295. */
  12296. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12297. /**
  12298. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12299. * @param radius The radius of the sphere to emit from
  12300. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12301. * @returns the emitter
  12302. */
  12303. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12304. /**
  12305. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12306. * @param radius The radius of the sphere to emit from
  12307. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12308. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12309. * @returns the emitter
  12310. */
  12311. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12312. /**
  12313. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12314. * @param radius The radius of the emission cylinder
  12315. * @param height The height of the emission cylinder
  12316. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12317. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12318. * @returns the emitter
  12319. */
  12320. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12321. /**
  12322. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12323. * @param radius The radius of the cylinder to emit from
  12324. * @param height The height of the emission cylinder
  12325. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12326. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12327. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12328. * @returns the emitter
  12329. */
  12330. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12331. /**
  12332. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12333. * @param radius The radius of the cone to emit from
  12334. * @param angle The base angle of the cone
  12335. * @returns the emitter
  12336. */
  12337. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12338. /**
  12339. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12340. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12341. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12342. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12343. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12344. * @returns the emitter
  12345. */
  12346. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12347. }
  12348. }
  12349. declare module BABYLON {
  12350. /**
  12351. * Type of sub emitter
  12352. */
  12353. export enum SubEmitterType {
  12354. /**
  12355. * Attached to the particle over it's lifetime
  12356. */
  12357. ATTACHED = 0,
  12358. /**
  12359. * Created when the particle dies
  12360. */
  12361. END = 1
  12362. }
  12363. /**
  12364. * Sub emitter class used to emit particles from an existing particle
  12365. */
  12366. export class SubEmitter {
  12367. /**
  12368. * the particle system to be used by the sub emitter
  12369. */
  12370. particleSystem: ParticleSystem;
  12371. /**
  12372. * Type of the submitter (Default: END)
  12373. */
  12374. type: SubEmitterType;
  12375. /**
  12376. * 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)
  12377. * Note: This only is supported when using an emitter of type Mesh
  12378. */
  12379. inheritDirection: boolean;
  12380. /**
  12381. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12382. */
  12383. inheritedVelocityAmount: number;
  12384. /**
  12385. * Creates a sub emitter
  12386. * @param particleSystem the particle system to be used by the sub emitter
  12387. */
  12388. constructor(
  12389. /**
  12390. * the particle system to be used by the sub emitter
  12391. */
  12392. particleSystem: ParticleSystem);
  12393. /**
  12394. * Clones the sub emitter
  12395. * @returns the cloned sub emitter
  12396. */
  12397. clone(): SubEmitter;
  12398. /**
  12399. * Serialize current object to a JSON object
  12400. * @returns the serialized object
  12401. */
  12402. serialize(): any;
  12403. /** @hidden */
  12404. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12405. /**
  12406. * Creates a new SubEmitter from a serialized JSON version
  12407. * @param serializationObject defines the JSON object to read from
  12408. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12409. * @param rootUrl defines the rootUrl for data loading
  12410. * @returns a new SubEmitter
  12411. */
  12412. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12413. /** Release associated resources */
  12414. dispose(): void;
  12415. }
  12416. }
  12417. declare module BABYLON {
  12418. /** @hidden */
  12419. export var imageProcessingDeclaration: {
  12420. name: string;
  12421. shader: string;
  12422. };
  12423. }
  12424. declare module BABYLON {
  12425. /** @hidden */
  12426. export var imageProcessingFunctions: {
  12427. name: string;
  12428. shader: string;
  12429. };
  12430. }
  12431. declare module BABYLON {
  12432. /** @hidden */
  12433. export var particlesPixelShader: {
  12434. name: string;
  12435. shader: string;
  12436. };
  12437. }
  12438. declare module BABYLON {
  12439. /** @hidden */
  12440. export var particlesVertexShader: {
  12441. name: string;
  12442. shader: string;
  12443. };
  12444. }
  12445. declare module BABYLON {
  12446. /**
  12447. * Interface used to define entities containing multiple clip planes
  12448. */
  12449. export interface IClipPlanesHolder {
  12450. /**
  12451. * Gets or sets the active clipplane 1
  12452. */
  12453. clipPlane: Nullable<Plane>;
  12454. /**
  12455. * Gets or sets the active clipplane 2
  12456. */
  12457. clipPlane2: Nullable<Plane>;
  12458. /**
  12459. * Gets or sets the active clipplane 3
  12460. */
  12461. clipPlane3: Nullable<Plane>;
  12462. /**
  12463. * Gets or sets the active clipplane 4
  12464. */
  12465. clipPlane4: Nullable<Plane>;
  12466. /**
  12467. * Gets or sets the active clipplane 5
  12468. */
  12469. clipPlane5: Nullable<Plane>;
  12470. /**
  12471. * Gets or sets the active clipplane 6
  12472. */
  12473. clipPlane6: Nullable<Plane>;
  12474. }
  12475. }
  12476. declare module BABYLON {
  12477. /**
  12478. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12479. *
  12480. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12481. *
  12482. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12483. */
  12484. export class ThinMaterialHelper {
  12485. /**
  12486. * Binds the clip plane information from the holder to the effect.
  12487. * @param effect The effect we are binding the data to
  12488. * @param holder The entity containing the clip plane information
  12489. */
  12490. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12491. }
  12492. }
  12493. declare module BABYLON {
  12494. interface ThinEngine {
  12495. /**
  12496. * Sets alpha constants used by some alpha blending modes
  12497. * @param r defines the red component
  12498. * @param g defines the green component
  12499. * @param b defines the blue component
  12500. * @param a defines the alpha component
  12501. */
  12502. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12503. /**
  12504. * Sets the current alpha mode
  12505. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12506. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12507. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12508. */
  12509. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12510. /**
  12511. * Gets the current alpha mode
  12512. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12513. * @returns the current alpha mode
  12514. */
  12515. getAlphaMode(): number;
  12516. /**
  12517. * Sets the current alpha equation
  12518. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12519. */
  12520. setAlphaEquation(equation: number): void;
  12521. /**
  12522. * Gets the current alpha equation.
  12523. * @returns the current alpha equation
  12524. */
  12525. getAlphaEquation(): number;
  12526. }
  12527. }
  12528. declare module BABYLON {
  12529. /**
  12530. * This represents a particle system in Babylon.
  12531. * 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.
  12532. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12533. * @example https://doc.babylonjs.com/babylon101/particles
  12534. */
  12535. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12536. /**
  12537. * Billboard mode will only apply to Y axis
  12538. */
  12539. static readonly BILLBOARDMODE_Y: number;
  12540. /**
  12541. * Billboard mode will apply to all axes
  12542. */
  12543. static readonly BILLBOARDMODE_ALL: number;
  12544. /**
  12545. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12546. */
  12547. static readonly BILLBOARDMODE_STRETCHED: number;
  12548. /**
  12549. * This function can be defined to provide custom update for active particles.
  12550. * This function will be called instead of regular update (age, position, color, etc.).
  12551. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12552. */
  12553. updateFunction: (particles: Particle[]) => void;
  12554. private _emitterWorldMatrix;
  12555. /**
  12556. * This function can be defined to specify initial direction for every new particle.
  12557. * It by default use the emitterType defined function
  12558. */
  12559. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12560. /**
  12561. * This function can be defined to specify initial position for every new particle.
  12562. * It by default use the emitterType defined function
  12563. */
  12564. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12565. /**
  12566. * @hidden
  12567. */
  12568. _inheritedVelocityOffset: Vector3;
  12569. /**
  12570. * An event triggered when the system is disposed
  12571. */
  12572. onDisposeObservable: Observable<IParticleSystem>;
  12573. private _onDisposeObserver;
  12574. /**
  12575. * Sets a callback that will be triggered when the system is disposed
  12576. */
  12577. set onDispose(callback: () => void);
  12578. private _particles;
  12579. private _epsilon;
  12580. private _capacity;
  12581. private _stockParticles;
  12582. private _newPartsExcess;
  12583. private _vertexData;
  12584. private _vertexBuffer;
  12585. private _vertexBuffers;
  12586. private _spriteBuffer;
  12587. private _indexBuffer;
  12588. private _effect;
  12589. private _customEffect;
  12590. private _cachedDefines;
  12591. private _scaledColorStep;
  12592. private _colorDiff;
  12593. private _scaledDirection;
  12594. private _scaledGravity;
  12595. private _currentRenderId;
  12596. private _alive;
  12597. private _useInstancing;
  12598. private _started;
  12599. private _stopped;
  12600. private _actualFrame;
  12601. private _scaledUpdateSpeed;
  12602. private _vertexBufferSize;
  12603. /** @hidden */
  12604. _currentEmitRateGradient: Nullable<FactorGradient>;
  12605. /** @hidden */
  12606. _currentEmitRate1: number;
  12607. /** @hidden */
  12608. _currentEmitRate2: number;
  12609. /** @hidden */
  12610. _currentStartSizeGradient: Nullable<FactorGradient>;
  12611. /** @hidden */
  12612. _currentStartSize1: number;
  12613. /** @hidden */
  12614. _currentStartSize2: number;
  12615. private readonly _rawTextureWidth;
  12616. private _rampGradientsTexture;
  12617. private _useRampGradients;
  12618. /** Gets or sets a matrix to use to compute projection */
  12619. defaultProjectionMatrix: Matrix;
  12620. /** Gets or sets a matrix to use to compute view */
  12621. defaultViewMatrix: Matrix;
  12622. /** Gets or sets a boolean indicating that ramp gradients must be used
  12623. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12624. */
  12625. get useRampGradients(): boolean;
  12626. set useRampGradients(value: boolean);
  12627. /**
  12628. * 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.
  12629. * 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: [])
  12630. */
  12631. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12632. private _subEmitters;
  12633. /**
  12634. * @hidden
  12635. * If the particle systems emitter should be disposed when the particle system is disposed
  12636. */
  12637. _disposeEmitterOnDispose: boolean;
  12638. /**
  12639. * The current active Sub-systems, this property is used by the root particle system only.
  12640. */
  12641. activeSubSystems: Array<ParticleSystem>;
  12642. /**
  12643. * Specifies if the particles are updated in emitter local space or world space
  12644. */
  12645. isLocal: boolean;
  12646. private _rootParticleSystem;
  12647. /**
  12648. * Gets the current list of active particles
  12649. */
  12650. get particles(): Particle[];
  12651. /**
  12652. * Gets the number of particles active at the same time.
  12653. * @returns The number of active particles.
  12654. */
  12655. getActiveCount(): number;
  12656. /**
  12657. * Returns the string "ParticleSystem"
  12658. * @returns a string containing the class name
  12659. */
  12660. getClassName(): string;
  12661. /**
  12662. * Gets a boolean indicating that the system is stopping
  12663. * @returns true if the system is currently stopping
  12664. */
  12665. isStopping(): boolean;
  12666. /**
  12667. * Gets the custom effect used to render the particles
  12668. * @param blendMode Blend mode for which the effect should be retrieved
  12669. * @returns The effect
  12670. */
  12671. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12672. /**
  12673. * Sets the custom effect used to render the particles
  12674. * @param effect The effect to set
  12675. * @param blendMode Blend mode for which the effect should be set
  12676. */
  12677. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12678. /** @hidden */
  12679. private _onBeforeDrawParticlesObservable;
  12680. /**
  12681. * Observable that will be called just before the particles are drawn
  12682. */
  12683. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12684. /**
  12685. * Gets the name of the particle vertex shader
  12686. */
  12687. get vertexShaderName(): string;
  12688. /**
  12689. * Instantiates a particle system.
  12690. * 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.
  12691. * @param name The name of the particle system
  12692. * @param capacity The max number of particles alive at the same time
  12693. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  12694. * @param customEffect a custom effect used to change the way particles are rendered by default
  12695. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12696. * @param epsilon Offset used to render the particles
  12697. */
  12698. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12699. private _addFactorGradient;
  12700. private _removeFactorGradient;
  12701. /**
  12702. * Adds a new life time gradient
  12703. * @param gradient defines the gradient to use (between 0 and 1)
  12704. * @param factor defines the life time factor to affect to the specified gradient
  12705. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12706. * @returns the current particle system
  12707. */
  12708. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12709. /**
  12710. * Remove a specific life time gradient
  12711. * @param gradient defines the gradient to remove
  12712. * @returns the current particle system
  12713. */
  12714. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12715. /**
  12716. * Adds a new size gradient
  12717. * @param gradient defines the gradient to use (between 0 and 1)
  12718. * @param factor defines the size factor to affect to the specified gradient
  12719. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12720. * @returns the current particle system
  12721. */
  12722. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12723. /**
  12724. * Remove a specific size gradient
  12725. * @param gradient defines the gradient to remove
  12726. * @returns the current particle system
  12727. */
  12728. removeSizeGradient(gradient: number): IParticleSystem;
  12729. /**
  12730. * Adds a new color remap gradient
  12731. * @param gradient defines the gradient to use (between 0 and 1)
  12732. * @param min defines the color remap minimal range
  12733. * @param max defines the color remap maximal range
  12734. * @returns the current particle system
  12735. */
  12736. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12737. /**
  12738. * Remove a specific color remap gradient
  12739. * @param gradient defines the gradient to remove
  12740. * @returns the current particle system
  12741. */
  12742. removeColorRemapGradient(gradient: number): IParticleSystem;
  12743. /**
  12744. * Adds a new alpha remap gradient
  12745. * @param gradient defines the gradient to use (between 0 and 1)
  12746. * @param min defines the alpha remap minimal range
  12747. * @param max defines the alpha remap maximal range
  12748. * @returns the current particle system
  12749. */
  12750. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12751. /**
  12752. * Remove a specific alpha remap gradient
  12753. * @param gradient defines the gradient to remove
  12754. * @returns the current particle system
  12755. */
  12756. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12757. /**
  12758. * Adds a new angular speed gradient
  12759. * @param gradient defines the gradient to use (between 0 and 1)
  12760. * @param factor defines the angular speed to affect to the specified gradient
  12761. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12762. * @returns the current particle system
  12763. */
  12764. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12765. /**
  12766. * Remove a specific angular speed gradient
  12767. * @param gradient defines the gradient to remove
  12768. * @returns the current particle system
  12769. */
  12770. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12771. /**
  12772. * Adds a new velocity gradient
  12773. * @param gradient defines the gradient to use (between 0 and 1)
  12774. * @param factor defines the velocity to affect to the specified gradient
  12775. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12776. * @returns the current particle system
  12777. */
  12778. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12779. /**
  12780. * Remove a specific velocity gradient
  12781. * @param gradient defines the gradient to remove
  12782. * @returns the current particle system
  12783. */
  12784. removeVelocityGradient(gradient: number): IParticleSystem;
  12785. /**
  12786. * Adds a new limit velocity gradient
  12787. * @param gradient defines the gradient to use (between 0 and 1)
  12788. * @param factor defines the limit velocity value to affect to the specified gradient
  12789. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12790. * @returns the current particle system
  12791. */
  12792. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12793. /**
  12794. * Remove a specific limit velocity gradient
  12795. * @param gradient defines the gradient to remove
  12796. * @returns the current particle system
  12797. */
  12798. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12799. /**
  12800. * Adds a new drag gradient
  12801. * @param gradient defines the gradient to use (between 0 and 1)
  12802. * @param factor defines the drag value to affect to the specified gradient
  12803. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12804. * @returns the current particle system
  12805. */
  12806. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12807. /**
  12808. * Remove a specific drag gradient
  12809. * @param gradient defines the gradient to remove
  12810. * @returns the current particle system
  12811. */
  12812. removeDragGradient(gradient: number): IParticleSystem;
  12813. /**
  12814. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12815. * @param gradient defines the gradient to use (between 0 and 1)
  12816. * @param factor defines the emit rate value to affect to the specified gradient
  12817. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12818. * @returns the current particle system
  12819. */
  12820. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12821. /**
  12822. * Remove a specific emit rate gradient
  12823. * @param gradient defines the gradient to remove
  12824. * @returns the current particle system
  12825. */
  12826. removeEmitRateGradient(gradient: number): IParticleSystem;
  12827. /**
  12828. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12829. * @param gradient defines the gradient to use (between 0 and 1)
  12830. * @param factor defines the start size value to affect to the specified gradient
  12831. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12832. * @returns the current particle system
  12833. */
  12834. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12835. /**
  12836. * Remove a specific start size gradient
  12837. * @param gradient defines the gradient to remove
  12838. * @returns the current particle system
  12839. */
  12840. removeStartSizeGradient(gradient: number): IParticleSystem;
  12841. private _createRampGradientTexture;
  12842. /**
  12843. * Gets the current list of ramp gradients.
  12844. * You must use addRampGradient and removeRampGradient to udpate this list
  12845. * @returns the list of ramp gradients
  12846. */
  12847. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12848. /** Force the system to rebuild all gradients that need to be resync */
  12849. forceRefreshGradients(): void;
  12850. private _syncRampGradientTexture;
  12851. /**
  12852. * Adds a new ramp gradient used to remap particle colors
  12853. * @param gradient defines the gradient to use (between 0 and 1)
  12854. * @param color defines the color to affect to the specified gradient
  12855. * @returns the current particle system
  12856. */
  12857. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12858. /**
  12859. * Remove a specific ramp gradient
  12860. * @param gradient defines the gradient to remove
  12861. * @returns the current particle system
  12862. */
  12863. removeRampGradient(gradient: number): ParticleSystem;
  12864. /**
  12865. * Adds a new color gradient
  12866. * @param gradient defines the gradient to use (between 0 and 1)
  12867. * @param color1 defines the color to affect to the specified gradient
  12868. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12869. * @returns this particle system
  12870. */
  12871. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12872. /**
  12873. * Remove a specific color gradient
  12874. * @param gradient defines the gradient to remove
  12875. * @returns this particle system
  12876. */
  12877. removeColorGradient(gradient: number): IParticleSystem;
  12878. private _fetchR;
  12879. protected _reset(): void;
  12880. private _resetEffect;
  12881. private _createVertexBuffers;
  12882. private _createIndexBuffer;
  12883. /**
  12884. * Gets the maximum number of particles active at the same time.
  12885. * @returns The max number of active particles.
  12886. */
  12887. getCapacity(): number;
  12888. /**
  12889. * Gets whether there are still active particles in the system.
  12890. * @returns True if it is alive, otherwise false.
  12891. */
  12892. isAlive(): boolean;
  12893. /**
  12894. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12895. * @returns True if it has been started, otherwise false.
  12896. */
  12897. isStarted(): boolean;
  12898. private _prepareSubEmitterInternalArray;
  12899. /**
  12900. * Starts the particle system and begins to emit
  12901. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12902. */
  12903. start(delay?: number): void;
  12904. /**
  12905. * Stops the particle system.
  12906. * @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.
  12907. */
  12908. stop(stopSubEmitters?: boolean): void;
  12909. /**
  12910. * Remove all active particles
  12911. */
  12912. reset(): void;
  12913. /**
  12914. * @hidden (for internal use only)
  12915. */
  12916. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12917. /**
  12918. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12919. * Its lifetime will start back at 0.
  12920. */
  12921. recycleParticle: (particle: Particle) => void;
  12922. private _stopSubEmitters;
  12923. private _createParticle;
  12924. private _removeFromRoot;
  12925. private _emitFromParticle;
  12926. private _update;
  12927. /** @hidden */
  12928. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12929. /** @hidden */
  12930. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12931. /**
  12932. * Fill the defines array according to the current settings of the particle system
  12933. * @param defines Array to be updated
  12934. * @param blendMode blend mode to take into account when updating the array
  12935. */
  12936. fillDefines(defines: Array<string>, blendMode: number): void;
  12937. /**
  12938. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12939. * @param uniforms Uniforms array to fill
  12940. * @param attributes Attributes array to fill
  12941. * @param samplers Samplers array to fill
  12942. */
  12943. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12944. /** @hidden */
  12945. private _getEffect;
  12946. /**
  12947. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12948. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12949. */
  12950. animate(preWarmOnly?: boolean): void;
  12951. private _appendParticleVertices;
  12952. /**
  12953. * Rebuilds the particle system.
  12954. */
  12955. rebuild(): void;
  12956. /**
  12957. * Is this system ready to be used/rendered
  12958. * @return true if the system is ready
  12959. */
  12960. isReady(): boolean;
  12961. private _render;
  12962. /**
  12963. * Renders the particle system in its current state.
  12964. * @returns the current number of particles
  12965. */
  12966. render(): number;
  12967. /**
  12968. * Disposes the particle system and free the associated resources
  12969. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12970. */
  12971. dispose(disposeTexture?: boolean): void;
  12972. /**
  12973. * Clones the particle system.
  12974. * @param name The name of the cloned object
  12975. * @param newEmitter The new emitter to use
  12976. * @returns the cloned particle system
  12977. */
  12978. clone(name: string, newEmitter: any): ParticleSystem;
  12979. /**
  12980. * Serializes the particle system to a JSON object
  12981. * @param serializeTexture defines if the texture must be serialized as well
  12982. * @returns the JSON object
  12983. */
  12984. serialize(serializeTexture?: boolean): any;
  12985. /** @hidden */
  12986. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12987. /** @hidden */
  12988. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  12989. /**
  12990. * Parses a JSON object to create a particle system.
  12991. * @param parsedParticleSystem The JSON object to parse
  12992. * @param sceneOrEngine The scene or the engine to create the particle system in
  12993. * @param rootUrl The root url to use to load external dependencies like texture
  12994. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12995. * @returns the Parsed particle system
  12996. */
  12997. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12998. }
  12999. }
  13000. declare module BABYLON {
  13001. /**
  13002. * A particle represents one of the element emitted by a particle system.
  13003. * This is mainly define by its coordinates, direction, velocity and age.
  13004. */
  13005. export class Particle {
  13006. /**
  13007. * The particle system the particle belongs to.
  13008. */
  13009. particleSystem: ParticleSystem;
  13010. private static _Count;
  13011. /**
  13012. * Unique ID of the particle
  13013. */
  13014. id: number;
  13015. /**
  13016. * The world position of the particle in the scene.
  13017. */
  13018. position: Vector3;
  13019. /**
  13020. * The world direction of the particle in the scene.
  13021. */
  13022. direction: Vector3;
  13023. /**
  13024. * The color of the particle.
  13025. */
  13026. color: Color4;
  13027. /**
  13028. * The color change of the particle per step.
  13029. */
  13030. colorStep: Color4;
  13031. /**
  13032. * Defines how long will the life of the particle be.
  13033. */
  13034. lifeTime: number;
  13035. /**
  13036. * The current age of the particle.
  13037. */
  13038. age: number;
  13039. /**
  13040. * The current size of the particle.
  13041. */
  13042. size: number;
  13043. /**
  13044. * The current scale of the particle.
  13045. */
  13046. scale: Vector2;
  13047. /**
  13048. * The current angle of the particle.
  13049. */
  13050. angle: number;
  13051. /**
  13052. * Defines how fast is the angle changing.
  13053. */
  13054. angularSpeed: number;
  13055. /**
  13056. * Defines the cell index used by the particle to be rendered from a sprite.
  13057. */
  13058. cellIndex: number;
  13059. /**
  13060. * The information required to support color remapping
  13061. */
  13062. remapData: Vector4;
  13063. /** @hidden */
  13064. _randomCellOffset?: number;
  13065. /** @hidden */
  13066. _initialDirection: Nullable<Vector3>;
  13067. /** @hidden */
  13068. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13069. /** @hidden */
  13070. _initialStartSpriteCellID: number;
  13071. /** @hidden */
  13072. _initialEndSpriteCellID: number;
  13073. /** @hidden */
  13074. _currentColorGradient: Nullable<ColorGradient>;
  13075. /** @hidden */
  13076. _currentColor1: Color4;
  13077. /** @hidden */
  13078. _currentColor2: Color4;
  13079. /** @hidden */
  13080. _currentSizeGradient: Nullable<FactorGradient>;
  13081. /** @hidden */
  13082. _currentSize1: number;
  13083. /** @hidden */
  13084. _currentSize2: number;
  13085. /** @hidden */
  13086. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13087. /** @hidden */
  13088. _currentAngularSpeed1: number;
  13089. /** @hidden */
  13090. _currentAngularSpeed2: number;
  13091. /** @hidden */
  13092. _currentVelocityGradient: Nullable<FactorGradient>;
  13093. /** @hidden */
  13094. _currentVelocity1: number;
  13095. /** @hidden */
  13096. _currentVelocity2: number;
  13097. /** @hidden */
  13098. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13099. /** @hidden */
  13100. _currentLimitVelocity1: number;
  13101. /** @hidden */
  13102. _currentLimitVelocity2: number;
  13103. /** @hidden */
  13104. _currentDragGradient: Nullable<FactorGradient>;
  13105. /** @hidden */
  13106. _currentDrag1: number;
  13107. /** @hidden */
  13108. _currentDrag2: number;
  13109. /** @hidden */
  13110. _randomNoiseCoordinates1: Vector3;
  13111. /** @hidden */
  13112. _randomNoiseCoordinates2: Vector3;
  13113. /** @hidden */
  13114. _localPosition?: Vector3;
  13115. /**
  13116. * Creates a new instance Particle
  13117. * @param particleSystem the particle system the particle belongs to
  13118. */
  13119. constructor(
  13120. /**
  13121. * The particle system the particle belongs to.
  13122. */
  13123. particleSystem: ParticleSystem);
  13124. private updateCellInfoFromSystem;
  13125. /**
  13126. * Defines how the sprite cell index is updated for the particle
  13127. */
  13128. updateCellIndex(): void;
  13129. /** @hidden */
  13130. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13131. /** @hidden */
  13132. _inheritParticleInfoToSubEmitters(): void;
  13133. /** @hidden */
  13134. _reset(): void;
  13135. /**
  13136. * Copy the properties of particle to another one.
  13137. * @param other the particle to copy the information to.
  13138. */
  13139. copyTo(other: Particle): void;
  13140. }
  13141. }
  13142. declare module BABYLON {
  13143. /**
  13144. * Particle emitter represents a volume emitting particles.
  13145. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13146. */
  13147. export interface IParticleEmitterType {
  13148. /**
  13149. * Called by the particle System when the direction is computed for the created particle.
  13150. * @param worldMatrix is the world matrix of the particle system
  13151. * @param directionToUpdate is the direction vector to update with the result
  13152. * @param particle is the particle we are computed the direction for
  13153. * @param isLocal defines if the direction should be set in local space
  13154. */
  13155. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13156. /**
  13157. * Called by the particle System when the position is computed for the created particle.
  13158. * @param worldMatrix is the world matrix of the particle system
  13159. * @param positionToUpdate is the position vector to update with the result
  13160. * @param particle is the particle we are computed the position for
  13161. * @param isLocal defines if the position should be set in local space
  13162. */
  13163. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13164. /**
  13165. * Clones the current emitter and returns a copy of it
  13166. * @returns the new emitter
  13167. */
  13168. clone(): IParticleEmitterType;
  13169. /**
  13170. * Called by the GPUParticleSystem to setup the update shader
  13171. * @param effect defines the update shader
  13172. */
  13173. applyToShader(effect: Effect): void;
  13174. /**
  13175. * Returns a string to use to update the GPU particles update shader
  13176. * @returns the effect defines string
  13177. */
  13178. getEffectDefines(): string;
  13179. /**
  13180. * Returns a string representing the class name
  13181. * @returns a string containing the class name
  13182. */
  13183. getClassName(): string;
  13184. /**
  13185. * Serializes the particle system to a JSON object.
  13186. * @returns the JSON object
  13187. */
  13188. serialize(): any;
  13189. /**
  13190. * Parse properties from a JSON object
  13191. * @param serializationObject defines the JSON object
  13192. * @param scene defines the hosting scene
  13193. */
  13194. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13195. }
  13196. }
  13197. declare module BABYLON {
  13198. /**
  13199. * Particle emitter emitting particles from the inside of a box.
  13200. * It emits the particles randomly between 2 given directions.
  13201. */
  13202. export class BoxParticleEmitter implements IParticleEmitterType {
  13203. /**
  13204. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13205. */
  13206. direction1: Vector3;
  13207. /**
  13208. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13209. */
  13210. direction2: Vector3;
  13211. /**
  13212. * 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.
  13213. */
  13214. minEmitBox: Vector3;
  13215. /**
  13216. * 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.
  13217. */
  13218. maxEmitBox: Vector3;
  13219. /**
  13220. * Creates a new instance BoxParticleEmitter
  13221. */
  13222. constructor();
  13223. /**
  13224. * Called by the particle System when the direction is computed for the created particle.
  13225. * @param worldMatrix is the world matrix of the particle system
  13226. * @param directionToUpdate is the direction vector to update with the result
  13227. * @param particle is the particle we are computed the direction for
  13228. * @param isLocal defines if the direction should be set in local space
  13229. */
  13230. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13231. /**
  13232. * Called by the particle System when the position is computed for the created particle.
  13233. * @param worldMatrix is the world matrix of the particle system
  13234. * @param positionToUpdate is the position vector to update with the result
  13235. * @param particle is the particle we are computed the position for
  13236. * @param isLocal defines if the position should be set in local space
  13237. */
  13238. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13239. /**
  13240. * Clones the current emitter and returns a copy of it
  13241. * @returns the new emitter
  13242. */
  13243. clone(): BoxParticleEmitter;
  13244. /**
  13245. * Called by the GPUParticleSystem to setup the update shader
  13246. * @param effect defines the update shader
  13247. */
  13248. applyToShader(effect: Effect): void;
  13249. /**
  13250. * Returns a string to use to update the GPU particles update shader
  13251. * @returns a string containng the defines string
  13252. */
  13253. getEffectDefines(): string;
  13254. /**
  13255. * Returns the string "BoxParticleEmitter"
  13256. * @returns a string containing the class name
  13257. */
  13258. getClassName(): string;
  13259. /**
  13260. * Serializes the particle system to a JSON object.
  13261. * @returns the JSON object
  13262. */
  13263. serialize(): any;
  13264. /**
  13265. * Parse properties from a JSON object
  13266. * @param serializationObject defines the JSON object
  13267. */
  13268. parse(serializationObject: any): void;
  13269. }
  13270. }
  13271. declare module BABYLON {
  13272. /**
  13273. * Particle emitter emitting particles from the inside of a cone.
  13274. * It emits the particles alongside the cone volume from the base to the particle.
  13275. * The emission direction might be randomized.
  13276. */
  13277. export class ConeParticleEmitter implements IParticleEmitterType {
  13278. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13279. directionRandomizer: number;
  13280. private _radius;
  13281. private _angle;
  13282. private _height;
  13283. /**
  13284. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13285. */
  13286. radiusRange: number;
  13287. /**
  13288. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13289. */
  13290. heightRange: number;
  13291. /**
  13292. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13293. */
  13294. emitFromSpawnPointOnly: boolean;
  13295. /**
  13296. * Gets or sets the radius of the emission cone
  13297. */
  13298. get radius(): number;
  13299. set radius(value: number);
  13300. /**
  13301. * Gets or sets the angle of the emission cone
  13302. */
  13303. get angle(): number;
  13304. set angle(value: number);
  13305. private _buildHeight;
  13306. /**
  13307. * Creates a new instance ConeParticleEmitter
  13308. * @param radius the radius of the emission cone (1 by default)
  13309. * @param angle the cone base angle (PI by default)
  13310. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13311. */
  13312. constructor(radius?: number, angle?: number,
  13313. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13314. directionRandomizer?: number);
  13315. /**
  13316. * Called by the particle System when the direction is computed for the created particle.
  13317. * @param worldMatrix is the world matrix of the particle system
  13318. * @param directionToUpdate is the direction vector to update with the result
  13319. * @param particle is the particle we are computed the direction for
  13320. * @param isLocal defines if the direction should be set in local space
  13321. */
  13322. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13323. /**
  13324. * Called by the particle System when the position is computed for the created particle.
  13325. * @param worldMatrix is the world matrix of the particle system
  13326. * @param positionToUpdate is the position vector to update with the result
  13327. * @param particle is the particle we are computed the position for
  13328. * @param isLocal defines if the position should be set in local space
  13329. */
  13330. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13331. /**
  13332. * Clones the current emitter and returns a copy of it
  13333. * @returns the new emitter
  13334. */
  13335. clone(): ConeParticleEmitter;
  13336. /**
  13337. * Called by the GPUParticleSystem to setup the update shader
  13338. * @param effect defines the update shader
  13339. */
  13340. applyToShader(effect: Effect): void;
  13341. /**
  13342. * Returns a string to use to update the GPU particles update shader
  13343. * @returns a string containng the defines string
  13344. */
  13345. getEffectDefines(): string;
  13346. /**
  13347. * Returns the string "ConeParticleEmitter"
  13348. * @returns a string containing the class name
  13349. */
  13350. getClassName(): string;
  13351. /**
  13352. * Serializes the particle system to a JSON object.
  13353. * @returns the JSON object
  13354. */
  13355. serialize(): any;
  13356. /**
  13357. * Parse properties from a JSON object
  13358. * @param serializationObject defines the JSON object
  13359. */
  13360. parse(serializationObject: any): void;
  13361. }
  13362. }
  13363. declare module BABYLON {
  13364. /**
  13365. * Particle emitter emitting particles from the inside of a cylinder.
  13366. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13367. */
  13368. export class CylinderParticleEmitter implements IParticleEmitterType {
  13369. /**
  13370. * The radius of the emission cylinder.
  13371. */
  13372. radius: number;
  13373. /**
  13374. * The height of the emission cylinder.
  13375. */
  13376. height: number;
  13377. /**
  13378. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13379. */
  13380. radiusRange: number;
  13381. /**
  13382. * How much to randomize the particle direction [0-1].
  13383. */
  13384. directionRandomizer: number;
  13385. /**
  13386. * Creates a new instance CylinderParticleEmitter
  13387. * @param radius the radius of the emission cylinder (1 by default)
  13388. * @param height the height of the emission cylinder (1 by default)
  13389. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13390. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13391. */
  13392. constructor(
  13393. /**
  13394. * The radius of the emission cylinder.
  13395. */
  13396. radius?: number,
  13397. /**
  13398. * The height of the emission cylinder.
  13399. */
  13400. height?: number,
  13401. /**
  13402. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13403. */
  13404. radiusRange?: number,
  13405. /**
  13406. * How much to randomize the particle direction [0-1].
  13407. */
  13408. directionRandomizer?: number);
  13409. /**
  13410. * Called by the particle System when the direction is computed for the created particle.
  13411. * @param worldMatrix is the world matrix of the particle system
  13412. * @param directionToUpdate is the direction vector to update with the result
  13413. * @param particle is the particle we are computed the direction for
  13414. * @param isLocal defines if the direction should be set in local space
  13415. */
  13416. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13417. /**
  13418. * Called by the particle System when the position is computed for the created particle.
  13419. * @param worldMatrix is the world matrix of the particle system
  13420. * @param positionToUpdate is the position vector to update with the result
  13421. * @param particle is the particle we are computed the position for
  13422. * @param isLocal defines if the position should be set in local space
  13423. */
  13424. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13425. /**
  13426. * Clones the current emitter and returns a copy of it
  13427. * @returns the new emitter
  13428. */
  13429. clone(): CylinderParticleEmitter;
  13430. /**
  13431. * Called by the GPUParticleSystem to setup the update shader
  13432. * @param effect defines the update shader
  13433. */
  13434. applyToShader(effect: Effect): void;
  13435. /**
  13436. * Returns a string to use to update the GPU particles update shader
  13437. * @returns a string containng the defines string
  13438. */
  13439. getEffectDefines(): string;
  13440. /**
  13441. * Returns the string "CylinderParticleEmitter"
  13442. * @returns a string containing the class name
  13443. */
  13444. getClassName(): string;
  13445. /**
  13446. * Serializes the particle system to a JSON object.
  13447. * @returns the JSON object
  13448. */
  13449. serialize(): any;
  13450. /**
  13451. * Parse properties from a JSON object
  13452. * @param serializationObject defines the JSON object
  13453. */
  13454. parse(serializationObject: any): void;
  13455. }
  13456. /**
  13457. * Particle emitter emitting particles from the inside of a cylinder.
  13458. * It emits the particles randomly between two vectors.
  13459. */
  13460. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13461. /**
  13462. * The min limit of the emission direction.
  13463. */
  13464. direction1: Vector3;
  13465. /**
  13466. * The max limit of the emission direction.
  13467. */
  13468. direction2: Vector3;
  13469. /**
  13470. * Creates a new instance CylinderDirectedParticleEmitter
  13471. * @param radius the radius of the emission cylinder (1 by default)
  13472. * @param height the height of the emission cylinder (1 by default)
  13473. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13474. * @param direction1 the min limit of the emission direction (up vector by default)
  13475. * @param direction2 the max limit of the emission direction (up vector by default)
  13476. */
  13477. constructor(radius?: number, height?: number, radiusRange?: number,
  13478. /**
  13479. * The min limit of the emission direction.
  13480. */
  13481. direction1?: Vector3,
  13482. /**
  13483. * The max limit of the emission direction.
  13484. */
  13485. direction2?: Vector3);
  13486. /**
  13487. * Called by the particle System when the direction is computed for the created particle.
  13488. * @param worldMatrix is the world matrix of the particle system
  13489. * @param directionToUpdate is the direction vector to update with the result
  13490. * @param particle is the particle we are computed the direction for
  13491. */
  13492. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13493. /**
  13494. * Clones the current emitter and returns a copy of it
  13495. * @returns the new emitter
  13496. */
  13497. clone(): CylinderDirectedParticleEmitter;
  13498. /**
  13499. * Called by the GPUParticleSystem to setup the update shader
  13500. * @param effect defines the update shader
  13501. */
  13502. applyToShader(effect: Effect): void;
  13503. /**
  13504. * Returns a string to use to update the GPU particles update shader
  13505. * @returns a string containng the defines string
  13506. */
  13507. getEffectDefines(): string;
  13508. /**
  13509. * Returns the string "CylinderDirectedParticleEmitter"
  13510. * @returns a string containing the class name
  13511. */
  13512. getClassName(): string;
  13513. /**
  13514. * Serializes the particle system to a JSON object.
  13515. * @returns the JSON object
  13516. */
  13517. serialize(): any;
  13518. /**
  13519. * Parse properties from a JSON object
  13520. * @param serializationObject defines the JSON object
  13521. */
  13522. parse(serializationObject: any): void;
  13523. }
  13524. }
  13525. declare module BABYLON {
  13526. /**
  13527. * Particle emitter emitting particles from the inside of a hemisphere.
  13528. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13529. */
  13530. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13531. /**
  13532. * The radius of the emission hemisphere.
  13533. */
  13534. radius: number;
  13535. /**
  13536. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13537. */
  13538. radiusRange: number;
  13539. /**
  13540. * How much to randomize the particle direction [0-1].
  13541. */
  13542. directionRandomizer: number;
  13543. /**
  13544. * Creates a new instance HemisphericParticleEmitter
  13545. * @param radius the radius of the emission hemisphere (1 by default)
  13546. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13547. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13548. */
  13549. constructor(
  13550. /**
  13551. * The radius of the emission hemisphere.
  13552. */
  13553. radius?: number,
  13554. /**
  13555. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13556. */
  13557. radiusRange?: number,
  13558. /**
  13559. * How much to randomize the particle direction [0-1].
  13560. */
  13561. directionRandomizer?: number);
  13562. /**
  13563. * Called by the particle System when the direction is computed for the created particle.
  13564. * @param worldMatrix is the world matrix of the particle system
  13565. * @param directionToUpdate is the direction vector to update with the result
  13566. * @param particle is the particle we are computed the direction for
  13567. * @param isLocal defines if the direction should be set in local space
  13568. */
  13569. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13570. /**
  13571. * Called by the particle System when the position is computed for the created particle.
  13572. * @param worldMatrix is the world matrix of the particle system
  13573. * @param positionToUpdate is the position vector to update with the result
  13574. * @param particle is the particle we are computed the position for
  13575. * @param isLocal defines if the position should be set in local space
  13576. */
  13577. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13578. /**
  13579. * Clones the current emitter and returns a copy of it
  13580. * @returns the new emitter
  13581. */
  13582. clone(): HemisphericParticleEmitter;
  13583. /**
  13584. * Called by the GPUParticleSystem to setup the update shader
  13585. * @param effect defines the update shader
  13586. */
  13587. applyToShader(effect: Effect): void;
  13588. /**
  13589. * Returns a string to use to update the GPU particles update shader
  13590. * @returns a string containng the defines string
  13591. */
  13592. getEffectDefines(): string;
  13593. /**
  13594. * Returns the string "HemisphericParticleEmitter"
  13595. * @returns a string containing the class name
  13596. */
  13597. getClassName(): string;
  13598. /**
  13599. * Serializes the particle system to a JSON object.
  13600. * @returns the JSON object
  13601. */
  13602. serialize(): any;
  13603. /**
  13604. * Parse properties from a JSON object
  13605. * @param serializationObject defines the JSON object
  13606. */
  13607. parse(serializationObject: any): void;
  13608. }
  13609. }
  13610. declare module BABYLON {
  13611. /**
  13612. * Particle emitter emitting particles from a point.
  13613. * It emits the particles randomly between 2 given directions.
  13614. */
  13615. export class PointParticleEmitter implements IParticleEmitterType {
  13616. /**
  13617. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13618. */
  13619. direction1: Vector3;
  13620. /**
  13621. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13622. */
  13623. direction2: Vector3;
  13624. /**
  13625. * Creates a new instance PointParticleEmitter
  13626. */
  13627. constructor();
  13628. /**
  13629. * Called by the particle System when the direction is computed for the created particle.
  13630. * @param worldMatrix is the world matrix of the particle system
  13631. * @param directionToUpdate is the direction vector to update with the result
  13632. * @param particle is the particle we are computed the direction for
  13633. * @param isLocal defines if the direction should be set in local space
  13634. */
  13635. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13636. /**
  13637. * Called by the particle System when the position is computed for the created particle.
  13638. * @param worldMatrix is the world matrix of the particle system
  13639. * @param positionToUpdate is the position vector to update with the result
  13640. * @param particle is the particle we are computed the position for
  13641. * @param isLocal defines if the position should be set in local space
  13642. */
  13643. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13644. /**
  13645. * Clones the current emitter and returns a copy of it
  13646. * @returns the new emitter
  13647. */
  13648. clone(): PointParticleEmitter;
  13649. /**
  13650. * Called by the GPUParticleSystem to setup the update shader
  13651. * @param effect defines the update shader
  13652. */
  13653. applyToShader(effect: Effect): void;
  13654. /**
  13655. * Returns a string to use to update the GPU particles update shader
  13656. * @returns a string containng the defines string
  13657. */
  13658. getEffectDefines(): string;
  13659. /**
  13660. * Returns the string "PointParticleEmitter"
  13661. * @returns a string containing the class name
  13662. */
  13663. getClassName(): string;
  13664. /**
  13665. * Serializes the particle system to a JSON object.
  13666. * @returns the JSON object
  13667. */
  13668. serialize(): any;
  13669. /**
  13670. * Parse properties from a JSON object
  13671. * @param serializationObject defines the JSON object
  13672. */
  13673. parse(serializationObject: any): void;
  13674. }
  13675. }
  13676. declare module BABYLON {
  13677. /**
  13678. * Particle emitter emitting particles from the inside of a sphere.
  13679. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13680. */
  13681. export class SphereParticleEmitter implements IParticleEmitterType {
  13682. /**
  13683. * The radius of the emission sphere.
  13684. */
  13685. radius: number;
  13686. /**
  13687. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13688. */
  13689. radiusRange: number;
  13690. /**
  13691. * How much to randomize the particle direction [0-1].
  13692. */
  13693. directionRandomizer: number;
  13694. /**
  13695. * Creates a new instance SphereParticleEmitter
  13696. * @param radius the radius of the emission sphere (1 by default)
  13697. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13698. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13699. */
  13700. constructor(
  13701. /**
  13702. * The radius of the emission sphere.
  13703. */
  13704. radius?: number,
  13705. /**
  13706. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13707. */
  13708. radiusRange?: number,
  13709. /**
  13710. * How much to randomize the particle direction [0-1].
  13711. */
  13712. directionRandomizer?: number);
  13713. /**
  13714. * Called by the particle System when the direction is computed for the created particle.
  13715. * @param worldMatrix is the world matrix of the particle system
  13716. * @param directionToUpdate is the direction vector to update with the result
  13717. * @param particle is the particle we are computed the direction for
  13718. * @param isLocal defines if the direction should be set in local space
  13719. */
  13720. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13721. /**
  13722. * Called by the particle System when the position is computed for the created particle.
  13723. * @param worldMatrix is the world matrix of the particle system
  13724. * @param positionToUpdate is the position vector to update with the result
  13725. * @param particle is the particle we are computed the position for
  13726. * @param isLocal defines if the position should be set in local space
  13727. */
  13728. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13729. /**
  13730. * Clones the current emitter and returns a copy of it
  13731. * @returns the new emitter
  13732. */
  13733. clone(): SphereParticleEmitter;
  13734. /**
  13735. * Called by the GPUParticleSystem to setup the update shader
  13736. * @param effect defines the update shader
  13737. */
  13738. applyToShader(effect: Effect): void;
  13739. /**
  13740. * Returns a string to use to update the GPU particles update shader
  13741. * @returns a string containng the defines string
  13742. */
  13743. getEffectDefines(): string;
  13744. /**
  13745. * Returns the string "SphereParticleEmitter"
  13746. * @returns a string containing the class name
  13747. */
  13748. getClassName(): string;
  13749. /**
  13750. * Serializes the particle system to a JSON object.
  13751. * @returns the JSON object
  13752. */
  13753. serialize(): any;
  13754. /**
  13755. * Parse properties from a JSON object
  13756. * @param serializationObject defines the JSON object
  13757. */
  13758. parse(serializationObject: any): void;
  13759. }
  13760. /**
  13761. * Particle emitter emitting particles from the inside of a sphere.
  13762. * It emits the particles randomly between two vectors.
  13763. */
  13764. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13765. /**
  13766. * The min limit of the emission direction.
  13767. */
  13768. direction1: Vector3;
  13769. /**
  13770. * The max limit of the emission direction.
  13771. */
  13772. direction2: Vector3;
  13773. /**
  13774. * Creates a new instance SphereDirectedParticleEmitter
  13775. * @param radius the radius of the emission sphere (1 by default)
  13776. * @param direction1 the min limit of the emission direction (up vector by default)
  13777. * @param direction2 the max limit of the emission direction (up vector by default)
  13778. */
  13779. constructor(radius?: number,
  13780. /**
  13781. * The min limit of the emission direction.
  13782. */
  13783. direction1?: Vector3,
  13784. /**
  13785. * The max limit of the emission direction.
  13786. */
  13787. direction2?: Vector3);
  13788. /**
  13789. * Called by the particle System when the direction is computed for the created particle.
  13790. * @param worldMatrix is the world matrix of the particle system
  13791. * @param directionToUpdate is the direction vector to update with the result
  13792. * @param particle is the particle we are computed the direction for
  13793. */
  13794. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13795. /**
  13796. * Clones the current emitter and returns a copy of it
  13797. * @returns the new emitter
  13798. */
  13799. clone(): SphereDirectedParticleEmitter;
  13800. /**
  13801. * Called by the GPUParticleSystem to setup the update shader
  13802. * @param effect defines the update shader
  13803. */
  13804. applyToShader(effect: Effect): void;
  13805. /**
  13806. * Returns a string to use to update the GPU particles update shader
  13807. * @returns a string containng the defines string
  13808. */
  13809. getEffectDefines(): string;
  13810. /**
  13811. * Returns the string "SphereDirectedParticleEmitter"
  13812. * @returns a string containing the class name
  13813. */
  13814. getClassName(): string;
  13815. /**
  13816. * Serializes the particle system to a JSON object.
  13817. * @returns the JSON object
  13818. */
  13819. serialize(): any;
  13820. /**
  13821. * Parse properties from a JSON object
  13822. * @param serializationObject defines the JSON object
  13823. */
  13824. parse(serializationObject: any): void;
  13825. }
  13826. }
  13827. declare module BABYLON {
  13828. /**
  13829. * Particle emitter emitting particles from a custom list of positions.
  13830. */
  13831. export class CustomParticleEmitter implements IParticleEmitterType {
  13832. /**
  13833. * Gets or sets the position generator that will create the inital position of each particle.
  13834. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13835. */
  13836. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13837. /**
  13838. * Gets or sets the destination generator that will create the final destination of each particle.
  13839. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13840. */
  13841. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13842. /**
  13843. * Creates a new instance CustomParticleEmitter
  13844. */
  13845. constructor();
  13846. /**
  13847. * Called by the particle System when the direction is computed for the created particle.
  13848. * @param worldMatrix is the world matrix of the particle system
  13849. * @param directionToUpdate is the direction vector to update with the result
  13850. * @param particle is the particle we are computed the direction for
  13851. * @param isLocal defines if the direction should be set in local space
  13852. */
  13853. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13854. /**
  13855. * Called by the particle System when the position is computed for the created particle.
  13856. * @param worldMatrix is the world matrix of the particle system
  13857. * @param positionToUpdate is the position vector to update with the result
  13858. * @param particle is the particle we are computed the position for
  13859. * @param isLocal defines if the position should be set in local space
  13860. */
  13861. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13862. /**
  13863. * Clones the current emitter and returns a copy of it
  13864. * @returns the new emitter
  13865. */
  13866. clone(): CustomParticleEmitter;
  13867. /**
  13868. * Called by the GPUParticleSystem to setup the update shader
  13869. * @param effect defines the update shader
  13870. */
  13871. applyToShader(effect: Effect): void;
  13872. /**
  13873. * Returns a string to use to update the GPU particles update shader
  13874. * @returns a string containng the defines string
  13875. */
  13876. getEffectDefines(): string;
  13877. /**
  13878. * Returns the string "PointParticleEmitter"
  13879. * @returns a string containing the class name
  13880. */
  13881. getClassName(): string;
  13882. /**
  13883. * Serializes the particle system to a JSON object.
  13884. * @returns the JSON object
  13885. */
  13886. serialize(): any;
  13887. /**
  13888. * Parse properties from a JSON object
  13889. * @param serializationObject defines the JSON object
  13890. */
  13891. parse(serializationObject: any): void;
  13892. }
  13893. }
  13894. declare module BABYLON {
  13895. /**
  13896. * Particle emitter emitting particles from the inside of a box.
  13897. * It emits the particles randomly between 2 given directions.
  13898. */
  13899. export class MeshParticleEmitter implements IParticleEmitterType {
  13900. private _indices;
  13901. private _positions;
  13902. private _normals;
  13903. private _storedNormal;
  13904. private _mesh;
  13905. /**
  13906. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13907. */
  13908. direction1: Vector3;
  13909. /**
  13910. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13911. */
  13912. direction2: Vector3;
  13913. /**
  13914. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13915. */
  13916. useMeshNormalsForDirection: boolean;
  13917. /** Defines the mesh to use as source */
  13918. get mesh(): Nullable<AbstractMesh>;
  13919. set mesh(value: Nullable<AbstractMesh>);
  13920. /**
  13921. * Creates a new instance MeshParticleEmitter
  13922. * @param mesh defines the mesh to use as source
  13923. */
  13924. constructor(mesh?: Nullable<AbstractMesh>);
  13925. /**
  13926. * Called by the particle System when the direction is computed for the created particle.
  13927. * @param worldMatrix is the world matrix of the particle system
  13928. * @param directionToUpdate is the direction vector to update with the result
  13929. * @param particle is the particle we are computed the direction for
  13930. * @param isLocal defines if the direction should be set in local space
  13931. */
  13932. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13933. /**
  13934. * Called by the particle System when the position is computed for the created particle.
  13935. * @param worldMatrix is the world matrix of the particle system
  13936. * @param positionToUpdate is the position vector to update with the result
  13937. * @param particle is the particle we are computed the position for
  13938. * @param isLocal defines if the position should be set in local space
  13939. */
  13940. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13941. /**
  13942. * Clones the current emitter and returns a copy of it
  13943. * @returns the new emitter
  13944. */
  13945. clone(): MeshParticleEmitter;
  13946. /**
  13947. * Called by the GPUParticleSystem to setup the update shader
  13948. * @param effect defines the update shader
  13949. */
  13950. applyToShader(effect: Effect): void;
  13951. /**
  13952. * Returns a string to use to update the GPU particles update shader
  13953. * @returns a string containng the defines string
  13954. */
  13955. getEffectDefines(): string;
  13956. /**
  13957. * Returns the string "BoxParticleEmitter"
  13958. * @returns a string containing the class name
  13959. */
  13960. getClassName(): string;
  13961. /**
  13962. * Serializes the particle system to a JSON object.
  13963. * @returns the JSON object
  13964. */
  13965. serialize(): any;
  13966. /**
  13967. * Parse properties from a JSON object
  13968. * @param serializationObject defines the JSON object
  13969. * @param scene defines the hosting scene
  13970. */
  13971. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13972. }
  13973. }
  13974. declare module BABYLON {
  13975. /**
  13976. * Interface representing a particle system in Babylon.js.
  13977. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13978. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13979. */
  13980. export interface IParticleSystem {
  13981. /**
  13982. * List of animations used by the particle system.
  13983. */
  13984. animations: Animation[];
  13985. /**
  13986. * The id of the Particle system.
  13987. */
  13988. id: string;
  13989. /**
  13990. * The name of the Particle system.
  13991. */
  13992. name: string;
  13993. /**
  13994. * The emitter represents the Mesh or position we are attaching the particle system to.
  13995. */
  13996. emitter: Nullable<AbstractMesh | Vector3>;
  13997. /**
  13998. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13999. */
  14000. isBillboardBased: boolean;
  14001. /**
  14002. * The rendering group used by the Particle system to chose when to render.
  14003. */
  14004. renderingGroupId: number;
  14005. /**
  14006. * The layer mask we are rendering the particles through.
  14007. */
  14008. layerMask: number;
  14009. /**
  14010. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14011. */
  14012. updateSpeed: number;
  14013. /**
  14014. * The amount of time the particle system is running (depends of the overall update speed).
  14015. */
  14016. targetStopDuration: number;
  14017. /**
  14018. * The texture used to render each particle. (this can be a spritesheet)
  14019. */
  14020. particleTexture: Nullable<BaseTexture>;
  14021. /**
  14022. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14023. */
  14024. blendMode: number;
  14025. /**
  14026. * Minimum life time of emitting particles.
  14027. */
  14028. minLifeTime: number;
  14029. /**
  14030. * Maximum life time of emitting particles.
  14031. */
  14032. maxLifeTime: number;
  14033. /**
  14034. * Minimum Size of emitting particles.
  14035. */
  14036. minSize: number;
  14037. /**
  14038. * Maximum Size of emitting particles.
  14039. */
  14040. maxSize: number;
  14041. /**
  14042. * Minimum scale of emitting particles on X axis.
  14043. */
  14044. minScaleX: number;
  14045. /**
  14046. * Maximum scale of emitting particles on X axis.
  14047. */
  14048. maxScaleX: number;
  14049. /**
  14050. * Minimum scale of emitting particles on Y axis.
  14051. */
  14052. minScaleY: number;
  14053. /**
  14054. * Maximum scale of emitting particles on Y axis.
  14055. */
  14056. maxScaleY: number;
  14057. /**
  14058. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14059. */
  14060. color1: Color4;
  14061. /**
  14062. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14063. */
  14064. color2: Color4;
  14065. /**
  14066. * Color the particle will have at the end of its lifetime.
  14067. */
  14068. colorDead: Color4;
  14069. /**
  14070. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14071. */
  14072. emitRate: number;
  14073. /**
  14074. * You can use gravity if you want to give an orientation to your particles.
  14075. */
  14076. gravity: Vector3;
  14077. /**
  14078. * Minimum power of emitting particles.
  14079. */
  14080. minEmitPower: number;
  14081. /**
  14082. * Maximum power of emitting particles.
  14083. */
  14084. maxEmitPower: number;
  14085. /**
  14086. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14087. */
  14088. minAngularSpeed: number;
  14089. /**
  14090. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14091. */
  14092. maxAngularSpeed: number;
  14093. /**
  14094. * Gets or sets the minimal initial rotation in radians.
  14095. */
  14096. minInitialRotation: number;
  14097. /**
  14098. * Gets or sets the maximal initial rotation in radians.
  14099. */
  14100. maxInitialRotation: number;
  14101. /**
  14102. * The particle emitter type defines the emitter used by the particle system.
  14103. * It can be for example box, sphere, or cone...
  14104. */
  14105. particleEmitterType: Nullable<IParticleEmitterType>;
  14106. /**
  14107. * Defines the delay in milliseconds before starting the system (0 by default)
  14108. */
  14109. startDelay: number;
  14110. /**
  14111. * 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
  14112. */
  14113. preWarmCycles: number;
  14114. /**
  14115. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14116. */
  14117. preWarmStepOffset: number;
  14118. /**
  14119. * 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)
  14120. */
  14121. spriteCellChangeSpeed: number;
  14122. /**
  14123. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14124. */
  14125. startSpriteCellID: number;
  14126. /**
  14127. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14128. */
  14129. endSpriteCellID: number;
  14130. /**
  14131. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14132. */
  14133. spriteCellWidth: number;
  14134. /**
  14135. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14136. */
  14137. spriteCellHeight: number;
  14138. /**
  14139. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14140. */
  14141. spriteRandomStartCell: boolean;
  14142. /**
  14143. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14144. */
  14145. isAnimationSheetEnabled: boolean;
  14146. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14147. translationPivot: Vector2;
  14148. /**
  14149. * Gets or sets a texture used to add random noise to particle positions
  14150. */
  14151. noiseTexture: Nullable<BaseTexture>;
  14152. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14153. noiseStrength: Vector3;
  14154. /**
  14155. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14156. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14157. */
  14158. billboardMode: number;
  14159. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14160. limitVelocityDamping: number;
  14161. /**
  14162. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14163. */
  14164. beginAnimationOnStart: boolean;
  14165. /**
  14166. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14167. */
  14168. beginAnimationFrom: number;
  14169. /**
  14170. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14171. */
  14172. beginAnimationTo: number;
  14173. /**
  14174. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14175. */
  14176. beginAnimationLoop: boolean;
  14177. /**
  14178. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14179. */
  14180. disposeOnStop: boolean;
  14181. /**
  14182. * Specifies if the particles are updated in emitter local space or world space
  14183. */
  14184. isLocal: boolean;
  14185. /** Snippet ID if the particle system was created from the snippet server */
  14186. snippetId: string;
  14187. /** Gets or sets a matrix to use to compute projection */
  14188. defaultProjectionMatrix: Matrix;
  14189. /**
  14190. * Gets the maximum number of particles active at the same time.
  14191. * @returns The max number of active particles.
  14192. */
  14193. getCapacity(): number;
  14194. /**
  14195. * Gets the number of particles active at the same time.
  14196. * @returns The number of active particles.
  14197. */
  14198. getActiveCount(): number;
  14199. /**
  14200. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14201. * @returns True if it has been started, otherwise false.
  14202. */
  14203. isStarted(): boolean;
  14204. /**
  14205. * Animates the particle system for this frame.
  14206. */
  14207. animate(): void;
  14208. /**
  14209. * Renders the particle system in its current state.
  14210. * @returns the current number of particles
  14211. */
  14212. render(): number;
  14213. /**
  14214. * Dispose the particle system and frees its associated resources.
  14215. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14216. */
  14217. dispose(disposeTexture?: boolean): void;
  14218. /**
  14219. * An event triggered when the system is disposed
  14220. */
  14221. onDisposeObservable: Observable<IParticleSystem>;
  14222. /**
  14223. * Clones the particle system.
  14224. * @param name The name of the cloned object
  14225. * @param newEmitter The new emitter to use
  14226. * @returns the cloned particle system
  14227. */
  14228. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14229. /**
  14230. * Serializes the particle system to a JSON object
  14231. * @param serializeTexture defines if the texture must be serialized as well
  14232. * @returns the JSON object
  14233. */
  14234. serialize(serializeTexture: boolean): any;
  14235. /**
  14236. * Rebuild the particle system
  14237. */
  14238. rebuild(): void;
  14239. /** Force the system to rebuild all gradients that need to be resync */
  14240. forceRefreshGradients(): void;
  14241. /**
  14242. * Starts the particle system and begins to emit
  14243. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14244. */
  14245. start(delay?: number): void;
  14246. /**
  14247. * Stops the particle system.
  14248. */
  14249. stop(): void;
  14250. /**
  14251. * Remove all active particles
  14252. */
  14253. reset(): void;
  14254. /**
  14255. * Gets a boolean indicating that the system is stopping
  14256. * @returns true if the system is currently stopping
  14257. */
  14258. isStopping(): boolean;
  14259. /**
  14260. * Is this system ready to be used/rendered
  14261. * @return true if the system is ready
  14262. */
  14263. isReady(): boolean;
  14264. /**
  14265. * Returns the string "ParticleSystem"
  14266. * @returns a string containing the class name
  14267. */
  14268. getClassName(): string;
  14269. /**
  14270. * Gets the custom effect used to render the particles
  14271. * @param blendMode Blend mode for which the effect should be retrieved
  14272. * @returns The effect
  14273. */
  14274. getCustomEffect(blendMode: number): Nullable<Effect>;
  14275. /**
  14276. * Sets the custom effect used to render the particles
  14277. * @param effect The effect to set
  14278. * @param blendMode Blend mode for which the effect should be set
  14279. */
  14280. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14281. /**
  14282. * Fill the defines array according to the current settings of the particle system
  14283. * @param defines Array to be updated
  14284. * @param blendMode blend mode to take into account when updating the array
  14285. */
  14286. fillDefines(defines: Array<string>, blendMode: number): void;
  14287. /**
  14288. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14289. * @param uniforms Uniforms array to fill
  14290. * @param attributes Attributes array to fill
  14291. * @param samplers Samplers array to fill
  14292. */
  14293. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14294. /**
  14295. * Observable that will be called just before the particles are drawn
  14296. */
  14297. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14298. /**
  14299. * Gets the name of the particle vertex shader
  14300. */
  14301. vertexShaderName: string;
  14302. /**
  14303. * Adds a new color gradient
  14304. * @param gradient defines the gradient to use (between 0 and 1)
  14305. * @param color1 defines the color to affect to the specified gradient
  14306. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14307. * @returns the current particle system
  14308. */
  14309. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14310. /**
  14311. * Remove a specific color gradient
  14312. * @param gradient defines the gradient to remove
  14313. * @returns the current particle system
  14314. */
  14315. removeColorGradient(gradient: number): IParticleSystem;
  14316. /**
  14317. * Adds a new size gradient
  14318. * @param gradient defines the gradient to use (between 0 and 1)
  14319. * @param factor defines the size factor to affect to the specified gradient
  14320. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14321. * @returns the current particle system
  14322. */
  14323. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14324. /**
  14325. * Remove a specific size gradient
  14326. * @param gradient defines the gradient to remove
  14327. * @returns the current particle system
  14328. */
  14329. removeSizeGradient(gradient: number): IParticleSystem;
  14330. /**
  14331. * Gets the current list of color gradients.
  14332. * You must use addColorGradient and removeColorGradient to udpate this list
  14333. * @returns the list of color gradients
  14334. */
  14335. getColorGradients(): Nullable<Array<ColorGradient>>;
  14336. /**
  14337. * Gets the current list of size gradients.
  14338. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14339. * @returns the list of size gradients
  14340. */
  14341. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14342. /**
  14343. * Gets the current list of angular speed gradients.
  14344. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14345. * @returns the list of angular speed gradients
  14346. */
  14347. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14348. /**
  14349. * Adds a new angular speed gradient
  14350. * @param gradient defines the gradient to use (between 0 and 1)
  14351. * @param factor defines the angular speed to affect to the specified gradient
  14352. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14353. * @returns the current particle system
  14354. */
  14355. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14356. /**
  14357. * Remove a specific angular speed gradient
  14358. * @param gradient defines the gradient to remove
  14359. * @returns the current particle system
  14360. */
  14361. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14362. /**
  14363. * Gets the current list of velocity gradients.
  14364. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14365. * @returns the list of velocity gradients
  14366. */
  14367. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14368. /**
  14369. * Adds a new velocity gradient
  14370. * @param gradient defines the gradient to use (between 0 and 1)
  14371. * @param factor defines the velocity to affect to the specified gradient
  14372. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14373. * @returns the current particle system
  14374. */
  14375. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14376. /**
  14377. * Remove a specific velocity gradient
  14378. * @param gradient defines the gradient to remove
  14379. * @returns the current particle system
  14380. */
  14381. removeVelocityGradient(gradient: number): IParticleSystem;
  14382. /**
  14383. * Gets the current list of limit velocity gradients.
  14384. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14385. * @returns the list of limit velocity gradients
  14386. */
  14387. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14388. /**
  14389. * Adds a new limit velocity gradient
  14390. * @param gradient defines the gradient to use (between 0 and 1)
  14391. * @param factor defines the limit velocity to affect to the specified gradient
  14392. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14393. * @returns the current particle system
  14394. */
  14395. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14396. /**
  14397. * Remove a specific limit velocity gradient
  14398. * @param gradient defines the gradient to remove
  14399. * @returns the current particle system
  14400. */
  14401. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14402. /**
  14403. * Adds a new drag gradient
  14404. * @param gradient defines the gradient to use (between 0 and 1)
  14405. * @param factor defines the drag to affect to the specified gradient
  14406. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14407. * @returns the current particle system
  14408. */
  14409. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14410. /**
  14411. * Remove a specific drag gradient
  14412. * @param gradient defines the gradient to remove
  14413. * @returns the current particle system
  14414. */
  14415. removeDragGradient(gradient: number): IParticleSystem;
  14416. /**
  14417. * Gets the current list of drag gradients.
  14418. * You must use addDragGradient and removeDragGradient to udpate this list
  14419. * @returns the list of drag gradients
  14420. */
  14421. getDragGradients(): Nullable<Array<FactorGradient>>;
  14422. /**
  14423. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14424. * @param gradient defines the gradient to use (between 0 and 1)
  14425. * @param factor defines the emit rate to affect to the specified gradient
  14426. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14427. * @returns the current particle system
  14428. */
  14429. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14430. /**
  14431. * Remove a specific emit rate gradient
  14432. * @param gradient defines the gradient to remove
  14433. * @returns the current particle system
  14434. */
  14435. removeEmitRateGradient(gradient: number): IParticleSystem;
  14436. /**
  14437. * Gets the current list of emit rate gradients.
  14438. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14439. * @returns the list of emit rate gradients
  14440. */
  14441. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14442. /**
  14443. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14444. * @param gradient defines the gradient to use (between 0 and 1)
  14445. * @param factor defines the start size to affect to the specified gradient
  14446. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14447. * @returns the current particle system
  14448. */
  14449. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14450. /**
  14451. * Remove a specific start size gradient
  14452. * @param gradient defines the gradient to remove
  14453. * @returns the current particle system
  14454. */
  14455. removeStartSizeGradient(gradient: number): IParticleSystem;
  14456. /**
  14457. * Gets the current list of start size gradients.
  14458. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14459. * @returns the list of start size gradients
  14460. */
  14461. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14462. /**
  14463. * Adds a new life time gradient
  14464. * @param gradient defines the gradient to use (between 0 and 1)
  14465. * @param factor defines the life time factor to affect to the specified gradient
  14466. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14467. * @returns the current particle system
  14468. */
  14469. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14470. /**
  14471. * Remove a specific life time gradient
  14472. * @param gradient defines the gradient to remove
  14473. * @returns the current particle system
  14474. */
  14475. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14476. /**
  14477. * Gets the current list of life time gradients.
  14478. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14479. * @returns the list of life time gradients
  14480. */
  14481. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14482. /**
  14483. * Gets the current list of color gradients.
  14484. * You must use addColorGradient and removeColorGradient to udpate this list
  14485. * @returns the list of color gradients
  14486. */
  14487. getColorGradients(): Nullable<Array<ColorGradient>>;
  14488. /**
  14489. * Adds a new ramp gradient used to remap particle colors
  14490. * @param gradient defines the gradient to use (between 0 and 1)
  14491. * @param color defines the color to affect to the specified gradient
  14492. * @returns the current particle system
  14493. */
  14494. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14495. /**
  14496. * Gets the current list of ramp gradients.
  14497. * You must use addRampGradient and removeRampGradient to udpate this list
  14498. * @returns the list of ramp gradients
  14499. */
  14500. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14501. /** Gets or sets a boolean indicating that ramp gradients must be used
  14502. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14503. */
  14504. useRampGradients: boolean;
  14505. /**
  14506. * Adds a new color remap gradient
  14507. * @param gradient defines the gradient to use (between 0 and 1)
  14508. * @param min defines the color remap minimal range
  14509. * @param max defines the color remap maximal range
  14510. * @returns the current particle system
  14511. */
  14512. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14513. /**
  14514. * Gets the current list of color remap gradients.
  14515. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14516. * @returns the list of color remap gradients
  14517. */
  14518. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14519. /**
  14520. * Adds a new alpha remap gradient
  14521. * @param gradient defines the gradient to use (between 0 and 1)
  14522. * @param min defines the alpha remap minimal range
  14523. * @param max defines the alpha remap maximal range
  14524. * @returns the current particle system
  14525. */
  14526. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14527. /**
  14528. * Gets the current list of alpha remap gradients.
  14529. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14530. * @returns the list of alpha remap gradients
  14531. */
  14532. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14533. /**
  14534. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14535. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14536. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14537. * @returns the emitter
  14538. */
  14539. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14540. /**
  14541. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14542. * @param radius The radius of the hemisphere to emit from
  14543. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14544. * @returns the emitter
  14545. */
  14546. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14547. /**
  14548. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14549. * @param radius The radius of the sphere to emit from
  14550. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14551. * @returns the emitter
  14552. */
  14553. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14554. /**
  14555. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14556. * @param radius The radius of the sphere to emit from
  14557. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14558. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14559. * @returns the emitter
  14560. */
  14561. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14562. /**
  14563. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14564. * @param radius The radius of the emission cylinder
  14565. * @param height The height of the emission cylinder
  14566. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14567. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14568. * @returns the emitter
  14569. */
  14570. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14571. /**
  14572. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14573. * @param radius The radius of the cylinder to emit from
  14574. * @param height The height of the emission cylinder
  14575. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14576. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14577. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14578. * @returns the emitter
  14579. */
  14580. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14581. /**
  14582. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14583. * @param radius The radius of the cone to emit from
  14584. * @param angle The base angle of the cone
  14585. * @returns the emitter
  14586. */
  14587. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14588. /**
  14589. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14590. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14591. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14592. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14593. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14594. * @returns the emitter
  14595. */
  14596. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14597. /**
  14598. * Get hosting scene
  14599. * @returns the scene
  14600. */
  14601. getScene(): Nullable<Scene>;
  14602. }
  14603. }
  14604. declare module BABYLON {
  14605. /**
  14606. * 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.
  14607. * @see https://doc.babylonjs.com/how_to/transformnode
  14608. */
  14609. export class TransformNode extends Node {
  14610. /**
  14611. * Object will not rotate to face the camera
  14612. */
  14613. static BILLBOARDMODE_NONE: number;
  14614. /**
  14615. * Object will rotate to face the camera but only on the x axis
  14616. */
  14617. static BILLBOARDMODE_X: number;
  14618. /**
  14619. * Object will rotate to face the camera but only on the y axis
  14620. */
  14621. static BILLBOARDMODE_Y: number;
  14622. /**
  14623. * Object will rotate to face the camera but only on the z axis
  14624. */
  14625. static BILLBOARDMODE_Z: number;
  14626. /**
  14627. * Object will rotate to face the camera
  14628. */
  14629. static BILLBOARDMODE_ALL: number;
  14630. /**
  14631. * Object will rotate to face the camera's position instead of orientation
  14632. */
  14633. static BILLBOARDMODE_USE_POSITION: number;
  14634. private static _TmpRotation;
  14635. private static _TmpScaling;
  14636. private static _TmpTranslation;
  14637. private _forward;
  14638. private _forwardInverted;
  14639. private _up;
  14640. private _right;
  14641. private _rightInverted;
  14642. private _position;
  14643. private _rotation;
  14644. private _rotationQuaternion;
  14645. protected _scaling: Vector3;
  14646. protected _isDirty: boolean;
  14647. private _transformToBoneReferal;
  14648. private _isAbsoluteSynced;
  14649. private _billboardMode;
  14650. /**
  14651. * Gets or sets the billboard mode. Default is 0.
  14652. *
  14653. * | Value | Type | Description |
  14654. * | --- | --- | --- |
  14655. * | 0 | BILLBOARDMODE_NONE | |
  14656. * | 1 | BILLBOARDMODE_X | |
  14657. * | 2 | BILLBOARDMODE_Y | |
  14658. * | 4 | BILLBOARDMODE_Z | |
  14659. * | 7 | BILLBOARDMODE_ALL | |
  14660. *
  14661. */
  14662. get billboardMode(): number;
  14663. set billboardMode(value: number);
  14664. private _preserveParentRotationForBillboard;
  14665. /**
  14666. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14667. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14668. */
  14669. get preserveParentRotationForBillboard(): boolean;
  14670. set preserveParentRotationForBillboard(value: boolean);
  14671. /**
  14672. * 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
  14673. */
  14674. scalingDeterminant: number;
  14675. private _infiniteDistance;
  14676. /**
  14677. * Gets or sets the distance of the object to max, often used by skybox
  14678. */
  14679. get infiniteDistance(): boolean;
  14680. set infiniteDistance(value: boolean);
  14681. /**
  14682. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14683. * By default the system will update normals to compensate
  14684. */
  14685. ignoreNonUniformScaling: boolean;
  14686. /**
  14687. * 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
  14688. */
  14689. reIntegrateRotationIntoRotationQuaternion: boolean;
  14690. /** @hidden */
  14691. _poseMatrix: Nullable<Matrix>;
  14692. /** @hidden */
  14693. _localMatrix: Matrix;
  14694. private _usePivotMatrix;
  14695. private _absolutePosition;
  14696. private _absoluteScaling;
  14697. private _absoluteRotationQuaternion;
  14698. private _pivotMatrix;
  14699. private _pivotMatrixInverse;
  14700. protected _postMultiplyPivotMatrix: boolean;
  14701. protected _isWorldMatrixFrozen: boolean;
  14702. /** @hidden */
  14703. _indexInSceneTransformNodesArray: number;
  14704. /**
  14705. * An event triggered after the world matrix is updated
  14706. */
  14707. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14708. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14709. /**
  14710. * Gets a string identifying the name of the class
  14711. * @returns "TransformNode" string
  14712. */
  14713. getClassName(): string;
  14714. /**
  14715. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14716. */
  14717. get position(): Vector3;
  14718. set position(newPosition: Vector3);
  14719. /**
  14720. * 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)).
  14721. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14722. */
  14723. get rotation(): Vector3;
  14724. set rotation(newRotation: Vector3);
  14725. /**
  14726. * 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)).
  14727. */
  14728. get scaling(): Vector3;
  14729. set scaling(newScaling: Vector3);
  14730. /**
  14731. * 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).
  14732. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14733. */
  14734. get rotationQuaternion(): Nullable<Quaternion>;
  14735. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14736. /**
  14737. * The forward direction of that transform in world space.
  14738. */
  14739. get forward(): Vector3;
  14740. /**
  14741. * The up direction of that transform in world space.
  14742. */
  14743. get up(): Vector3;
  14744. /**
  14745. * The right direction of that transform in world space.
  14746. */
  14747. get right(): Vector3;
  14748. /**
  14749. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14750. * @param matrix the matrix to copy the pose from
  14751. * @returns this TransformNode.
  14752. */
  14753. updatePoseMatrix(matrix: Matrix): TransformNode;
  14754. /**
  14755. * Returns the mesh Pose matrix.
  14756. * @returns the pose matrix
  14757. */
  14758. getPoseMatrix(): Matrix;
  14759. /** @hidden */
  14760. _isSynchronized(): boolean;
  14761. /** @hidden */
  14762. _initCache(): void;
  14763. /**
  14764. * Flag the transform node as dirty (Forcing it to update everything)
  14765. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14766. * @returns this transform node
  14767. */
  14768. markAsDirty(property: string): TransformNode;
  14769. /**
  14770. * Returns the current mesh absolute position.
  14771. * Returns a Vector3.
  14772. */
  14773. get absolutePosition(): Vector3;
  14774. /**
  14775. * Returns the current mesh absolute scaling.
  14776. * Returns a Vector3.
  14777. */
  14778. get absoluteScaling(): Vector3;
  14779. /**
  14780. * Returns the current mesh absolute rotation.
  14781. * Returns a Quaternion.
  14782. */
  14783. get absoluteRotationQuaternion(): Quaternion;
  14784. /**
  14785. * Sets a new matrix to apply before all other transformation
  14786. * @param matrix defines the transform matrix
  14787. * @returns the current TransformNode
  14788. */
  14789. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14790. /**
  14791. * Sets a new pivot matrix to the current node
  14792. * @param matrix defines the new pivot matrix to use
  14793. * @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
  14794. * @returns the current TransformNode
  14795. */
  14796. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14797. /**
  14798. * Returns the mesh pivot matrix.
  14799. * Default : Identity.
  14800. * @returns the matrix
  14801. */
  14802. getPivotMatrix(): Matrix;
  14803. /**
  14804. * Instantiate (when possible) or clone that node with its hierarchy
  14805. * @param newParent defines the new parent to use for the instance (or clone)
  14806. * @param options defines options to configure how copy is done
  14807. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14808. * @returns an instance (or a clone) of the current node with its hiearchy
  14809. */
  14810. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14811. doNotInstantiate: boolean;
  14812. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14813. /**
  14814. * Prevents the World matrix to be computed any longer
  14815. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14816. * @returns the TransformNode.
  14817. */
  14818. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14819. /**
  14820. * Allows back the World matrix computation.
  14821. * @returns the TransformNode.
  14822. */
  14823. unfreezeWorldMatrix(): this;
  14824. /**
  14825. * True if the World matrix has been frozen.
  14826. */
  14827. get isWorldMatrixFrozen(): boolean;
  14828. /**
  14829. * Retuns the mesh absolute position in the World.
  14830. * @returns a Vector3.
  14831. */
  14832. getAbsolutePosition(): Vector3;
  14833. /**
  14834. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14835. * @param absolutePosition the absolute position to set
  14836. * @returns the TransformNode.
  14837. */
  14838. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14839. /**
  14840. * Sets the mesh position in its local space.
  14841. * @param vector3 the position to set in localspace
  14842. * @returns the TransformNode.
  14843. */
  14844. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14845. /**
  14846. * Returns the mesh position in the local space from the current World matrix values.
  14847. * @returns a new Vector3.
  14848. */
  14849. getPositionExpressedInLocalSpace(): Vector3;
  14850. /**
  14851. * Translates the mesh along the passed Vector3 in its local space.
  14852. * @param vector3 the distance to translate in localspace
  14853. * @returns the TransformNode.
  14854. */
  14855. locallyTranslate(vector3: Vector3): TransformNode;
  14856. private static _lookAtVectorCache;
  14857. /**
  14858. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14859. * @param targetPoint the position (must be in same space as current mesh) to look at
  14860. * @param yawCor optional yaw (y-axis) correction in radians
  14861. * @param pitchCor optional pitch (x-axis) correction in radians
  14862. * @param rollCor optional roll (z-axis) correction in radians
  14863. * @param space the choosen space of the target
  14864. * @returns the TransformNode.
  14865. */
  14866. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14867. /**
  14868. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14869. * This Vector3 is expressed in the World space.
  14870. * @param localAxis axis to rotate
  14871. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14872. */
  14873. getDirection(localAxis: Vector3): Vector3;
  14874. /**
  14875. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14876. * localAxis is expressed in the mesh local space.
  14877. * result is computed in the Wordl space from the mesh World matrix.
  14878. * @param localAxis axis to rotate
  14879. * @param result the resulting transformnode
  14880. * @returns this TransformNode.
  14881. */
  14882. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14883. /**
  14884. * Sets this transform node rotation to the given local axis.
  14885. * @param localAxis the axis in local space
  14886. * @param yawCor optional yaw (y-axis) correction in radians
  14887. * @param pitchCor optional pitch (x-axis) correction in radians
  14888. * @param rollCor optional roll (z-axis) correction in radians
  14889. * @returns this TransformNode
  14890. */
  14891. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14892. /**
  14893. * Sets a new pivot point to the current node
  14894. * @param point defines the new pivot point to use
  14895. * @param space defines if the point is in world or local space (local by default)
  14896. * @returns the current TransformNode
  14897. */
  14898. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14899. /**
  14900. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14901. * @returns the pivot point
  14902. */
  14903. getPivotPoint(): Vector3;
  14904. /**
  14905. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14906. * @param result the vector3 to store the result
  14907. * @returns this TransformNode.
  14908. */
  14909. getPivotPointToRef(result: Vector3): TransformNode;
  14910. /**
  14911. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14912. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14913. */
  14914. getAbsolutePivotPoint(): Vector3;
  14915. /**
  14916. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14917. * @param result vector3 to store the result
  14918. * @returns this TransformNode.
  14919. */
  14920. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14921. /**
  14922. * Defines the passed node as the parent of the current node.
  14923. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14924. * @see https://doc.babylonjs.com/how_to/parenting
  14925. * @param node the node ot set as the parent
  14926. * @returns this TransformNode.
  14927. */
  14928. setParent(node: Nullable<Node>): TransformNode;
  14929. private _nonUniformScaling;
  14930. /**
  14931. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14932. */
  14933. get nonUniformScaling(): boolean;
  14934. /** @hidden */
  14935. _updateNonUniformScalingState(value: boolean): boolean;
  14936. /**
  14937. * Attach the current TransformNode to another TransformNode associated with a bone
  14938. * @param bone Bone affecting the TransformNode
  14939. * @param affectedTransformNode TransformNode associated with the bone
  14940. * @returns this object
  14941. */
  14942. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14943. /**
  14944. * Detach the transform node if its associated with a bone
  14945. * @returns this object
  14946. */
  14947. detachFromBone(): TransformNode;
  14948. private static _rotationAxisCache;
  14949. /**
  14950. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14951. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14952. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14953. * The passed axis is also normalized.
  14954. * @param axis the axis to rotate around
  14955. * @param amount the amount to rotate in radians
  14956. * @param space Space to rotate in (Default: local)
  14957. * @returns the TransformNode.
  14958. */
  14959. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14960. /**
  14961. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14962. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14963. * The passed axis is also normalized. .
  14964. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14965. * @param point the point to rotate around
  14966. * @param axis the axis to rotate around
  14967. * @param amount the amount to rotate in radians
  14968. * @returns the TransformNode
  14969. */
  14970. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14971. /**
  14972. * Translates the mesh along the axis vector for the passed distance in the given space.
  14973. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14974. * @param axis the axis to translate in
  14975. * @param distance the distance to translate
  14976. * @param space Space to rotate in (Default: local)
  14977. * @returns the TransformNode.
  14978. */
  14979. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14980. /**
  14981. * Adds a rotation step to the mesh current rotation.
  14982. * x, y, z are Euler angles expressed in radians.
  14983. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14984. * This means this rotation is made in the mesh local space only.
  14985. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14986. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14987. * ```javascript
  14988. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14989. * ```
  14990. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14991. * 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.
  14992. * @param x Rotation to add
  14993. * @param y Rotation to add
  14994. * @param z Rotation to add
  14995. * @returns the TransformNode.
  14996. */
  14997. addRotation(x: number, y: number, z: number): TransformNode;
  14998. /**
  14999. * @hidden
  15000. */
  15001. protected _getEffectiveParent(): Nullable<Node>;
  15002. /**
  15003. * Computes the world matrix of the node
  15004. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15005. * @returns the world matrix
  15006. */
  15007. computeWorldMatrix(force?: boolean): Matrix;
  15008. /**
  15009. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15010. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15011. */
  15012. resetLocalMatrix(independentOfChildren?: boolean): void;
  15013. protected _afterComputeWorldMatrix(): void;
  15014. /**
  15015. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15016. * @param func callback function to add
  15017. *
  15018. * @returns the TransformNode.
  15019. */
  15020. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15021. /**
  15022. * Removes a registered callback function.
  15023. * @param func callback function to remove
  15024. * @returns the TransformNode.
  15025. */
  15026. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15027. /**
  15028. * Gets the position of the current mesh in camera space
  15029. * @param camera defines the camera to use
  15030. * @returns a position
  15031. */
  15032. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15033. /**
  15034. * Returns the distance from the mesh to the active camera
  15035. * @param camera defines the camera to use
  15036. * @returns the distance
  15037. */
  15038. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15039. /**
  15040. * Clone the current transform node
  15041. * @param name Name of the new clone
  15042. * @param newParent New parent for the clone
  15043. * @param doNotCloneChildren Do not clone children hierarchy
  15044. * @returns the new transform node
  15045. */
  15046. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15047. /**
  15048. * Serializes the objects information.
  15049. * @param currentSerializationObject defines the object to serialize in
  15050. * @returns the serialized object
  15051. */
  15052. serialize(currentSerializationObject?: any): any;
  15053. /**
  15054. * Returns a new TransformNode object parsed from the source provided.
  15055. * @param parsedTransformNode is the source.
  15056. * @param scene the scne the object belongs to
  15057. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15058. * @returns a new TransformNode object parsed from the source provided.
  15059. */
  15060. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15061. /**
  15062. * Get all child-transformNodes of this node
  15063. * @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
  15064. * @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
  15065. * @returns an array of TransformNode
  15066. */
  15067. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15068. /**
  15069. * Releases resources associated with this transform node.
  15070. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15071. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15072. */
  15073. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15074. /**
  15075. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15076. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15077. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15078. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15079. * @returns the current mesh
  15080. */
  15081. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15082. private _syncAbsoluteScalingAndRotation;
  15083. }
  15084. }
  15085. declare module BABYLON {
  15086. /**
  15087. * Class used to override all child animations of a given target
  15088. */
  15089. export class AnimationPropertiesOverride {
  15090. /**
  15091. * Gets or sets a value indicating if animation blending must be used
  15092. */
  15093. enableBlending: boolean;
  15094. /**
  15095. * Gets or sets the blending speed to use when enableBlending is true
  15096. */
  15097. blendingSpeed: number;
  15098. /**
  15099. * Gets or sets the default loop mode to use
  15100. */
  15101. loopMode: number;
  15102. }
  15103. }
  15104. declare module BABYLON {
  15105. /**
  15106. * Class used to store bone information
  15107. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15108. */
  15109. export class Bone extends Node {
  15110. /**
  15111. * defines the bone name
  15112. */
  15113. name: string;
  15114. private static _tmpVecs;
  15115. private static _tmpQuat;
  15116. private static _tmpMats;
  15117. /**
  15118. * Gets the list of child bones
  15119. */
  15120. children: Bone[];
  15121. /** Gets the animations associated with this bone */
  15122. animations: Animation[];
  15123. /**
  15124. * Gets or sets bone length
  15125. */
  15126. length: number;
  15127. /**
  15128. * @hidden Internal only
  15129. * Set this value to map this bone to a different index in the transform matrices
  15130. * Set this value to -1 to exclude the bone from the transform matrices
  15131. */
  15132. _index: Nullable<number>;
  15133. private _skeleton;
  15134. private _localMatrix;
  15135. private _restPose;
  15136. private _bindPose;
  15137. private _baseMatrix;
  15138. private _absoluteTransform;
  15139. private _invertedAbsoluteTransform;
  15140. private _parent;
  15141. private _scalingDeterminant;
  15142. private _worldTransform;
  15143. private _localScaling;
  15144. private _localRotation;
  15145. private _localPosition;
  15146. private _needToDecompose;
  15147. private _needToCompose;
  15148. /** @hidden */
  15149. _linkedTransformNode: Nullable<TransformNode>;
  15150. /** @hidden */
  15151. _waitingTransformNodeId: Nullable<string>;
  15152. /** @hidden */
  15153. get _matrix(): Matrix;
  15154. /** @hidden */
  15155. set _matrix(value: Matrix);
  15156. /**
  15157. * Create a new bone
  15158. * @param name defines the bone name
  15159. * @param skeleton defines the parent skeleton
  15160. * @param parentBone defines the parent (can be null if the bone is the root)
  15161. * @param localMatrix defines the local matrix
  15162. * @param restPose defines the rest pose matrix
  15163. * @param baseMatrix defines the base matrix
  15164. * @param index defines index of the bone in the hiearchy
  15165. */
  15166. constructor(
  15167. /**
  15168. * defines the bone name
  15169. */
  15170. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15171. /**
  15172. * Gets the current object class name.
  15173. * @return the class name
  15174. */
  15175. getClassName(): string;
  15176. /**
  15177. * Gets the parent skeleton
  15178. * @returns a skeleton
  15179. */
  15180. getSkeleton(): Skeleton;
  15181. /**
  15182. * Gets parent bone
  15183. * @returns a bone or null if the bone is the root of the bone hierarchy
  15184. */
  15185. getParent(): Nullable<Bone>;
  15186. /**
  15187. * Returns an array containing the root bones
  15188. * @returns an array containing the root bones
  15189. */
  15190. getChildren(): Array<Bone>;
  15191. /**
  15192. * Gets the node index in matrix array generated for rendering
  15193. * @returns the node index
  15194. */
  15195. getIndex(): number;
  15196. /**
  15197. * Sets the parent bone
  15198. * @param parent defines the parent (can be null if the bone is the root)
  15199. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15200. */
  15201. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15202. /**
  15203. * Gets the local matrix
  15204. * @returns a matrix
  15205. */
  15206. getLocalMatrix(): Matrix;
  15207. /**
  15208. * Gets the base matrix (initial matrix which remains unchanged)
  15209. * @returns a matrix
  15210. */
  15211. getBaseMatrix(): Matrix;
  15212. /**
  15213. * Gets the rest pose matrix
  15214. * @returns a matrix
  15215. */
  15216. getRestPose(): Matrix;
  15217. /**
  15218. * Sets the rest pose matrix
  15219. * @param matrix the local-space rest pose to set for this bone
  15220. */
  15221. setRestPose(matrix: Matrix): void;
  15222. /**
  15223. * Gets the bind pose matrix
  15224. * @returns the bind pose matrix
  15225. */
  15226. getBindPose(): Matrix;
  15227. /**
  15228. * Sets the bind pose matrix
  15229. * @param matrix the local-space bind pose to set for this bone
  15230. */
  15231. setBindPose(matrix: Matrix): void;
  15232. /**
  15233. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15234. */
  15235. getWorldMatrix(): Matrix;
  15236. /**
  15237. * Sets the local matrix to rest pose matrix
  15238. */
  15239. returnToRest(): void;
  15240. /**
  15241. * Gets the inverse of the absolute transform matrix.
  15242. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15243. * @returns a matrix
  15244. */
  15245. getInvertedAbsoluteTransform(): Matrix;
  15246. /**
  15247. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15248. * @returns a matrix
  15249. */
  15250. getAbsoluteTransform(): Matrix;
  15251. /**
  15252. * Links with the given transform node.
  15253. * The local matrix of this bone is copied from the transform node every frame.
  15254. * @param transformNode defines the transform node to link to
  15255. */
  15256. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15257. /**
  15258. * Gets the node used to drive the bone's transformation
  15259. * @returns a transform node or null
  15260. */
  15261. getTransformNode(): Nullable<TransformNode>;
  15262. /** Gets or sets current position (in local space) */
  15263. get position(): Vector3;
  15264. set position(newPosition: Vector3);
  15265. /** Gets or sets current rotation (in local space) */
  15266. get rotation(): Vector3;
  15267. set rotation(newRotation: Vector3);
  15268. /** Gets or sets current rotation quaternion (in local space) */
  15269. get rotationQuaternion(): Quaternion;
  15270. set rotationQuaternion(newRotation: Quaternion);
  15271. /** Gets or sets current scaling (in local space) */
  15272. get scaling(): Vector3;
  15273. set scaling(newScaling: Vector3);
  15274. /**
  15275. * Gets the animation properties override
  15276. */
  15277. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15278. private _decompose;
  15279. private _compose;
  15280. /**
  15281. * Update the base and local matrices
  15282. * @param matrix defines the new base or local matrix
  15283. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15284. * @param updateLocalMatrix defines if the local matrix should be updated
  15285. */
  15286. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15287. /** @hidden */
  15288. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15289. /**
  15290. * Flag the bone as dirty (Forcing it to update everything)
  15291. */
  15292. markAsDirty(): void;
  15293. /** @hidden */
  15294. _markAsDirtyAndCompose(): void;
  15295. private _markAsDirtyAndDecompose;
  15296. /**
  15297. * Translate the bone in local or world space
  15298. * @param vec The amount to translate the bone
  15299. * @param space The space that the translation is in
  15300. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15301. */
  15302. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15303. /**
  15304. * Set the postion of the bone in local or world space
  15305. * @param position The position to set the bone
  15306. * @param space The space that the position is in
  15307. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15308. */
  15309. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15310. /**
  15311. * Set the absolute position of the bone (world space)
  15312. * @param position The position to set the bone
  15313. * @param mesh The mesh that this bone is attached to
  15314. */
  15315. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15316. /**
  15317. * Scale the bone on the x, y and z axes (in local space)
  15318. * @param x The amount to scale the bone on the x axis
  15319. * @param y The amount to scale the bone on the y axis
  15320. * @param z The amount to scale the bone on the z axis
  15321. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15322. */
  15323. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15324. /**
  15325. * Set the bone scaling in local space
  15326. * @param scale defines the scaling vector
  15327. */
  15328. setScale(scale: Vector3): void;
  15329. /**
  15330. * Gets the current scaling in local space
  15331. * @returns the current scaling vector
  15332. */
  15333. getScale(): Vector3;
  15334. /**
  15335. * Gets the current scaling in local space and stores it in a target vector
  15336. * @param result defines the target vector
  15337. */
  15338. getScaleToRef(result: Vector3): void;
  15339. /**
  15340. * Set the yaw, pitch, and roll of the bone in local or world space
  15341. * @param yaw The rotation of the bone on the y axis
  15342. * @param pitch The rotation of the bone on the x axis
  15343. * @param roll The rotation of the bone on the z axis
  15344. * @param space The space that the axes of rotation are in
  15345. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15346. */
  15347. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15348. /**
  15349. * Add a rotation to the bone on an axis in local or world space
  15350. * @param axis The axis to rotate the bone on
  15351. * @param amount The amount to rotate the bone
  15352. * @param space The space that the axis is in
  15353. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15354. */
  15355. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15356. /**
  15357. * Set the rotation of the bone to a particular axis angle in local or world space
  15358. * @param axis The axis to rotate the bone on
  15359. * @param angle The angle that the bone should be rotated to
  15360. * @param space The space that the axis is in
  15361. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15362. */
  15363. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15364. /**
  15365. * Set the euler rotation of the bone in local of world space
  15366. * @param rotation The euler rotation that the bone should be set to
  15367. * @param space The space that the rotation is in
  15368. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15369. */
  15370. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15371. /**
  15372. * Set the quaternion rotation of the bone in local of world space
  15373. * @param quat The quaternion rotation that the bone should be set to
  15374. * @param space The space that the rotation is in
  15375. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15376. */
  15377. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15378. /**
  15379. * Set the rotation matrix of the bone in local of world space
  15380. * @param rotMat The rotation matrix that the bone should be set to
  15381. * @param space The space that the rotation is in
  15382. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15383. */
  15384. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15385. private _rotateWithMatrix;
  15386. private _getNegativeRotationToRef;
  15387. /**
  15388. * Get the position of the bone in local or world space
  15389. * @param space The space that the returned position is in
  15390. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15391. * @returns The position of the bone
  15392. */
  15393. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15394. /**
  15395. * Copy the position of the bone to a vector3 in local or world space
  15396. * @param space The space that the returned position is in
  15397. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15398. * @param result The vector3 to copy the position to
  15399. */
  15400. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15401. /**
  15402. * Get the absolute position of the bone (world space)
  15403. * @param mesh The mesh that this bone is attached to
  15404. * @returns The absolute position of the bone
  15405. */
  15406. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15407. /**
  15408. * Copy the absolute position of the bone (world space) to the result param
  15409. * @param mesh The mesh that this bone is attached to
  15410. * @param result The vector3 to copy the absolute position to
  15411. */
  15412. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15413. /**
  15414. * Compute the absolute transforms of this bone and its children
  15415. */
  15416. computeAbsoluteTransforms(): void;
  15417. /**
  15418. * Get the world direction from an axis that is in the local space of the bone
  15419. * @param localAxis The local direction that is used to compute the world direction
  15420. * @param mesh The mesh that this bone is attached to
  15421. * @returns The world direction
  15422. */
  15423. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15424. /**
  15425. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15426. * @param localAxis The local direction that is used to compute the world direction
  15427. * @param mesh The mesh that this bone is attached to
  15428. * @param result The vector3 that the world direction will be copied to
  15429. */
  15430. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15431. /**
  15432. * Get the euler rotation of the bone in local or world space
  15433. * @param space The space that the rotation should be in
  15434. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15435. * @returns The euler rotation
  15436. */
  15437. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15438. /**
  15439. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15440. * @param space The space that the rotation should be in
  15441. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15442. * @param result The vector3 that the rotation should be copied to
  15443. */
  15444. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15445. /**
  15446. * Get the quaternion rotation of the bone in either local or world space
  15447. * @param space The space that the rotation should be in
  15448. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15449. * @returns The quaternion rotation
  15450. */
  15451. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15452. /**
  15453. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15454. * @param space The space that the rotation should be in
  15455. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15456. * @param result The quaternion that the rotation should be copied to
  15457. */
  15458. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15459. /**
  15460. * Get the rotation matrix of the bone in local or world space
  15461. * @param space The space that the rotation should be in
  15462. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15463. * @returns The rotation matrix
  15464. */
  15465. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15466. /**
  15467. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15468. * @param space The space that the rotation should be in
  15469. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15470. * @param result The quaternion that the rotation should be copied to
  15471. */
  15472. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15473. /**
  15474. * Get the world position of a point that is in the local space of the bone
  15475. * @param position The local position
  15476. * @param mesh The mesh that this bone is attached to
  15477. * @returns The world position
  15478. */
  15479. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15480. /**
  15481. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15482. * @param position The local position
  15483. * @param mesh The mesh that this bone is attached to
  15484. * @param result The vector3 that the world position should be copied to
  15485. */
  15486. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15487. /**
  15488. * Get the local position of a point that is in world space
  15489. * @param position The world position
  15490. * @param mesh The mesh that this bone is attached to
  15491. * @returns The local position
  15492. */
  15493. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15494. /**
  15495. * Get the local position of a point that is in world space and copy it to the result param
  15496. * @param position The world position
  15497. * @param mesh The mesh that this bone is attached to
  15498. * @param result The vector3 that the local position should be copied to
  15499. */
  15500. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15501. }
  15502. }
  15503. declare module BABYLON {
  15504. /**
  15505. * Defines a runtime animation
  15506. */
  15507. export class RuntimeAnimation {
  15508. private _events;
  15509. /**
  15510. * The current frame of the runtime animation
  15511. */
  15512. private _currentFrame;
  15513. /**
  15514. * The animation used by the runtime animation
  15515. */
  15516. private _animation;
  15517. /**
  15518. * The target of the runtime animation
  15519. */
  15520. private _target;
  15521. /**
  15522. * The initiating animatable
  15523. */
  15524. private _host;
  15525. /**
  15526. * The original value of the runtime animation
  15527. */
  15528. private _originalValue;
  15529. /**
  15530. * The original blend value of the runtime animation
  15531. */
  15532. private _originalBlendValue;
  15533. /**
  15534. * The offsets cache of the runtime animation
  15535. */
  15536. private _offsetsCache;
  15537. /**
  15538. * The high limits cache of the runtime animation
  15539. */
  15540. private _highLimitsCache;
  15541. /**
  15542. * Specifies if the runtime animation has been stopped
  15543. */
  15544. private _stopped;
  15545. /**
  15546. * The blending factor of the runtime animation
  15547. */
  15548. private _blendingFactor;
  15549. /**
  15550. * The BabylonJS scene
  15551. */
  15552. private _scene;
  15553. /**
  15554. * The current value of the runtime animation
  15555. */
  15556. private _currentValue;
  15557. /** @hidden */
  15558. _animationState: _IAnimationState;
  15559. /**
  15560. * The active target of the runtime animation
  15561. */
  15562. private _activeTargets;
  15563. private _currentActiveTarget;
  15564. private _directTarget;
  15565. /**
  15566. * The target path of the runtime animation
  15567. */
  15568. private _targetPath;
  15569. /**
  15570. * The weight of the runtime animation
  15571. */
  15572. private _weight;
  15573. /**
  15574. * The ratio offset of the runtime animation
  15575. */
  15576. private _ratioOffset;
  15577. /**
  15578. * The previous delay of the runtime animation
  15579. */
  15580. private _previousDelay;
  15581. /**
  15582. * The previous ratio of the runtime animation
  15583. */
  15584. private _previousRatio;
  15585. private _enableBlending;
  15586. private _keys;
  15587. private _minFrame;
  15588. private _maxFrame;
  15589. private _minValue;
  15590. private _maxValue;
  15591. private _targetIsArray;
  15592. /**
  15593. * Gets the current frame of the runtime animation
  15594. */
  15595. get currentFrame(): number;
  15596. /**
  15597. * Gets the weight of the runtime animation
  15598. */
  15599. get weight(): number;
  15600. /**
  15601. * Gets the current value of the runtime animation
  15602. */
  15603. get currentValue(): any;
  15604. /**
  15605. * Gets the target path of the runtime animation
  15606. */
  15607. get targetPath(): string;
  15608. /**
  15609. * Gets the actual target of the runtime animation
  15610. */
  15611. get target(): any;
  15612. /**
  15613. * Gets the additive state of the runtime animation
  15614. */
  15615. get isAdditive(): boolean;
  15616. /** @hidden */
  15617. _onLoop: () => void;
  15618. /**
  15619. * Create a new RuntimeAnimation object
  15620. * @param target defines the target of the animation
  15621. * @param animation defines the source animation object
  15622. * @param scene defines the hosting scene
  15623. * @param host defines the initiating Animatable
  15624. */
  15625. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15626. private _preparePath;
  15627. /**
  15628. * Gets the animation from the runtime animation
  15629. */
  15630. get animation(): Animation;
  15631. /**
  15632. * Resets the runtime animation to the beginning
  15633. * @param restoreOriginal defines whether to restore the target property to the original value
  15634. */
  15635. reset(restoreOriginal?: boolean): void;
  15636. /**
  15637. * Specifies if the runtime animation is stopped
  15638. * @returns Boolean specifying if the runtime animation is stopped
  15639. */
  15640. isStopped(): boolean;
  15641. /**
  15642. * Disposes of the runtime animation
  15643. */
  15644. dispose(): void;
  15645. /**
  15646. * Apply the interpolated value to the target
  15647. * @param currentValue defines the value computed by the animation
  15648. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15649. */
  15650. setValue(currentValue: any, weight: number): void;
  15651. private _getOriginalValues;
  15652. private _setValue;
  15653. /**
  15654. * Gets the loop pmode of the runtime animation
  15655. * @returns Loop Mode
  15656. */
  15657. private _getCorrectLoopMode;
  15658. /**
  15659. * Move the current animation to a given frame
  15660. * @param frame defines the frame to move to
  15661. */
  15662. goToFrame(frame: number): void;
  15663. /**
  15664. * @hidden Internal use only
  15665. */
  15666. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15667. /**
  15668. * Execute the current animation
  15669. * @param delay defines the delay to add to the current frame
  15670. * @param from defines the lower bound of the animation range
  15671. * @param to defines the upper bound of the animation range
  15672. * @param loop defines if the current animation must loop
  15673. * @param speedRatio defines the current speed ratio
  15674. * @param weight defines the weight of the animation (default is -1 so no weight)
  15675. * @param onLoop optional callback called when animation loops
  15676. * @returns a boolean indicating if the animation is running
  15677. */
  15678. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15679. }
  15680. }
  15681. declare module BABYLON {
  15682. /**
  15683. * Class used to store an actual running animation
  15684. */
  15685. export class Animatable {
  15686. /** defines the target object */
  15687. target: any;
  15688. /** defines the starting frame number (default is 0) */
  15689. fromFrame: number;
  15690. /** defines the ending frame number (default is 100) */
  15691. toFrame: number;
  15692. /** defines if the animation must loop (default is false) */
  15693. loopAnimation: boolean;
  15694. /** defines a callback to call when animation ends if it is not looping */
  15695. onAnimationEnd?: (() => void) | null | undefined;
  15696. /** defines a callback to call when animation loops */
  15697. onAnimationLoop?: (() => void) | null | undefined;
  15698. /** defines whether the animation should be evaluated additively */
  15699. isAdditive: boolean;
  15700. private _localDelayOffset;
  15701. private _pausedDelay;
  15702. private _runtimeAnimations;
  15703. private _paused;
  15704. private _scene;
  15705. private _speedRatio;
  15706. private _weight;
  15707. private _syncRoot;
  15708. /**
  15709. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15710. * This will only apply for non looping animation (default is true)
  15711. */
  15712. disposeOnEnd: boolean;
  15713. /**
  15714. * Gets a boolean indicating if the animation has started
  15715. */
  15716. animationStarted: boolean;
  15717. /**
  15718. * Observer raised when the animation ends
  15719. */
  15720. onAnimationEndObservable: Observable<Animatable>;
  15721. /**
  15722. * Observer raised when the animation loops
  15723. */
  15724. onAnimationLoopObservable: Observable<Animatable>;
  15725. /**
  15726. * Gets the root Animatable used to synchronize and normalize animations
  15727. */
  15728. get syncRoot(): Nullable<Animatable>;
  15729. /**
  15730. * Gets the current frame of the first RuntimeAnimation
  15731. * Used to synchronize Animatables
  15732. */
  15733. get masterFrame(): number;
  15734. /**
  15735. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15736. */
  15737. get weight(): number;
  15738. set weight(value: number);
  15739. /**
  15740. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15741. */
  15742. get speedRatio(): number;
  15743. set speedRatio(value: number);
  15744. /**
  15745. * Creates a new Animatable
  15746. * @param scene defines the hosting scene
  15747. * @param target defines the target object
  15748. * @param fromFrame defines the starting frame number (default is 0)
  15749. * @param toFrame defines the ending frame number (default is 100)
  15750. * @param loopAnimation defines if the animation must loop (default is false)
  15751. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15752. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15753. * @param animations defines a group of animation to add to the new Animatable
  15754. * @param onAnimationLoop defines a callback to call when animation loops
  15755. * @param isAdditive defines whether the animation should be evaluated additively
  15756. */
  15757. constructor(scene: Scene,
  15758. /** defines the target object */
  15759. target: any,
  15760. /** defines the starting frame number (default is 0) */
  15761. fromFrame?: number,
  15762. /** defines the ending frame number (default is 100) */
  15763. toFrame?: number,
  15764. /** defines if the animation must loop (default is false) */
  15765. loopAnimation?: boolean, speedRatio?: number,
  15766. /** defines a callback to call when animation ends if it is not looping */
  15767. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15768. /** defines a callback to call when animation loops */
  15769. onAnimationLoop?: (() => void) | null | undefined,
  15770. /** defines whether the animation should be evaluated additively */
  15771. isAdditive?: boolean);
  15772. /**
  15773. * Synchronize and normalize current Animatable with a source Animatable
  15774. * This is useful when using animation weights and when animations are not of the same length
  15775. * @param root defines the root Animatable to synchronize with
  15776. * @returns the current Animatable
  15777. */
  15778. syncWith(root: Animatable): Animatable;
  15779. /**
  15780. * Gets the list of runtime animations
  15781. * @returns an array of RuntimeAnimation
  15782. */
  15783. getAnimations(): RuntimeAnimation[];
  15784. /**
  15785. * Adds more animations to the current animatable
  15786. * @param target defines the target of the animations
  15787. * @param animations defines the new animations to add
  15788. */
  15789. appendAnimations(target: any, animations: Animation[]): void;
  15790. /**
  15791. * Gets the source animation for a specific property
  15792. * @param property defines the propertyu to look for
  15793. * @returns null or the source animation for the given property
  15794. */
  15795. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15796. /**
  15797. * Gets the runtime animation for a specific property
  15798. * @param property defines the propertyu to look for
  15799. * @returns null or the runtime animation for the given property
  15800. */
  15801. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15802. /**
  15803. * Resets the animatable to its original state
  15804. */
  15805. reset(): void;
  15806. /**
  15807. * Allows the animatable to blend with current running animations
  15808. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15809. * @param blendingSpeed defines the blending speed to use
  15810. */
  15811. enableBlending(blendingSpeed: number): void;
  15812. /**
  15813. * Disable animation blending
  15814. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15815. */
  15816. disableBlending(): void;
  15817. /**
  15818. * Jump directly to a given frame
  15819. * @param frame defines the frame to jump to
  15820. */
  15821. goToFrame(frame: number): void;
  15822. /**
  15823. * Pause the animation
  15824. */
  15825. pause(): void;
  15826. /**
  15827. * Restart the animation
  15828. */
  15829. restart(): void;
  15830. private _raiseOnAnimationEnd;
  15831. /**
  15832. * Stop and delete the current animation
  15833. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15834. * @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)
  15835. */
  15836. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15837. /**
  15838. * Wait asynchronously for the animation to end
  15839. * @returns a promise which will be fullfilled when the animation ends
  15840. */
  15841. waitAsync(): Promise<Animatable>;
  15842. /** @hidden */
  15843. _animate(delay: number): boolean;
  15844. }
  15845. interface Scene {
  15846. /** @hidden */
  15847. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15848. /** @hidden */
  15849. _processLateAnimationBindingsForMatrices(holder: {
  15850. totalWeight: number;
  15851. totalAdditiveWeight: number;
  15852. animations: RuntimeAnimation[];
  15853. additiveAnimations: RuntimeAnimation[];
  15854. originalValue: Matrix;
  15855. }): any;
  15856. /** @hidden */
  15857. _processLateAnimationBindingsForQuaternions(holder: {
  15858. totalWeight: number;
  15859. totalAdditiveWeight: number;
  15860. animations: RuntimeAnimation[];
  15861. additiveAnimations: RuntimeAnimation[];
  15862. originalValue: Quaternion;
  15863. }, refQuaternion: Quaternion): Quaternion;
  15864. /** @hidden */
  15865. _processLateAnimationBindings(): void;
  15866. /**
  15867. * Will start the animation sequence of a given target
  15868. * @param target defines the target
  15869. * @param from defines from which frame should animation start
  15870. * @param to defines until which frame should animation run.
  15871. * @param weight defines the weight to apply to the animation (1.0 by default)
  15872. * @param loop defines if the animation loops
  15873. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15874. * @param onAnimationEnd defines the function to be executed when the animation ends
  15875. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15876. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15877. * @param onAnimationLoop defines the callback to call when an animation loops
  15878. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15879. * @returns the animatable object created for this animation
  15880. */
  15881. 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;
  15882. /**
  15883. * Will start the animation sequence of a given target
  15884. * @param target defines the target
  15885. * @param from defines from which frame should animation start
  15886. * @param to defines until which frame should animation run.
  15887. * @param loop defines if the animation loops
  15888. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15889. * @param onAnimationEnd defines the function to be executed when the animation ends
  15890. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15891. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15892. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15893. * @param onAnimationLoop defines the callback to call when an animation loops
  15894. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15895. * @returns the animatable object created for this animation
  15896. */
  15897. 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;
  15898. /**
  15899. * Will start the animation sequence of a given target and its hierarchy
  15900. * @param target defines the target
  15901. * @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.
  15902. * @param from defines from which frame should animation start
  15903. * @param to defines until which frame should animation run.
  15904. * @param loop defines if the animation loops
  15905. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15906. * @param onAnimationEnd defines the function to be executed when the animation ends
  15907. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15908. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15909. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15910. * @param onAnimationLoop defines the callback to call when an animation loops
  15911. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15912. * @returns the list of created animatables
  15913. */
  15914. 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[];
  15915. /**
  15916. * Begin a new animation on a given node
  15917. * @param target defines the target where the animation will take place
  15918. * @param animations defines the list of animations to start
  15919. * @param from defines the initial value
  15920. * @param to defines the final value
  15921. * @param loop defines if you want animation to loop (off by default)
  15922. * @param speedRatio defines the speed ratio to apply to all animations
  15923. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15924. * @param onAnimationLoop defines the callback to call when an animation loops
  15925. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15926. * @returns the list of created animatables
  15927. */
  15928. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15929. /**
  15930. * Begin a new animation on a given node and its hierarchy
  15931. * @param target defines the root node where the animation will take place
  15932. * @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.
  15933. * @param animations defines the list of animations to start
  15934. * @param from defines the initial value
  15935. * @param to defines the final value
  15936. * @param loop defines if you want animation to loop (off by default)
  15937. * @param speedRatio defines the speed ratio to apply to all animations
  15938. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15939. * @param onAnimationLoop defines the callback to call when an animation loops
  15940. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15941. * @returns the list of animatables created for all nodes
  15942. */
  15943. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15944. /**
  15945. * Gets the animatable associated with a specific target
  15946. * @param target defines the target of the animatable
  15947. * @returns the required animatable if found
  15948. */
  15949. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15950. /**
  15951. * Gets all animatables associated with a given target
  15952. * @param target defines the target to look animatables for
  15953. * @returns an array of Animatables
  15954. */
  15955. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15956. /**
  15957. * Stops and removes all animations that have been applied to the scene
  15958. */
  15959. stopAllAnimations(): void;
  15960. /**
  15961. * Gets the current delta time used by animation engine
  15962. */
  15963. deltaTime: number;
  15964. }
  15965. interface Bone {
  15966. /**
  15967. * Copy an animation range from another bone
  15968. * @param source defines the source bone
  15969. * @param rangeName defines the range name to copy
  15970. * @param frameOffset defines the frame offset
  15971. * @param rescaleAsRequired defines if rescaling must be applied if required
  15972. * @param skelDimensionsRatio defines the scaling ratio
  15973. * @returns true if operation was successful
  15974. */
  15975. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15976. }
  15977. }
  15978. declare module BABYLON {
  15979. /**
  15980. * Class used to handle skinning animations
  15981. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15982. */
  15983. export class Skeleton implements IAnimatable {
  15984. /** defines the skeleton name */
  15985. name: string;
  15986. /** defines the skeleton Id */
  15987. id: string;
  15988. /**
  15989. * Defines the list of child bones
  15990. */
  15991. bones: Bone[];
  15992. /**
  15993. * Defines an estimate of the dimension of the skeleton at rest
  15994. */
  15995. dimensionsAtRest: Vector3;
  15996. /**
  15997. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15998. */
  15999. needInitialSkinMatrix: boolean;
  16000. /**
  16001. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16002. */
  16003. overrideMesh: Nullable<AbstractMesh>;
  16004. /**
  16005. * Gets the list of animations attached to this skeleton
  16006. */
  16007. animations: Array<Animation>;
  16008. private _scene;
  16009. private _isDirty;
  16010. private _transformMatrices;
  16011. private _transformMatrixTexture;
  16012. private _meshesWithPoseMatrix;
  16013. private _animatables;
  16014. private _identity;
  16015. private _synchronizedWithMesh;
  16016. private _ranges;
  16017. private _lastAbsoluteTransformsUpdateId;
  16018. private _canUseTextureForBones;
  16019. private _uniqueId;
  16020. /** @hidden */
  16021. _numBonesWithLinkedTransformNode: number;
  16022. /** @hidden */
  16023. _hasWaitingData: Nullable<boolean>;
  16024. /**
  16025. * Specifies if the skeleton should be serialized
  16026. */
  16027. doNotSerialize: boolean;
  16028. private _useTextureToStoreBoneMatrices;
  16029. /**
  16030. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16031. * Please note that this option is not available if the hardware does not support it
  16032. */
  16033. get useTextureToStoreBoneMatrices(): boolean;
  16034. set useTextureToStoreBoneMatrices(value: boolean);
  16035. private _animationPropertiesOverride;
  16036. /**
  16037. * Gets or sets the animation properties override
  16038. */
  16039. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16040. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16041. /**
  16042. * List of inspectable custom properties (used by the Inspector)
  16043. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16044. */
  16045. inspectableCustomProperties: IInspectable[];
  16046. /**
  16047. * An observable triggered before computing the skeleton's matrices
  16048. */
  16049. onBeforeComputeObservable: Observable<Skeleton>;
  16050. /**
  16051. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16052. */
  16053. get isUsingTextureForMatrices(): boolean;
  16054. /**
  16055. * Gets the unique ID of this skeleton
  16056. */
  16057. get uniqueId(): number;
  16058. /**
  16059. * Creates a new skeleton
  16060. * @param name defines the skeleton name
  16061. * @param id defines the skeleton Id
  16062. * @param scene defines the hosting scene
  16063. */
  16064. constructor(
  16065. /** defines the skeleton name */
  16066. name: string,
  16067. /** defines the skeleton Id */
  16068. id: string, scene: Scene);
  16069. /**
  16070. * Gets the current object class name.
  16071. * @return the class name
  16072. */
  16073. getClassName(): string;
  16074. /**
  16075. * Returns an array containing the root bones
  16076. * @returns an array containing the root bones
  16077. */
  16078. getChildren(): Array<Bone>;
  16079. /**
  16080. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16081. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16082. * @returns a Float32Array containing matrices data
  16083. */
  16084. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16085. /**
  16086. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16087. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16088. * @returns a raw texture containing the data
  16089. */
  16090. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16091. /**
  16092. * Gets the current hosting scene
  16093. * @returns a scene object
  16094. */
  16095. getScene(): Scene;
  16096. /**
  16097. * Gets a string representing the current skeleton data
  16098. * @param fullDetails defines a boolean indicating if we want a verbose version
  16099. * @returns a string representing the current skeleton data
  16100. */
  16101. toString(fullDetails?: boolean): string;
  16102. /**
  16103. * Get bone's index searching by name
  16104. * @param name defines bone's name to search for
  16105. * @return the indice of the bone. Returns -1 if not found
  16106. */
  16107. getBoneIndexByName(name: string): number;
  16108. /**
  16109. * Creater a new animation range
  16110. * @param name defines the name of the range
  16111. * @param from defines the start key
  16112. * @param to defines the end key
  16113. */
  16114. createAnimationRange(name: string, from: number, to: number): void;
  16115. /**
  16116. * Delete a specific animation range
  16117. * @param name defines the name of the range
  16118. * @param deleteFrames defines if frames must be removed as well
  16119. */
  16120. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16121. /**
  16122. * Gets a specific animation range
  16123. * @param name defines the name of the range to look for
  16124. * @returns the requested animation range or null if not found
  16125. */
  16126. getAnimationRange(name: string): Nullable<AnimationRange>;
  16127. /**
  16128. * Gets the list of all animation ranges defined on this skeleton
  16129. * @returns an array
  16130. */
  16131. getAnimationRanges(): Nullable<AnimationRange>[];
  16132. /**
  16133. * Copy animation range from a source skeleton.
  16134. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16135. * @param source defines the source skeleton
  16136. * @param name defines the name of the range to copy
  16137. * @param rescaleAsRequired defines if rescaling must be applied if required
  16138. * @returns true if operation was successful
  16139. */
  16140. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16141. /**
  16142. * Forces the skeleton to go to rest pose
  16143. */
  16144. returnToRest(): void;
  16145. private _getHighestAnimationFrame;
  16146. /**
  16147. * Begin a specific animation range
  16148. * @param name defines the name of the range to start
  16149. * @param loop defines if looping must be turned on (false by default)
  16150. * @param speedRatio defines the speed ratio to apply (1 by default)
  16151. * @param onAnimationEnd defines a callback which will be called when animation will end
  16152. * @returns a new animatable
  16153. */
  16154. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16155. /**
  16156. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16157. * @param skeleton defines the Skeleton containing the animation range to convert
  16158. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16159. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16160. * @returns the original skeleton
  16161. */
  16162. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16163. /** @hidden */
  16164. _markAsDirty(): void;
  16165. /** @hidden */
  16166. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16167. /** @hidden */
  16168. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16169. private _computeTransformMatrices;
  16170. /**
  16171. * Build all resources required to render a skeleton
  16172. */
  16173. prepare(): void;
  16174. /**
  16175. * Gets the list of animatables currently running for this skeleton
  16176. * @returns an array of animatables
  16177. */
  16178. getAnimatables(): IAnimatable[];
  16179. /**
  16180. * Clone the current skeleton
  16181. * @param name defines the name of the new skeleton
  16182. * @param id defines the id of the new skeleton
  16183. * @returns the new skeleton
  16184. */
  16185. clone(name: string, id?: string): Skeleton;
  16186. /**
  16187. * Enable animation blending for this skeleton
  16188. * @param blendingSpeed defines the blending speed to apply
  16189. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16190. */
  16191. enableBlending(blendingSpeed?: number): void;
  16192. /**
  16193. * Releases all resources associated with the current skeleton
  16194. */
  16195. dispose(): void;
  16196. /**
  16197. * Serialize the skeleton in a JSON object
  16198. * @returns a JSON object
  16199. */
  16200. serialize(): any;
  16201. /**
  16202. * Creates a new skeleton from serialized data
  16203. * @param parsedSkeleton defines the serialized data
  16204. * @param scene defines the hosting scene
  16205. * @returns a new skeleton
  16206. */
  16207. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16208. /**
  16209. * Compute all node absolute transforms
  16210. * @param forceUpdate defines if computation must be done even if cache is up to date
  16211. */
  16212. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16213. /**
  16214. * Gets the root pose matrix
  16215. * @returns a matrix
  16216. */
  16217. getPoseMatrix(): Nullable<Matrix>;
  16218. /**
  16219. * Sorts bones per internal index
  16220. */
  16221. sortBones(): void;
  16222. private _sortBones;
  16223. }
  16224. }
  16225. declare module BABYLON {
  16226. /**
  16227. * Creates an instance based on a source mesh.
  16228. */
  16229. export class InstancedMesh extends AbstractMesh {
  16230. private _sourceMesh;
  16231. private _currentLOD;
  16232. /** @hidden */
  16233. _indexInSourceMeshInstanceArray: number;
  16234. constructor(name: string, source: Mesh);
  16235. /**
  16236. * Returns the string "InstancedMesh".
  16237. */
  16238. getClassName(): string;
  16239. /** Gets the list of lights affecting that mesh */
  16240. get lightSources(): Light[];
  16241. _resyncLightSources(): void;
  16242. _resyncLightSource(light: Light): void;
  16243. _removeLightSource(light: Light, dispose: boolean): void;
  16244. /**
  16245. * If the source mesh receives shadows
  16246. */
  16247. get receiveShadows(): boolean;
  16248. /**
  16249. * The material of the source mesh
  16250. */
  16251. get material(): Nullable<Material>;
  16252. /**
  16253. * Visibility of the source mesh
  16254. */
  16255. get visibility(): number;
  16256. /**
  16257. * Skeleton of the source mesh
  16258. */
  16259. get skeleton(): Nullable<Skeleton>;
  16260. /**
  16261. * Rendering ground id of the source mesh
  16262. */
  16263. get renderingGroupId(): number;
  16264. set renderingGroupId(value: number);
  16265. /**
  16266. * Returns the total number of vertices (integer).
  16267. */
  16268. getTotalVertices(): number;
  16269. /**
  16270. * Returns a positive integer : the total number of indices in this mesh geometry.
  16271. * @returns the numner of indices or zero if the mesh has no geometry.
  16272. */
  16273. getTotalIndices(): number;
  16274. /**
  16275. * The source mesh of the instance
  16276. */
  16277. get sourceMesh(): Mesh;
  16278. /**
  16279. * Creates a new InstancedMesh object from the mesh model.
  16280. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16281. * @param name defines the name of the new instance
  16282. * @returns a new InstancedMesh
  16283. */
  16284. createInstance(name: string): InstancedMesh;
  16285. /**
  16286. * Is this node ready to be used/rendered
  16287. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16288. * @return {boolean} is it ready
  16289. */
  16290. isReady(completeCheck?: boolean): boolean;
  16291. /**
  16292. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16293. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16294. * @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.
  16295. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16296. */
  16297. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16298. /**
  16299. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16300. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16301. * The `data` are either a numeric array either a Float32Array.
  16302. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16303. * 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).
  16304. * Note that a new underlying VertexBuffer object is created each call.
  16305. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16306. *
  16307. * Possible `kind` values :
  16308. * - VertexBuffer.PositionKind
  16309. * - VertexBuffer.UVKind
  16310. * - VertexBuffer.UV2Kind
  16311. * - VertexBuffer.UV3Kind
  16312. * - VertexBuffer.UV4Kind
  16313. * - VertexBuffer.UV5Kind
  16314. * - VertexBuffer.UV6Kind
  16315. * - VertexBuffer.ColorKind
  16316. * - VertexBuffer.MatricesIndicesKind
  16317. * - VertexBuffer.MatricesIndicesExtraKind
  16318. * - VertexBuffer.MatricesWeightsKind
  16319. * - VertexBuffer.MatricesWeightsExtraKind
  16320. *
  16321. * Returns the Mesh.
  16322. */
  16323. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16324. /**
  16325. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16326. * If the mesh has no geometry, it is simply returned as it is.
  16327. * The `data` are either a numeric array either a Float32Array.
  16328. * No new underlying VertexBuffer object is created.
  16329. * 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.
  16330. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16331. *
  16332. * Possible `kind` values :
  16333. * - VertexBuffer.PositionKind
  16334. * - VertexBuffer.UVKind
  16335. * - VertexBuffer.UV2Kind
  16336. * - VertexBuffer.UV3Kind
  16337. * - VertexBuffer.UV4Kind
  16338. * - VertexBuffer.UV5Kind
  16339. * - VertexBuffer.UV6Kind
  16340. * - VertexBuffer.ColorKind
  16341. * - VertexBuffer.MatricesIndicesKind
  16342. * - VertexBuffer.MatricesIndicesExtraKind
  16343. * - VertexBuffer.MatricesWeightsKind
  16344. * - VertexBuffer.MatricesWeightsExtraKind
  16345. *
  16346. * Returns the Mesh.
  16347. */
  16348. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16349. /**
  16350. * Sets the mesh indices.
  16351. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16352. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16353. * This method creates a new index buffer each call.
  16354. * Returns the Mesh.
  16355. */
  16356. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16357. /**
  16358. * Boolean : True if the mesh owns the requested kind of data.
  16359. */
  16360. isVerticesDataPresent(kind: string): boolean;
  16361. /**
  16362. * Returns an array of indices (IndicesArray).
  16363. */
  16364. getIndices(): Nullable<IndicesArray>;
  16365. get _positions(): Nullable<Vector3[]>;
  16366. /**
  16367. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16368. * This means the mesh underlying bounding box and sphere are recomputed.
  16369. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16370. * @returns the current mesh
  16371. */
  16372. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16373. /** @hidden */
  16374. _preActivate(): InstancedMesh;
  16375. /** @hidden */
  16376. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16377. /** @hidden */
  16378. _postActivate(): void;
  16379. getWorldMatrix(): Matrix;
  16380. get isAnInstance(): boolean;
  16381. /**
  16382. * Returns the current associated LOD AbstractMesh.
  16383. */
  16384. getLOD(camera: Camera): AbstractMesh;
  16385. /** @hidden */
  16386. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16387. /** @hidden */
  16388. _syncSubMeshes(): InstancedMesh;
  16389. /** @hidden */
  16390. _generatePointsArray(): boolean;
  16391. /** @hidden */
  16392. _updateBoundingInfo(): AbstractMesh;
  16393. /**
  16394. * Creates a new InstancedMesh from the current mesh.
  16395. * - name (string) : the cloned mesh name
  16396. * - newParent (optional Node) : the optional Node to parent the clone to.
  16397. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16398. *
  16399. * Returns the clone.
  16400. */
  16401. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16402. /**
  16403. * Disposes the InstancedMesh.
  16404. * Returns nothing.
  16405. */
  16406. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16407. }
  16408. interface Mesh {
  16409. /**
  16410. * Register a custom buffer that will be instanced
  16411. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16412. * @param kind defines the buffer kind
  16413. * @param stride defines the stride in floats
  16414. */
  16415. registerInstancedBuffer(kind: string, stride: number): void;
  16416. /**
  16417. * true to use the edge renderer for all instances of this mesh
  16418. */
  16419. edgesShareWithInstances: boolean;
  16420. /** @hidden */
  16421. _userInstancedBuffersStorage: {
  16422. data: {
  16423. [key: string]: Float32Array;
  16424. };
  16425. sizes: {
  16426. [key: string]: number;
  16427. };
  16428. vertexBuffers: {
  16429. [key: string]: Nullable<VertexBuffer>;
  16430. };
  16431. strides: {
  16432. [key: string]: number;
  16433. };
  16434. };
  16435. }
  16436. interface AbstractMesh {
  16437. /**
  16438. * Object used to store instanced buffers defined by user
  16439. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16440. */
  16441. instancedBuffers: {
  16442. [key: string]: any;
  16443. };
  16444. }
  16445. }
  16446. declare module BABYLON {
  16447. /**
  16448. * Defines the options associated with the creation of a shader material.
  16449. */
  16450. export interface IShaderMaterialOptions {
  16451. /**
  16452. * Does the material work in alpha blend mode
  16453. */
  16454. needAlphaBlending: boolean;
  16455. /**
  16456. * Does the material work in alpha test mode
  16457. */
  16458. needAlphaTesting: boolean;
  16459. /**
  16460. * The list of attribute names used in the shader
  16461. */
  16462. attributes: string[];
  16463. /**
  16464. * The list of unifrom names used in the shader
  16465. */
  16466. uniforms: string[];
  16467. /**
  16468. * The list of UBO names used in the shader
  16469. */
  16470. uniformBuffers: string[];
  16471. /**
  16472. * The list of sampler names used in the shader
  16473. */
  16474. samplers: string[];
  16475. /**
  16476. * The list of defines used in the shader
  16477. */
  16478. defines: string[];
  16479. }
  16480. /**
  16481. * 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.
  16482. *
  16483. * This returned material effects how the mesh will look based on the code in the shaders.
  16484. *
  16485. * @see https://doc.babylonjs.com/how_to/shader_material
  16486. */
  16487. export class ShaderMaterial extends Material {
  16488. private _shaderPath;
  16489. private _options;
  16490. private _textures;
  16491. private _textureArrays;
  16492. private _floats;
  16493. private _ints;
  16494. private _floatsArrays;
  16495. private _colors3;
  16496. private _colors3Arrays;
  16497. private _colors4;
  16498. private _colors4Arrays;
  16499. private _vectors2;
  16500. private _vectors3;
  16501. private _vectors4;
  16502. private _matrices;
  16503. private _matrixArrays;
  16504. private _matrices3x3;
  16505. private _matrices2x2;
  16506. private _vectors2Arrays;
  16507. private _vectors3Arrays;
  16508. private _vectors4Arrays;
  16509. private _cachedWorldViewMatrix;
  16510. private _cachedWorldViewProjectionMatrix;
  16511. private _renderId;
  16512. private _multiview;
  16513. private _cachedDefines;
  16514. /** Define the Url to load snippets */
  16515. static SnippetUrl: string;
  16516. /** Snippet ID if the material was created from the snippet server */
  16517. snippetId: string;
  16518. /**
  16519. * Instantiate a new shader material.
  16520. * 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.
  16521. * This returned material effects how the mesh will look based on the code in the shaders.
  16522. * @see https://doc.babylonjs.com/how_to/shader_material
  16523. * @param name Define the name of the material in the scene
  16524. * @param scene Define the scene the material belongs to
  16525. * @param shaderPath Defines the route to the shader code in one of three ways:
  16526. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16527. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16528. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16529. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16530. * @param options Define the options used to create the shader
  16531. */
  16532. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16533. /**
  16534. * Gets the shader path used to define the shader code
  16535. * It can be modified to trigger a new compilation
  16536. */
  16537. get shaderPath(): any;
  16538. /**
  16539. * Sets the shader path used to define the shader code
  16540. * It can be modified to trigger a new compilation
  16541. */
  16542. set shaderPath(shaderPath: any);
  16543. /**
  16544. * Gets the options used to compile the shader.
  16545. * They can be modified to trigger a new compilation
  16546. */
  16547. get options(): IShaderMaterialOptions;
  16548. /**
  16549. * Gets the current class name of the material e.g. "ShaderMaterial"
  16550. * Mainly use in serialization.
  16551. * @returns the class name
  16552. */
  16553. getClassName(): string;
  16554. /**
  16555. * Specifies if the material will require alpha blending
  16556. * @returns a boolean specifying if alpha blending is needed
  16557. */
  16558. needAlphaBlending(): boolean;
  16559. /**
  16560. * Specifies if this material should be rendered in alpha test mode
  16561. * @returns a boolean specifying if an alpha test is needed.
  16562. */
  16563. needAlphaTesting(): boolean;
  16564. private _checkUniform;
  16565. /**
  16566. * Set a texture in the shader.
  16567. * @param name Define the name of the uniform samplers as defined in the shader
  16568. * @param texture Define the texture to bind to this sampler
  16569. * @return the material itself allowing "fluent" like uniform updates
  16570. */
  16571. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16572. /**
  16573. * Set a texture array in the shader.
  16574. * @param name Define the name of the uniform sampler array as defined in the shader
  16575. * @param textures Define the list of textures to bind to this sampler
  16576. * @return the material itself allowing "fluent" like uniform updates
  16577. */
  16578. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16579. /**
  16580. * Set a float in the shader.
  16581. * @param name Define the name of the uniform as defined in the shader
  16582. * @param value Define the value to give to the uniform
  16583. * @return the material itself allowing "fluent" like uniform updates
  16584. */
  16585. setFloat(name: string, value: number): ShaderMaterial;
  16586. /**
  16587. * Set a int in the shader.
  16588. * @param name Define the name of the uniform as defined in the shader
  16589. * @param value Define the value to give to the uniform
  16590. * @return the material itself allowing "fluent" like uniform updates
  16591. */
  16592. setInt(name: string, value: number): ShaderMaterial;
  16593. /**
  16594. * Set an array of floats in the shader.
  16595. * @param name Define the name of the uniform as defined in the shader
  16596. * @param value Define the value to give to the uniform
  16597. * @return the material itself allowing "fluent" like uniform updates
  16598. */
  16599. setFloats(name: string, value: number[]): ShaderMaterial;
  16600. /**
  16601. * Set a vec3 in the shader from a Color3.
  16602. * @param name Define the name of the uniform as defined in the shader
  16603. * @param value Define the value to give to the uniform
  16604. * @return the material itself allowing "fluent" like uniform updates
  16605. */
  16606. setColor3(name: string, value: Color3): ShaderMaterial;
  16607. /**
  16608. * Set a vec3 array in the shader from a Color3 array.
  16609. * @param name Define the name of the uniform as defined in the shader
  16610. * @param value Define the value to give to the uniform
  16611. * @return the material itself allowing "fluent" like uniform updates
  16612. */
  16613. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16614. /**
  16615. * Set a vec4 in the shader from a Color4.
  16616. * @param name Define the name of the uniform as defined in the shader
  16617. * @param value Define the value to give to the uniform
  16618. * @return the material itself allowing "fluent" like uniform updates
  16619. */
  16620. setColor4(name: string, value: Color4): ShaderMaterial;
  16621. /**
  16622. * Set a vec4 array in the shader from a Color4 array.
  16623. * @param name Define the name of the uniform as defined in the shader
  16624. * @param value Define the value to give to the uniform
  16625. * @return the material itself allowing "fluent" like uniform updates
  16626. */
  16627. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16628. /**
  16629. * Set a vec2 in the shader from a Vector2.
  16630. * @param name Define the name of the uniform as defined in the shader
  16631. * @param value Define the value to give to the uniform
  16632. * @return the material itself allowing "fluent" like uniform updates
  16633. */
  16634. setVector2(name: string, value: Vector2): ShaderMaterial;
  16635. /**
  16636. * Set a vec3 in the shader from a Vector3.
  16637. * @param name Define the name of the uniform as defined in the shader
  16638. * @param value Define the value to give to the uniform
  16639. * @return the material itself allowing "fluent" like uniform updates
  16640. */
  16641. setVector3(name: string, value: Vector3): ShaderMaterial;
  16642. /**
  16643. * Set a vec4 in the shader from a Vector4.
  16644. * @param name Define the name of the uniform as defined in the shader
  16645. * @param value Define the value to give to the uniform
  16646. * @return the material itself allowing "fluent" like uniform updates
  16647. */
  16648. setVector4(name: string, value: Vector4): ShaderMaterial;
  16649. /**
  16650. * Set a mat4 in the shader from a Matrix.
  16651. * @param name Define the name of the uniform as defined in the shader
  16652. * @param value Define the value to give to the uniform
  16653. * @return the material itself allowing "fluent" like uniform updates
  16654. */
  16655. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16656. /**
  16657. * Set a float32Array in the shader from a matrix array.
  16658. * @param name Define the name of the uniform as defined in the shader
  16659. * @param value Define the value to give to the uniform
  16660. * @return the material itself allowing "fluent" like uniform updates
  16661. */
  16662. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16663. /**
  16664. * Set a mat3 in the shader from a Float32Array.
  16665. * @param name Define the name of the uniform as defined in the shader
  16666. * @param value Define the value to give to the uniform
  16667. * @return the material itself allowing "fluent" like uniform updates
  16668. */
  16669. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16670. /**
  16671. * Set a mat2 in the shader from a Float32Array.
  16672. * @param name Define the name of the uniform as defined in the shader
  16673. * @param value Define the value to give to the uniform
  16674. * @return the material itself allowing "fluent" like uniform updates
  16675. */
  16676. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16677. /**
  16678. * Set a vec2 array in the shader from a number array.
  16679. * @param name Define the name of the uniform as defined in the shader
  16680. * @param value Define the value to give to the uniform
  16681. * @return the material itself allowing "fluent" like uniform updates
  16682. */
  16683. setArray2(name: string, value: number[]): ShaderMaterial;
  16684. /**
  16685. * Set a vec3 array in the shader from a number array.
  16686. * @param name Define the name of the uniform as defined in the shader
  16687. * @param value Define the value to give to the uniform
  16688. * @return the material itself allowing "fluent" like uniform updates
  16689. */
  16690. setArray3(name: string, value: number[]): ShaderMaterial;
  16691. /**
  16692. * Set a vec4 array in the shader from a number array.
  16693. * @param name Define the name of the uniform as defined in the shader
  16694. * @param value Define the value to give to the uniform
  16695. * @return the material itself allowing "fluent" like uniform updates
  16696. */
  16697. setArray4(name: string, value: number[]): ShaderMaterial;
  16698. private _checkCache;
  16699. /**
  16700. * Specifies that the submesh is ready to be used
  16701. * @param mesh defines the mesh to check
  16702. * @param subMesh defines which submesh to check
  16703. * @param useInstances specifies that instances should be used
  16704. * @returns a boolean indicating that the submesh is ready or not
  16705. */
  16706. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16707. /**
  16708. * Checks if the material is ready to render the requested mesh
  16709. * @param mesh Define the mesh to render
  16710. * @param useInstances Define whether or not the material is used with instances
  16711. * @returns true if ready, otherwise false
  16712. */
  16713. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16714. /**
  16715. * Binds the world matrix to the material
  16716. * @param world defines the world transformation matrix
  16717. * @param effectOverride - If provided, use this effect instead of internal effect
  16718. */
  16719. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16720. /**
  16721. * Binds the submesh to this material by preparing the effect and shader to draw
  16722. * @param world defines the world transformation matrix
  16723. * @param mesh defines the mesh containing the submesh
  16724. * @param subMesh defines the submesh to bind the material to
  16725. */
  16726. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16727. /**
  16728. * Binds the material to the mesh
  16729. * @param world defines the world transformation matrix
  16730. * @param mesh defines the mesh to bind the material to
  16731. * @param effectOverride - If provided, use this effect instead of internal effect
  16732. */
  16733. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16734. protected _afterBind(mesh?: Mesh): void;
  16735. /**
  16736. * Gets the active textures from the material
  16737. * @returns an array of textures
  16738. */
  16739. getActiveTextures(): BaseTexture[];
  16740. /**
  16741. * Specifies if the material uses a texture
  16742. * @param texture defines the texture to check against the material
  16743. * @returns a boolean specifying if the material uses the texture
  16744. */
  16745. hasTexture(texture: BaseTexture): boolean;
  16746. /**
  16747. * Makes a duplicate of the material, and gives it a new name
  16748. * @param name defines the new name for the duplicated material
  16749. * @returns the cloned material
  16750. */
  16751. clone(name: string): ShaderMaterial;
  16752. /**
  16753. * Disposes the material
  16754. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16755. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16756. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16757. */
  16758. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16759. /**
  16760. * Serializes this material in a JSON representation
  16761. * @returns the serialized material object
  16762. */
  16763. serialize(): any;
  16764. /**
  16765. * Creates a shader material from parsed shader material data
  16766. * @param source defines the JSON represnetation of the material
  16767. * @param scene defines the hosting scene
  16768. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16769. * @returns a new material
  16770. */
  16771. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16772. /**
  16773. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16774. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16775. * @param url defines the url to load from
  16776. * @param scene defines the hosting scene
  16777. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16778. * @returns a promise that will resolve to the new ShaderMaterial
  16779. */
  16780. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16781. /**
  16782. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16783. * @param snippetId defines the snippet to load
  16784. * @param scene defines the hosting scene
  16785. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16786. * @returns a promise that will resolve to the new ShaderMaterial
  16787. */
  16788. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16789. }
  16790. }
  16791. declare module BABYLON {
  16792. /** @hidden */
  16793. export var colorPixelShader: {
  16794. name: string;
  16795. shader: string;
  16796. };
  16797. }
  16798. declare module BABYLON {
  16799. /** @hidden */
  16800. export var colorVertexShader: {
  16801. name: string;
  16802. shader: string;
  16803. };
  16804. }
  16805. declare module BABYLON {
  16806. /**
  16807. * Line mesh
  16808. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16809. */
  16810. export class LinesMesh extends Mesh {
  16811. /**
  16812. * If vertex color should be applied to the mesh
  16813. */
  16814. readonly useVertexColor?: boolean | undefined;
  16815. /**
  16816. * If vertex alpha should be applied to the mesh
  16817. */
  16818. readonly useVertexAlpha?: boolean | undefined;
  16819. /**
  16820. * Color of the line (Default: White)
  16821. */
  16822. color: Color3;
  16823. /**
  16824. * Alpha of the line (Default: 1)
  16825. */
  16826. alpha: number;
  16827. /**
  16828. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16829. * This margin is expressed in world space coordinates, so its value may vary.
  16830. * Default value is 0.1
  16831. */
  16832. intersectionThreshold: number;
  16833. private _colorShader;
  16834. private color4;
  16835. /**
  16836. * Creates a new LinesMesh
  16837. * @param name defines the name
  16838. * @param scene defines the hosting scene
  16839. * @param parent defines the parent mesh if any
  16840. * @param source defines the optional source LinesMesh used to clone data from
  16841. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16842. * When false, achieved by calling a clone(), also passing False.
  16843. * This will make creation of children, recursive.
  16844. * @param useVertexColor defines if this LinesMesh supports vertex color
  16845. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16846. */
  16847. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16848. /**
  16849. * If vertex color should be applied to the mesh
  16850. */
  16851. useVertexColor?: boolean | undefined,
  16852. /**
  16853. * If vertex alpha should be applied to the mesh
  16854. */
  16855. useVertexAlpha?: boolean | undefined);
  16856. private _addClipPlaneDefine;
  16857. private _removeClipPlaneDefine;
  16858. isReady(): boolean;
  16859. /**
  16860. * Returns the string "LineMesh"
  16861. */
  16862. getClassName(): string;
  16863. /**
  16864. * @hidden
  16865. */
  16866. get material(): Material;
  16867. /**
  16868. * @hidden
  16869. */
  16870. set material(value: Material);
  16871. /**
  16872. * @hidden
  16873. */
  16874. get checkCollisions(): boolean;
  16875. /** @hidden */
  16876. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16877. /** @hidden */
  16878. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16879. /**
  16880. * Disposes of the line mesh
  16881. * @param doNotRecurse If children should be disposed
  16882. */
  16883. dispose(doNotRecurse?: boolean): void;
  16884. /**
  16885. * Returns a new LineMesh object cloned from the current one.
  16886. */
  16887. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16888. /**
  16889. * Creates a new InstancedLinesMesh object from the mesh model.
  16890. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16891. * @param name defines the name of the new instance
  16892. * @returns a new InstancedLinesMesh
  16893. */
  16894. createInstance(name: string): InstancedLinesMesh;
  16895. }
  16896. /**
  16897. * Creates an instance based on a source LinesMesh
  16898. */
  16899. export class InstancedLinesMesh extends InstancedMesh {
  16900. /**
  16901. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16902. * This margin is expressed in world space coordinates, so its value may vary.
  16903. * Initilized with the intersectionThreshold value of the source LinesMesh
  16904. */
  16905. intersectionThreshold: number;
  16906. constructor(name: string, source: LinesMesh);
  16907. /**
  16908. * Returns the string "InstancedLinesMesh".
  16909. */
  16910. getClassName(): string;
  16911. }
  16912. }
  16913. declare module BABYLON {
  16914. /** @hidden */
  16915. export var linePixelShader: {
  16916. name: string;
  16917. shader: string;
  16918. };
  16919. }
  16920. declare module BABYLON {
  16921. /** @hidden */
  16922. export var lineVertexShader: {
  16923. name: string;
  16924. shader: string;
  16925. };
  16926. }
  16927. declare module BABYLON {
  16928. interface Scene {
  16929. /** @hidden */
  16930. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  16931. }
  16932. interface AbstractMesh {
  16933. /**
  16934. * Gets the edgesRenderer associated with the mesh
  16935. */
  16936. edgesRenderer: Nullable<EdgesRenderer>;
  16937. }
  16938. interface LinesMesh {
  16939. /**
  16940. * Enables the edge rendering mode on the mesh.
  16941. * This mode makes the mesh edges visible
  16942. * @param epsilon defines the maximal distance between two angles to detect a face
  16943. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16944. * @returns the currentAbstractMesh
  16945. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16946. */
  16947. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16948. }
  16949. interface InstancedLinesMesh {
  16950. /**
  16951. * Enables the edge rendering mode on the mesh.
  16952. * This mode makes the mesh edges visible
  16953. * @param epsilon defines the maximal distance between two angles to detect a face
  16954. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16955. * @returns the current InstancedLinesMesh
  16956. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16957. */
  16958. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16959. }
  16960. /**
  16961. * Defines the minimum contract an Edges renderer should follow.
  16962. */
  16963. export interface IEdgesRenderer extends IDisposable {
  16964. /**
  16965. * Gets or sets a boolean indicating if the edgesRenderer is active
  16966. */
  16967. isEnabled: boolean;
  16968. /**
  16969. * Renders the edges of the attached mesh,
  16970. */
  16971. render(): void;
  16972. /**
  16973. * Checks wether or not the edges renderer is ready to render.
  16974. * @return true if ready, otherwise false.
  16975. */
  16976. isReady(): boolean;
  16977. /**
  16978. * List of instances to render in case the source mesh has instances
  16979. */
  16980. customInstances: SmartArray<Matrix>;
  16981. }
  16982. /**
  16983. * Defines the additional options of the edges renderer
  16984. */
  16985. export interface IEdgesRendererOptions {
  16986. /**
  16987. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  16988. * If not defined, the default value is true
  16989. */
  16990. useAlternateEdgeFinder?: boolean;
  16991. /**
  16992. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  16993. * If not defined, the default value is true.
  16994. * 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)
  16995. * This option is used only if useAlternateEdgeFinder = true
  16996. */
  16997. useFastVertexMerger?: boolean;
  16998. /**
  16999. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17000. * The default value is 1e-6
  17001. * This option is used only if useAlternateEdgeFinder = true
  17002. */
  17003. epsilonVertexMerge?: number;
  17004. /**
  17005. * 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
  17006. * 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.
  17007. * This option is used only if useAlternateEdgeFinder = true
  17008. */
  17009. applyTessellation?: boolean;
  17010. /**
  17011. * 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
  17012. * The default value is 1e-6
  17013. * This option is used only if useAlternateEdgeFinder = true
  17014. */
  17015. epsilonVertexAligned?: number;
  17016. }
  17017. /**
  17018. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17019. */
  17020. export class EdgesRenderer implements IEdgesRenderer {
  17021. /**
  17022. * Define the size of the edges with an orthographic camera
  17023. */
  17024. edgesWidthScalerForOrthographic: number;
  17025. /**
  17026. * Define the size of the edges with a perspective camera
  17027. */
  17028. edgesWidthScalerForPerspective: number;
  17029. protected _source: AbstractMesh;
  17030. protected _linesPositions: number[];
  17031. protected _linesNormals: number[];
  17032. protected _linesIndices: number[];
  17033. protected _epsilon: number;
  17034. protected _indicesCount: number;
  17035. protected _lineShader: ShaderMaterial;
  17036. protected _ib: DataBuffer;
  17037. protected _buffers: {
  17038. [key: string]: Nullable<VertexBuffer>;
  17039. };
  17040. protected _buffersForInstances: {
  17041. [key: string]: Nullable<VertexBuffer>;
  17042. };
  17043. protected _checkVerticesInsteadOfIndices: boolean;
  17044. protected _options: Nullable<IEdgesRendererOptions>;
  17045. private _meshRebuildObserver;
  17046. private _meshDisposeObserver;
  17047. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17048. isEnabled: boolean;
  17049. /**
  17050. * List of instances to render in case the source mesh has instances
  17051. */
  17052. customInstances: SmartArray<Matrix>;
  17053. private static GetShader;
  17054. /**
  17055. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17056. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17057. * @param source Mesh used to create edges
  17058. * @param epsilon sum of angles in adjacency to check for edge
  17059. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17060. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17061. * @param options The options to apply when generating the edges
  17062. */
  17063. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17064. protected _prepareRessources(): void;
  17065. /** @hidden */
  17066. _rebuild(): void;
  17067. /**
  17068. * Releases the required resources for the edges renderer
  17069. */
  17070. dispose(): void;
  17071. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17072. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17073. /**
  17074. * Checks if the pair of p0 and p1 is en edge
  17075. * @param faceIndex
  17076. * @param edge
  17077. * @param faceNormals
  17078. * @param p0
  17079. * @param p1
  17080. * @private
  17081. */
  17082. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17083. /**
  17084. * push line into the position, normal and index buffer
  17085. * @protected
  17086. */
  17087. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17088. /**
  17089. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17090. */
  17091. private _tessellateTriangle;
  17092. private _generateEdgesLinesAlternate;
  17093. /**
  17094. * Generates lines edges from adjacencjes
  17095. * @private
  17096. */
  17097. _generateEdgesLines(): void;
  17098. /**
  17099. * Checks wether or not the edges renderer is ready to render.
  17100. * @return true if ready, otherwise false.
  17101. */
  17102. isReady(): boolean;
  17103. /**
  17104. * Renders the edges of the attached mesh,
  17105. */
  17106. render(): void;
  17107. }
  17108. /**
  17109. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17110. */
  17111. export class LineEdgesRenderer extends EdgesRenderer {
  17112. /**
  17113. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17114. * @param source LineMesh used to generate edges
  17115. * @param epsilon not important (specified angle for edge detection)
  17116. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17117. */
  17118. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17119. /**
  17120. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17121. */
  17122. _generateEdgesLines(): void;
  17123. }
  17124. }
  17125. declare module BABYLON {
  17126. /**
  17127. * This represents the object necessary to create a rendering group.
  17128. * This is exclusively used and created by the rendering manager.
  17129. * To modify the behavior, you use the available helpers in your scene or meshes.
  17130. * @hidden
  17131. */
  17132. export class RenderingGroup {
  17133. index: number;
  17134. private static _zeroVector;
  17135. private _scene;
  17136. private _opaqueSubMeshes;
  17137. private _transparentSubMeshes;
  17138. private _alphaTestSubMeshes;
  17139. private _depthOnlySubMeshes;
  17140. private _particleSystems;
  17141. private _spriteManagers;
  17142. private _opaqueSortCompareFn;
  17143. private _alphaTestSortCompareFn;
  17144. private _transparentSortCompareFn;
  17145. private _renderOpaque;
  17146. private _renderAlphaTest;
  17147. private _renderTransparent;
  17148. /** @hidden */
  17149. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17150. onBeforeTransparentRendering: () => void;
  17151. /**
  17152. * Set the opaque sort comparison function.
  17153. * If null the sub meshes will be render in the order they were created
  17154. */
  17155. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17156. /**
  17157. * Set the alpha test sort comparison function.
  17158. * If null the sub meshes will be render in the order they were created
  17159. */
  17160. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17161. /**
  17162. * Set the transparent sort comparison function.
  17163. * If null the sub meshes will be render in the order they were created
  17164. */
  17165. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17166. /**
  17167. * Creates a new rendering group.
  17168. * @param index The rendering group index
  17169. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17170. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17171. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17172. */
  17173. 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>);
  17174. /**
  17175. * Render all the sub meshes contained in the group.
  17176. * @param customRenderFunction Used to override the default render behaviour of the group.
  17177. * @returns true if rendered some submeshes.
  17178. */
  17179. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17180. /**
  17181. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17182. * @param subMeshes The submeshes to render
  17183. */
  17184. private renderOpaqueSorted;
  17185. /**
  17186. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17187. * @param subMeshes The submeshes to render
  17188. */
  17189. private renderAlphaTestSorted;
  17190. /**
  17191. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17192. * @param subMeshes The submeshes to render
  17193. */
  17194. private renderTransparentSorted;
  17195. /**
  17196. * Renders the submeshes in a specified order.
  17197. * @param subMeshes The submeshes to sort before render
  17198. * @param sortCompareFn The comparison function use to sort
  17199. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17200. * @param transparent Specifies to activate blending if true
  17201. */
  17202. private static renderSorted;
  17203. /**
  17204. * Renders the submeshes in the order they were dispatched (no sort applied).
  17205. * @param subMeshes The submeshes to render
  17206. */
  17207. private static renderUnsorted;
  17208. /**
  17209. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17210. * are rendered back to front if in the same alpha index.
  17211. *
  17212. * @param a The first submesh
  17213. * @param b The second submesh
  17214. * @returns The result of the comparison
  17215. */
  17216. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17217. /**
  17218. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17219. * are rendered back to front.
  17220. *
  17221. * @param a The first submesh
  17222. * @param b The second submesh
  17223. * @returns The result of the comparison
  17224. */
  17225. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17226. /**
  17227. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17228. * are rendered front to back (prevent overdraw).
  17229. *
  17230. * @param a The first submesh
  17231. * @param b The second submesh
  17232. * @returns The result of the comparison
  17233. */
  17234. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17235. /**
  17236. * Resets the different lists of submeshes to prepare a new frame.
  17237. */
  17238. prepare(): void;
  17239. dispose(): void;
  17240. /**
  17241. * Inserts the submesh in its correct queue depending on its material.
  17242. * @param subMesh The submesh to dispatch
  17243. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17244. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17245. */
  17246. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17247. dispatchSprites(spriteManager: ISpriteManager): void;
  17248. dispatchParticles(particleSystem: IParticleSystem): void;
  17249. private _renderParticles;
  17250. private _renderSprites;
  17251. }
  17252. }
  17253. declare module BABYLON {
  17254. /**
  17255. * Interface describing the different options available in the rendering manager
  17256. * regarding Auto Clear between groups.
  17257. */
  17258. export interface IRenderingManagerAutoClearSetup {
  17259. /**
  17260. * Defines whether or not autoclear is enable.
  17261. */
  17262. autoClear: boolean;
  17263. /**
  17264. * Defines whether or not to autoclear the depth buffer.
  17265. */
  17266. depth: boolean;
  17267. /**
  17268. * Defines whether or not to autoclear the stencil buffer.
  17269. */
  17270. stencil: boolean;
  17271. }
  17272. /**
  17273. * This class is used by the onRenderingGroupObservable
  17274. */
  17275. export class RenderingGroupInfo {
  17276. /**
  17277. * The Scene that being rendered
  17278. */
  17279. scene: Scene;
  17280. /**
  17281. * The camera currently used for the rendering pass
  17282. */
  17283. camera: Nullable<Camera>;
  17284. /**
  17285. * The ID of the renderingGroup being processed
  17286. */
  17287. renderingGroupId: number;
  17288. }
  17289. /**
  17290. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17291. * It is enable to manage the different groups as well as the different necessary sort functions.
  17292. * This should not be used directly aside of the few static configurations
  17293. */
  17294. export class RenderingManager {
  17295. /**
  17296. * The max id used for rendering groups (not included)
  17297. */
  17298. static MAX_RENDERINGGROUPS: number;
  17299. /**
  17300. * The min id used for rendering groups (included)
  17301. */
  17302. static MIN_RENDERINGGROUPS: number;
  17303. /**
  17304. * Used to globally prevent autoclearing scenes.
  17305. */
  17306. static AUTOCLEAR: boolean;
  17307. /**
  17308. * @hidden
  17309. */
  17310. _useSceneAutoClearSetup: boolean;
  17311. private _scene;
  17312. private _renderingGroups;
  17313. private _depthStencilBufferAlreadyCleaned;
  17314. private _autoClearDepthStencil;
  17315. private _customOpaqueSortCompareFn;
  17316. private _customAlphaTestSortCompareFn;
  17317. private _customTransparentSortCompareFn;
  17318. private _renderingGroupInfo;
  17319. /**
  17320. * Instantiates a new rendering group for a particular scene
  17321. * @param scene Defines the scene the groups belongs to
  17322. */
  17323. constructor(scene: Scene);
  17324. private _clearDepthStencilBuffer;
  17325. /**
  17326. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17327. * @hidden
  17328. */
  17329. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17330. /**
  17331. * Resets the different information of the group to prepare a new frame
  17332. * @hidden
  17333. */
  17334. reset(): void;
  17335. /**
  17336. * Dispose and release the group and its associated resources.
  17337. * @hidden
  17338. */
  17339. dispose(): void;
  17340. /**
  17341. * Clear the info related to rendering groups preventing retention points during dispose.
  17342. */
  17343. freeRenderingGroups(): void;
  17344. private _prepareRenderingGroup;
  17345. /**
  17346. * Add a sprite manager to the rendering manager in order to render it this frame.
  17347. * @param spriteManager Define the sprite manager to render
  17348. */
  17349. dispatchSprites(spriteManager: ISpriteManager): void;
  17350. /**
  17351. * Add a particle system to the rendering manager in order to render it this frame.
  17352. * @param particleSystem Define the particle system to render
  17353. */
  17354. dispatchParticles(particleSystem: IParticleSystem): void;
  17355. /**
  17356. * Add a submesh to the manager in order to render it this frame
  17357. * @param subMesh The submesh to dispatch
  17358. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17359. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17360. */
  17361. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17362. /**
  17363. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17364. * This allowed control for front to back rendering or reversly depending of the special needs.
  17365. *
  17366. * @param renderingGroupId The rendering group id corresponding to its index
  17367. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17368. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17369. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17370. */
  17371. 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;
  17372. /**
  17373. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17374. *
  17375. * @param renderingGroupId The rendering group id corresponding to its index
  17376. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17377. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17378. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17379. */
  17380. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17381. /**
  17382. * Gets the current auto clear configuration for one rendering group of the rendering
  17383. * manager.
  17384. * @param index the rendering group index to get the information for
  17385. * @returns The auto clear setup for the requested rendering group
  17386. */
  17387. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17388. }
  17389. }
  17390. declare module BABYLON {
  17391. /**
  17392. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17393. */
  17394. export interface ICustomShaderOptions {
  17395. /**
  17396. * Gets or sets the custom shader name to use
  17397. */
  17398. shaderName: string;
  17399. /**
  17400. * The list of attribute names used in the shader
  17401. */
  17402. attributes?: string[];
  17403. /**
  17404. * The list of unifrom names used in the shader
  17405. */
  17406. uniforms?: string[];
  17407. /**
  17408. * The list of sampler names used in the shader
  17409. */
  17410. samplers?: string[];
  17411. /**
  17412. * The list of defines used in the shader
  17413. */
  17414. defines?: string[];
  17415. }
  17416. /**
  17417. * Interface to implement to create a shadow generator compatible with BJS.
  17418. */
  17419. export interface IShadowGenerator {
  17420. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17421. id: string;
  17422. /**
  17423. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17424. * @returns The render target texture if present otherwise, null
  17425. */
  17426. getShadowMap(): Nullable<RenderTargetTexture>;
  17427. /**
  17428. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17429. * @param subMesh The submesh we want to render in the shadow map
  17430. * @param useInstances Defines wether will draw in the map using instances
  17431. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17432. * @returns true if ready otherwise, false
  17433. */
  17434. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17435. /**
  17436. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17437. * @param defines Defines of the material we want to update
  17438. * @param lightIndex Index of the light in the enabled light list of the material
  17439. */
  17440. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17441. /**
  17442. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17443. * defined in the generator but impacting the effect).
  17444. * It implies the unifroms available on the materials are the standard BJS ones.
  17445. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17446. * @param effect The effect we are binfing the information for
  17447. */
  17448. bindShadowLight(lightIndex: string, effect: Effect): void;
  17449. /**
  17450. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17451. * (eq to shadow prjection matrix * light transform matrix)
  17452. * @returns The transform matrix used to create the shadow map
  17453. */
  17454. getTransformMatrix(): Matrix;
  17455. /**
  17456. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17457. * Cube and 2D textures for instance.
  17458. */
  17459. recreateShadowMap(): void;
  17460. /**
  17461. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17462. * @param onCompiled Callback triggered at the and of the effects compilation
  17463. * @param options Sets of optional options forcing the compilation with different modes
  17464. */
  17465. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17466. useInstances: boolean;
  17467. }>): void;
  17468. /**
  17469. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17470. * @param options Sets of optional options forcing the compilation with different modes
  17471. * @returns A promise that resolves when the compilation completes
  17472. */
  17473. forceCompilationAsync(options?: Partial<{
  17474. useInstances: boolean;
  17475. }>): Promise<void>;
  17476. /**
  17477. * Serializes the shadow generator setup to a json object.
  17478. * @returns The serialized JSON object
  17479. */
  17480. serialize(): any;
  17481. /**
  17482. * Disposes the Shadow map and related Textures and effects.
  17483. */
  17484. dispose(): void;
  17485. }
  17486. /**
  17487. * Default implementation IShadowGenerator.
  17488. * This is the main object responsible of generating shadows in the framework.
  17489. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17490. */
  17491. export class ShadowGenerator implements IShadowGenerator {
  17492. /**
  17493. * Name of the shadow generator class
  17494. */
  17495. static CLASSNAME: string;
  17496. /**
  17497. * Shadow generator mode None: no filtering applied.
  17498. */
  17499. static readonly FILTER_NONE: number;
  17500. /**
  17501. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17502. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17503. */
  17504. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17505. /**
  17506. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17507. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17508. */
  17509. static readonly FILTER_POISSONSAMPLING: number;
  17510. /**
  17511. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17512. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17513. */
  17514. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17515. /**
  17516. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17517. * edge artifacts on steep falloff.
  17518. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17519. */
  17520. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17521. /**
  17522. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17523. * edge artifacts on steep falloff.
  17524. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17525. */
  17526. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17527. /**
  17528. * Shadow generator mode PCF: Percentage Closer Filtering
  17529. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17530. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17531. */
  17532. static readonly FILTER_PCF: number;
  17533. /**
  17534. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17535. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17536. * Contact Hardening
  17537. */
  17538. static readonly FILTER_PCSS: number;
  17539. /**
  17540. * Reserved for PCF and PCSS
  17541. * Highest Quality.
  17542. *
  17543. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17544. *
  17545. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17546. */
  17547. static readonly QUALITY_HIGH: number;
  17548. /**
  17549. * Reserved for PCF and PCSS
  17550. * Good tradeoff for quality/perf cross devices
  17551. *
  17552. * Execute PCF on a 3*3 kernel.
  17553. *
  17554. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17555. */
  17556. static readonly QUALITY_MEDIUM: number;
  17557. /**
  17558. * Reserved for PCF and PCSS
  17559. * The lowest quality but the fastest.
  17560. *
  17561. * Execute PCF on a 1*1 kernel.
  17562. *
  17563. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17564. */
  17565. static readonly QUALITY_LOW: number;
  17566. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17567. id: string;
  17568. /** Gets or sets the custom shader name to use */
  17569. customShaderOptions: ICustomShaderOptions;
  17570. /**
  17571. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17572. */
  17573. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17574. /**
  17575. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17576. */
  17577. onAfterShadowMapRenderObservable: Observable<Effect>;
  17578. /**
  17579. * Observable triggered before a mesh is rendered in the shadow map.
  17580. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17581. */
  17582. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17583. /**
  17584. * Observable triggered after a mesh is rendered in the shadow map.
  17585. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17586. */
  17587. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17588. protected _bias: number;
  17589. /**
  17590. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17591. */
  17592. get bias(): number;
  17593. /**
  17594. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17595. */
  17596. set bias(bias: number);
  17597. protected _normalBias: number;
  17598. /**
  17599. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17600. */
  17601. get normalBias(): number;
  17602. /**
  17603. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17604. */
  17605. set normalBias(normalBias: number);
  17606. protected _blurBoxOffset: number;
  17607. /**
  17608. * Gets the blur box offset: offset applied during the blur pass.
  17609. * Only useful if useKernelBlur = false
  17610. */
  17611. get blurBoxOffset(): number;
  17612. /**
  17613. * Sets the blur box offset: offset applied during the blur pass.
  17614. * Only useful if useKernelBlur = false
  17615. */
  17616. set blurBoxOffset(value: number);
  17617. protected _blurScale: number;
  17618. /**
  17619. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17620. * 2 means half of the size.
  17621. */
  17622. get blurScale(): number;
  17623. /**
  17624. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17625. * 2 means half of the size.
  17626. */
  17627. set blurScale(value: number);
  17628. protected _blurKernel: number;
  17629. /**
  17630. * Gets the blur kernel: kernel size of the blur pass.
  17631. * Only useful if useKernelBlur = true
  17632. */
  17633. get blurKernel(): number;
  17634. /**
  17635. * Sets the blur kernel: kernel size of the blur pass.
  17636. * Only useful if useKernelBlur = true
  17637. */
  17638. set blurKernel(value: number);
  17639. protected _useKernelBlur: boolean;
  17640. /**
  17641. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17642. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17643. */
  17644. get useKernelBlur(): boolean;
  17645. /**
  17646. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17647. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17648. */
  17649. set useKernelBlur(value: boolean);
  17650. protected _depthScale: number;
  17651. /**
  17652. * Gets the depth scale used in ESM mode.
  17653. */
  17654. get depthScale(): number;
  17655. /**
  17656. * Sets the depth scale used in ESM mode.
  17657. * This can override the scale stored on the light.
  17658. */
  17659. set depthScale(value: number);
  17660. protected _validateFilter(filter: number): number;
  17661. protected _filter: number;
  17662. /**
  17663. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17664. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17665. */
  17666. get filter(): number;
  17667. /**
  17668. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17669. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17670. */
  17671. set filter(value: number);
  17672. /**
  17673. * Gets if the current filter is set to Poisson Sampling.
  17674. */
  17675. get usePoissonSampling(): boolean;
  17676. /**
  17677. * Sets the current filter to Poisson Sampling.
  17678. */
  17679. set usePoissonSampling(value: boolean);
  17680. /**
  17681. * Gets if the current filter is set to ESM.
  17682. */
  17683. get useExponentialShadowMap(): boolean;
  17684. /**
  17685. * Sets the current filter is to ESM.
  17686. */
  17687. set useExponentialShadowMap(value: boolean);
  17688. /**
  17689. * Gets if the current filter is set to filtered ESM.
  17690. */
  17691. get useBlurExponentialShadowMap(): boolean;
  17692. /**
  17693. * Gets if the current filter is set to filtered ESM.
  17694. */
  17695. set useBlurExponentialShadowMap(value: boolean);
  17696. /**
  17697. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17698. * exponential to prevent steep falloff artifacts).
  17699. */
  17700. get useCloseExponentialShadowMap(): boolean;
  17701. /**
  17702. * Sets the current filter to "close ESM" (using the inverse of the
  17703. * exponential to prevent steep falloff artifacts).
  17704. */
  17705. set useCloseExponentialShadowMap(value: boolean);
  17706. /**
  17707. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17708. * exponential to prevent steep falloff artifacts).
  17709. */
  17710. get useBlurCloseExponentialShadowMap(): boolean;
  17711. /**
  17712. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17713. * exponential to prevent steep falloff artifacts).
  17714. */
  17715. set useBlurCloseExponentialShadowMap(value: boolean);
  17716. /**
  17717. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17718. */
  17719. get usePercentageCloserFiltering(): boolean;
  17720. /**
  17721. * Sets the current filter to "PCF" (percentage closer filtering).
  17722. */
  17723. set usePercentageCloserFiltering(value: boolean);
  17724. protected _filteringQuality: number;
  17725. /**
  17726. * Gets the PCF or PCSS Quality.
  17727. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17728. */
  17729. get filteringQuality(): number;
  17730. /**
  17731. * Sets the PCF or PCSS Quality.
  17732. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17733. */
  17734. set filteringQuality(filteringQuality: number);
  17735. /**
  17736. * Gets if the current filter is set to "PCSS" (contact hardening).
  17737. */
  17738. get useContactHardeningShadow(): boolean;
  17739. /**
  17740. * Sets the current filter to "PCSS" (contact hardening).
  17741. */
  17742. set useContactHardeningShadow(value: boolean);
  17743. protected _contactHardeningLightSizeUVRatio: number;
  17744. /**
  17745. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17746. * Using a ratio helps keeping shape stability independently of the map size.
  17747. *
  17748. * It does not account for the light projection as it was having too much
  17749. * instability during the light setup or during light position changes.
  17750. *
  17751. * Only valid if useContactHardeningShadow is true.
  17752. */
  17753. get contactHardeningLightSizeUVRatio(): number;
  17754. /**
  17755. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17756. * Using a ratio helps keeping shape stability independently of the map size.
  17757. *
  17758. * It does not account for the light projection as it was having too much
  17759. * instability during the light setup or during light position changes.
  17760. *
  17761. * Only valid if useContactHardeningShadow is true.
  17762. */
  17763. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17764. protected _darkness: number;
  17765. /** Gets or sets the actual darkness of a shadow */
  17766. get darkness(): number;
  17767. set darkness(value: number);
  17768. /**
  17769. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17770. * 0 means strongest and 1 would means no shadow.
  17771. * @returns the darkness.
  17772. */
  17773. getDarkness(): number;
  17774. /**
  17775. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17776. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17777. * @returns the shadow generator allowing fluent coding.
  17778. */
  17779. setDarkness(darkness: number): ShadowGenerator;
  17780. protected _transparencyShadow: boolean;
  17781. /** Gets or sets the ability to have transparent shadow */
  17782. get transparencyShadow(): boolean;
  17783. set transparencyShadow(value: boolean);
  17784. /**
  17785. * Sets the ability to have transparent shadow (boolean).
  17786. * @param transparent True if transparent else False
  17787. * @returns the shadow generator allowing fluent coding
  17788. */
  17789. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17790. /**
  17791. * Enables or disables shadows with varying strength based on the transparency
  17792. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17793. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17794. * mesh.visibility * alphaTexture.a
  17795. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17796. */
  17797. enableSoftTransparentShadow: boolean;
  17798. protected _shadowMap: Nullable<RenderTargetTexture>;
  17799. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17800. /**
  17801. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17802. * @returns The render target texture if present otherwise, null
  17803. */
  17804. getShadowMap(): Nullable<RenderTargetTexture>;
  17805. /**
  17806. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17807. * @returns The render target texture if the shadow map is present otherwise, null
  17808. */
  17809. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17810. /**
  17811. * Gets the class name of that object
  17812. * @returns "ShadowGenerator"
  17813. */
  17814. getClassName(): string;
  17815. /**
  17816. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17817. * @param mesh Mesh to add
  17818. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17819. * @returns the Shadow Generator itself
  17820. */
  17821. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17822. /**
  17823. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17824. * @param mesh Mesh to remove
  17825. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17826. * @returns the Shadow Generator itself
  17827. */
  17828. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17829. /**
  17830. * Controls the extent to which the shadows fade out at the edge of the frustum
  17831. */
  17832. frustumEdgeFalloff: number;
  17833. protected _light: IShadowLight;
  17834. /**
  17835. * Returns the associated light object.
  17836. * @returns the light generating the shadow
  17837. */
  17838. getLight(): IShadowLight;
  17839. /**
  17840. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17841. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17842. * It might on the other hand introduce peter panning.
  17843. */
  17844. forceBackFacesOnly: boolean;
  17845. protected _scene: Scene;
  17846. protected _lightDirection: Vector3;
  17847. protected _effect: Effect;
  17848. protected _viewMatrix: Matrix;
  17849. protected _projectionMatrix: Matrix;
  17850. protected _transformMatrix: Matrix;
  17851. protected _cachedPosition: Vector3;
  17852. protected _cachedDirection: Vector3;
  17853. protected _cachedDefines: string;
  17854. protected _currentRenderID: number;
  17855. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17856. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17857. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17858. protected _blurPostProcesses: PostProcess[];
  17859. protected _mapSize: number;
  17860. protected _currentFaceIndex: number;
  17861. protected _currentFaceIndexCache: number;
  17862. protected _textureType: number;
  17863. protected _defaultTextureMatrix: Matrix;
  17864. protected _storedUniqueId: Nullable<number>;
  17865. /** @hidden */
  17866. static _SceneComponentInitialization: (scene: Scene) => void;
  17867. /**
  17868. * Creates a ShadowGenerator object.
  17869. * A ShadowGenerator is the required tool to use the shadows.
  17870. * Each light casting shadows needs to use its own ShadowGenerator.
  17871. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17872. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17873. * @param light The light object generating the shadows.
  17874. * @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.
  17875. */
  17876. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17877. protected _initializeGenerator(): void;
  17878. protected _createTargetRenderTexture(): void;
  17879. protected _initializeShadowMap(): void;
  17880. protected _initializeBlurRTTAndPostProcesses(): void;
  17881. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17882. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17883. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17884. protected _applyFilterValues(): void;
  17885. /**
  17886. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17887. * @param onCompiled Callback triggered at the and of the effects compilation
  17888. * @param options Sets of optional options forcing the compilation with different modes
  17889. */
  17890. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17891. useInstances: boolean;
  17892. }>): void;
  17893. /**
  17894. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17895. * @param options Sets of optional options forcing the compilation with different modes
  17896. * @returns A promise that resolves when the compilation completes
  17897. */
  17898. forceCompilationAsync(options?: Partial<{
  17899. useInstances: boolean;
  17900. }>): Promise<void>;
  17901. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17902. private _prepareShadowDefines;
  17903. /**
  17904. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17905. * @param subMesh The submesh we want to render in the shadow map
  17906. * @param useInstances Defines wether will draw in the map using instances
  17907. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17908. * @returns true if ready otherwise, false
  17909. */
  17910. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17911. /**
  17912. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17913. * @param defines Defines of the material we want to update
  17914. * @param lightIndex Index of the light in the enabled light list of the material
  17915. */
  17916. prepareDefines(defines: any, lightIndex: number): void;
  17917. /**
  17918. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17919. * defined in the generator but impacting the effect).
  17920. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17921. * @param effect The effect we are binfing the information for
  17922. */
  17923. bindShadowLight(lightIndex: string, effect: Effect): void;
  17924. /**
  17925. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17926. * (eq to shadow prjection matrix * light transform matrix)
  17927. * @returns The transform matrix used to create the shadow map
  17928. */
  17929. getTransformMatrix(): Matrix;
  17930. /**
  17931. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17932. * Cube and 2D textures for instance.
  17933. */
  17934. recreateShadowMap(): void;
  17935. protected _disposeBlurPostProcesses(): void;
  17936. protected _disposeRTTandPostProcesses(): void;
  17937. /**
  17938. * Disposes the ShadowGenerator.
  17939. * Returns nothing.
  17940. */
  17941. dispose(): void;
  17942. /**
  17943. * Serializes the shadow generator setup to a json object.
  17944. * @returns The serialized JSON object
  17945. */
  17946. serialize(): any;
  17947. /**
  17948. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17949. * @param parsedShadowGenerator The JSON object to parse
  17950. * @param scene The scene to create the shadow map for
  17951. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17952. * @returns The parsed shadow generator
  17953. */
  17954. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17955. }
  17956. }
  17957. declare module BABYLON {
  17958. /**
  17959. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17960. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17961. * 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.
  17962. */
  17963. export abstract class Light extends Node {
  17964. /**
  17965. * Falloff Default: light is falling off following the material specification:
  17966. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17967. */
  17968. static readonly FALLOFF_DEFAULT: number;
  17969. /**
  17970. * Falloff Physical: light is falling off following the inverse squared distance law.
  17971. */
  17972. static readonly FALLOFF_PHYSICAL: number;
  17973. /**
  17974. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17975. * to enhance interoperability with other engines.
  17976. */
  17977. static readonly FALLOFF_GLTF: number;
  17978. /**
  17979. * Falloff Standard: light is falling off like in the standard material
  17980. * to enhance interoperability with other materials.
  17981. */
  17982. static readonly FALLOFF_STANDARD: number;
  17983. /**
  17984. * If every light affecting the material is in this lightmapMode,
  17985. * material.lightmapTexture adds or multiplies
  17986. * (depends on material.useLightmapAsShadowmap)
  17987. * after every other light calculations.
  17988. */
  17989. static readonly LIGHTMAP_DEFAULT: number;
  17990. /**
  17991. * material.lightmapTexture as only diffuse lighting from this light
  17992. * adds only specular lighting from this light
  17993. * adds dynamic shadows
  17994. */
  17995. static readonly LIGHTMAP_SPECULAR: number;
  17996. /**
  17997. * material.lightmapTexture as only lighting
  17998. * no light calculation from this light
  17999. * only adds dynamic shadows from this light
  18000. */
  18001. static readonly LIGHTMAP_SHADOWSONLY: number;
  18002. /**
  18003. * Each light type uses the default quantity according to its type:
  18004. * point/spot lights use luminous intensity
  18005. * directional lights use illuminance
  18006. */
  18007. static readonly INTENSITYMODE_AUTOMATIC: number;
  18008. /**
  18009. * lumen (lm)
  18010. */
  18011. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18012. /**
  18013. * candela (lm/sr)
  18014. */
  18015. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18016. /**
  18017. * lux (lm/m^2)
  18018. */
  18019. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18020. /**
  18021. * nit (cd/m^2)
  18022. */
  18023. static readonly INTENSITYMODE_LUMINANCE: number;
  18024. /**
  18025. * Light type const id of the point light.
  18026. */
  18027. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18028. /**
  18029. * Light type const id of the directional light.
  18030. */
  18031. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18032. /**
  18033. * Light type const id of the spot light.
  18034. */
  18035. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18036. /**
  18037. * Light type const id of the hemispheric light.
  18038. */
  18039. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18040. /**
  18041. * Diffuse gives the basic color to an object.
  18042. */
  18043. diffuse: Color3;
  18044. /**
  18045. * Specular produces a highlight color on an object.
  18046. * Note: This is note affecting PBR materials.
  18047. */
  18048. specular: Color3;
  18049. /**
  18050. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18051. * falling off base on range or angle.
  18052. * This can be set to any values in Light.FALLOFF_x.
  18053. *
  18054. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18055. * other types of materials.
  18056. */
  18057. falloffType: number;
  18058. /**
  18059. * Strength of the light.
  18060. * Note: By default it is define in the framework own unit.
  18061. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18062. */
  18063. intensity: number;
  18064. private _range;
  18065. protected _inverseSquaredRange: number;
  18066. /**
  18067. * Defines how far from the source the light is impacting in scene units.
  18068. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18069. */
  18070. get range(): number;
  18071. /**
  18072. * Defines how far from the source the light is impacting in scene units.
  18073. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18074. */
  18075. set range(value: number);
  18076. /**
  18077. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18078. * of light.
  18079. */
  18080. private _photometricScale;
  18081. private _intensityMode;
  18082. /**
  18083. * Gets the photometric scale used to interpret the intensity.
  18084. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18085. */
  18086. get intensityMode(): number;
  18087. /**
  18088. * Sets the photometric scale used to interpret the intensity.
  18089. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18090. */
  18091. set intensityMode(value: number);
  18092. private _radius;
  18093. /**
  18094. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18095. */
  18096. get radius(): number;
  18097. /**
  18098. * sets the light radius used by PBR Materials to simulate soft area lights.
  18099. */
  18100. set radius(value: number);
  18101. private _renderPriority;
  18102. /**
  18103. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18104. * exceeding the number allowed of the materials.
  18105. */
  18106. renderPriority: number;
  18107. private _shadowEnabled;
  18108. /**
  18109. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18110. * the current shadow generator.
  18111. */
  18112. get shadowEnabled(): boolean;
  18113. /**
  18114. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18115. * the current shadow generator.
  18116. */
  18117. set shadowEnabled(value: boolean);
  18118. private _includedOnlyMeshes;
  18119. /**
  18120. * Gets the only meshes impacted by this light.
  18121. */
  18122. get includedOnlyMeshes(): AbstractMesh[];
  18123. /**
  18124. * Sets the only meshes impacted by this light.
  18125. */
  18126. set includedOnlyMeshes(value: AbstractMesh[]);
  18127. private _excludedMeshes;
  18128. /**
  18129. * Gets the meshes not impacted by this light.
  18130. */
  18131. get excludedMeshes(): AbstractMesh[];
  18132. /**
  18133. * Sets the meshes not impacted by this light.
  18134. */
  18135. set excludedMeshes(value: AbstractMesh[]);
  18136. private _excludeWithLayerMask;
  18137. /**
  18138. * Gets the layer id use to find what meshes are not impacted by the light.
  18139. * Inactive if 0
  18140. */
  18141. get excludeWithLayerMask(): number;
  18142. /**
  18143. * Sets the layer id use to find what meshes are not impacted by the light.
  18144. * Inactive if 0
  18145. */
  18146. set excludeWithLayerMask(value: number);
  18147. private _includeOnlyWithLayerMask;
  18148. /**
  18149. * Gets the layer id use to find what meshes are impacted by the light.
  18150. * Inactive if 0
  18151. */
  18152. get includeOnlyWithLayerMask(): number;
  18153. /**
  18154. * Sets the layer id use to find what meshes are impacted by the light.
  18155. * Inactive if 0
  18156. */
  18157. set includeOnlyWithLayerMask(value: number);
  18158. private _lightmapMode;
  18159. /**
  18160. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18161. */
  18162. get lightmapMode(): number;
  18163. /**
  18164. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18165. */
  18166. set lightmapMode(value: number);
  18167. /**
  18168. * Shadow generator associted to the light.
  18169. * @hidden Internal use only.
  18170. */
  18171. _shadowGenerator: Nullable<IShadowGenerator>;
  18172. /**
  18173. * @hidden Internal use only.
  18174. */
  18175. _excludedMeshesIds: string[];
  18176. /**
  18177. * @hidden Internal use only.
  18178. */
  18179. _includedOnlyMeshesIds: string[];
  18180. /**
  18181. * The current light unifom buffer.
  18182. * @hidden Internal use only.
  18183. */
  18184. _uniformBuffer: UniformBuffer;
  18185. /** @hidden */
  18186. _renderId: number;
  18187. /**
  18188. * Creates a Light object in the scene.
  18189. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18190. * @param name The firendly name of the light
  18191. * @param scene The scene the light belongs too
  18192. */
  18193. constructor(name: string, scene: Scene);
  18194. protected abstract _buildUniformLayout(): void;
  18195. /**
  18196. * Sets the passed Effect "effect" with the Light information.
  18197. * @param effect The effect to update
  18198. * @param lightIndex The index of the light in the effect to update
  18199. * @returns The light
  18200. */
  18201. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18202. /**
  18203. * Sets the passed Effect "effect" with the Light textures.
  18204. * @param effect The effect to update
  18205. * @param lightIndex The index of the light in the effect to update
  18206. * @returns The light
  18207. */
  18208. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18209. /**
  18210. * Binds the lights information from the scene to the effect for the given mesh.
  18211. * @param lightIndex Light index
  18212. * @param scene The scene where the light belongs to
  18213. * @param effect The effect we are binding the data to
  18214. * @param useSpecular Defines if specular is supported
  18215. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18216. */
  18217. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18218. /**
  18219. * Sets the passed Effect "effect" with the Light information.
  18220. * @param effect The effect to update
  18221. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18222. * @returns The light
  18223. */
  18224. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18225. /**
  18226. * Returns the string "Light".
  18227. * @returns the class name
  18228. */
  18229. getClassName(): string;
  18230. /** @hidden */
  18231. readonly _isLight: boolean;
  18232. /**
  18233. * Converts the light information to a readable string for debug purpose.
  18234. * @param fullDetails Supports for multiple levels of logging within scene loading
  18235. * @returns the human readable light info
  18236. */
  18237. toString(fullDetails?: boolean): string;
  18238. /** @hidden */
  18239. protected _syncParentEnabledState(): void;
  18240. /**
  18241. * Set the enabled state of this node.
  18242. * @param value - the new enabled state
  18243. */
  18244. setEnabled(value: boolean): void;
  18245. /**
  18246. * Returns the Light associated shadow generator if any.
  18247. * @return the associated shadow generator.
  18248. */
  18249. getShadowGenerator(): Nullable<IShadowGenerator>;
  18250. /**
  18251. * Returns a Vector3, the absolute light position in the World.
  18252. * @returns the world space position of the light
  18253. */
  18254. getAbsolutePosition(): Vector3;
  18255. /**
  18256. * Specifies if the light will affect the passed mesh.
  18257. * @param mesh The mesh to test against the light
  18258. * @return true the mesh is affected otherwise, false.
  18259. */
  18260. canAffectMesh(mesh: AbstractMesh): boolean;
  18261. /**
  18262. * Sort function to order lights for rendering.
  18263. * @param a First Light object to compare to second.
  18264. * @param b Second Light object to compare first.
  18265. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18266. */
  18267. static CompareLightsPriority(a: Light, b: Light): number;
  18268. /**
  18269. * Releases resources associated with this node.
  18270. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18271. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18272. */
  18273. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18274. /**
  18275. * Returns the light type ID (integer).
  18276. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18277. */
  18278. getTypeID(): number;
  18279. /**
  18280. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18281. * @returns the scaled intensity in intensity mode unit
  18282. */
  18283. getScaledIntensity(): number;
  18284. /**
  18285. * Returns a new Light object, named "name", from the current one.
  18286. * @param name The name of the cloned light
  18287. * @param newParent The parent of this light, if it has one
  18288. * @returns the new created light
  18289. */
  18290. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18291. /**
  18292. * Serializes the current light into a Serialization object.
  18293. * @returns the serialized object.
  18294. */
  18295. serialize(): any;
  18296. /**
  18297. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18298. * This new light is named "name" and added to the passed scene.
  18299. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18300. * @param name The friendly name of the light
  18301. * @param scene The scene the new light will belong to
  18302. * @returns the constructor function
  18303. */
  18304. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18305. /**
  18306. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18307. * @param parsedLight The JSON representation of the light
  18308. * @param scene The scene to create the parsed light in
  18309. * @returns the created light after parsing
  18310. */
  18311. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18312. private _hookArrayForExcluded;
  18313. private _hookArrayForIncludedOnly;
  18314. private _resyncMeshes;
  18315. /**
  18316. * Forces the meshes to update their light related information in their rendering used effects
  18317. * @hidden Internal Use Only
  18318. */
  18319. _markMeshesAsLightDirty(): void;
  18320. /**
  18321. * Recomputes the cached photometric scale if needed.
  18322. */
  18323. private _computePhotometricScale;
  18324. /**
  18325. * Returns the Photometric Scale according to the light type and intensity mode.
  18326. */
  18327. private _getPhotometricScale;
  18328. /**
  18329. * Reorder the light in the scene according to their defined priority.
  18330. * @hidden Internal Use Only
  18331. */
  18332. _reorderLightsInScene(): void;
  18333. /**
  18334. * Prepares the list of defines specific to the light type.
  18335. * @param defines the list of defines
  18336. * @param lightIndex defines the index of the light for the effect
  18337. */
  18338. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18339. }
  18340. }
  18341. declare module BABYLON {
  18342. /**
  18343. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18344. * This is the base of the follow, arc rotate cameras and Free camera
  18345. * @see https://doc.babylonjs.com/features/cameras
  18346. */
  18347. export class TargetCamera extends Camera {
  18348. private static _RigCamTransformMatrix;
  18349. private static _TargetTransformMatrix;
  18350. private static _TargetFocalPoint;
  18351. private _tmpUpVector;
  18352. private _tmpTargetVector;
  18353. /**
  18354. * Define the current direction the camera is moving to
  18355. */
  18356. cameraDirection: Vector3;
  18357. /**
  18358. * Define the current rotation the camera is rotating to
  18359. */
  18360. cameraRotation: Vector2;
  18361. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18362. ignoreParentScaling: boolean;
  18363. /**
  18364. * When set, the up vector of the camera will be updated by the rotation of the camera
  18365. */
  18366. updateUpVectorFromRotation: boolean;
  18367. private _tmpQuaternion;
  18368. /**
  18369. * Define the current rotation of the camera
  18370. */
  18371. rotation: Vector3;
  18372. /**
  18373. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18374. */
  18375. rotationQuaternion: Quaternion;
  18376. /**
  18377. * Define the current speed of the camera
  18378. */
  18379. speed: number;
  18380. /**
  18381. * Add constraint to the camera to prevent it to move freely in all directions and
  18382. * around all axis.
  18383. */
  18384. noRotationConstraint: boolean;
  18385. /**
  18386. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18387. * panning
  18388. */
  18389. invertRotation: boolean;
  18390. /**
  18391. * Speed multiplier for inverse camera panning
  18392. */
  18393. inverseRotationSpeed: number;
  18394. /**
  18395. * Define the current target of the camera as an object or a position.
  18396. */
  18397. lockedTarget: any;
  18398. /** @hidden */
  18399. _currentTarget: Vector3;
  18400. /** @hidden */
  18401. _initialFocalDistance: number;
  18402. /** @hidden */
  18403. _viewMatrix: Matrix;
  18404. /** @hidden */
  18405. _camMatrix: Matrix;
  18406. /** @hidden */
  18407. _cameraTransformMatrix: Matrix;
  18408. /** @hidden */
  18409. _cameraRotationMatrix: Matrix;
  18410. /** @hidden */
  18411. _referencePoint: Vector3;
  18412. /** @hidden */
  18413. _transformedReferencePoint: Vector3;
  18414. /** @hidden */
  18415. _reset: () => void;
  18416. private _defaultUp;
  18417. /**
  18418. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18419. * This is the base of the follow, arc rotate cameras and Free camera
  18420. * @see https://doc.babylonjs.com/features/cameras
  18421. * @param name Defines the name of the camera in the scene
  18422. * @param position Defines the start position of the camera in the scene
  18423. * @param scene Defines the scene the camera belongs to
  18424. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18425. */
  18426. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18427. /**
  18428. * Gets the position in front of the camera at a given distance.
  18429. * @param distance The distance from the camera we want the position to be
  18430. * @returns the position
  18431. */
  18432. getFrontPosition(distance: number): Vector3;
  18433. /** @hidden */
  18434. _getLockedTargetPosition(): Nullable<Vector3>;
  18435. private _storedPosition;
  18436. private _storedRotation;
  18437. private _storedRotationQuaternion;
  18438. /**
  18439. * Store current camera state of the camera (fov, position, rotation, etc..)
  18440. * @returns the camera
  18441. */
  18442. storeState(): Camera;
  18443. /**
  18444. * Restored camera state. You must call storeState() first
  18445. * @returns whether it was successful or not
  18446. * @hidden
  18447. */
  18448. _restoreStateValues(): boolean;
  18449. /** @hidden */
  18450. _initCache(): void;
  18451. /** @hidden */
  18452. _updateCache(ignoreParentClass?: boolean): void;
  18453. /** @hidden */
  18454. _isSynchronizedViewMatrix(): boolean;
  18455. /** @hidden */
  18456. _computeLocalCameraSpeed(): number;
  18457. /**
  18458. * Defines the target the camera should look at.
  18459. * @param target Defines the new target as a Vector or a mesh
  18460. */
  18461. setTarget(target: Vector3): void;
  18462. /**
  18463. * Defines the target point of the camera.
  18464. * The camera looks towards it form the radius distance.
  18465. */
  18466. get target(): Vector3;
  18467. set target(value: Vector3);
  18468. /**
  18469. * Return the current target position of the camera. This value is expressed in local space.
  18470. * @returns the target position
  18471. */
  18472. getTarget(): Vector3;
  18473. /** @hidden */
  18474. _decideIfNeedsToMove(): boolean;
  18475. /** @hidden */
  18476. _updatePosition(): void;
  18477. /** @hidden */
  18478. _checkInputs(): void;
  18479. protected _updateCameraRotationMatrix(): void;
  18480. /**
  18481. * 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)
  18482. * @returns the current camera
  18483. */
  18484. private _rotateUpVectorWithCameraRotationMatrix;
  18485. private _cachedRotationZ;
  18486. private _cachedQuaternionRotationZ;
  18487. /** @hidden */
  18488. _getViewMatrix(): Matrix;
  18489. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18490. /**
  18491. * @hidden
  18492. */
  18493. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18494. /**
  18495. * @hidden
  18496. */
  18497. _updateRigCameras(): void;
  18498. private _getRigCamPositionAndTarget;
  18499. /**
  18500. * Gets the current object class name.
  18501. * @return the class name
  18502. */
  18503. getClassName(): string;
  18504. }
  18505. }
  18506. declare module BABYLON {
  18507. /**
  18508. * Gather the list of keyboard event types as constants.
  18509. */
  18510. export class KeyboardEventTypes {
  18511. /**
  18512. * The keydown event is fired when a key becomes active (pressed).
  18513. */
  18514. static readonly KEYDOWN: number;
  18515. /**
  18516. * The keyup event is fired when a key has been released.
  18517. */
  18518. static readonly KEYUP: number;
  18519. }
  18520. /**
  18521. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18522. */
  18523. export class KeyboardInfo {
  18524. /**
  18525. * Defines the type of event (KeyboardEventTypes)
  18526. */
  18527. type: number;
  18528. /**
  18529. * Defines the related dom event
  18530. */
  18531. event: KeyboardEvent;
  18532. /**
  18533. * Instantiates a new keyboard info.
  18534. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18535. * @param type Defines the type of event (KeyboardEventTypes)
  18536. * @param event Defines the related dom event
  18537. */
  18538. constructor(
  18539. /**
  18540. * Defines the type of event (KeyboardEventTypes)
  18541. */
  18542. type: number,
  18543. /**
  18544. * Defines the related dom event
  18545. */
  18546. event: KeyboardEvent);
  18547. }
  18548. /**
  18549. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18550. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18551. */
  18552. export class KeyboardInfoPre extends KeyboardInfo {
  18553. /**
  18554. * Defines the type of event (KeyboardEventTypes)
  18555. */
  18556. type: number;
  18557. /**
  18558. * Defines the related dom event
  18559. */
  18560. event: KeyboardEvent;
  18561. /**
  18562. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18563. */
  18564. skipOnPointerObservable: boolean;
  18565. /**
  18566. * Instantiates a new keyboard pre info.
  18567. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18568. * @param type Defines the type of event (KeyboardEventTypes)
  18569. * @param event Defines the related dom event
  18570. */
  18571. constructor(
  18572. /**
  18573. * Defines the type of event (KeyboardEventTypes)
  18574. */
  18575. type: number,
  18576. /**
  18577. * Defines the related dom event
  18578. */
  18579. event: KeyboardEvent);
  18580. }
  18581. }
  18582. declare module BABYLON {
  18583. /**
  18584. * Manage the keyboard inputs to control the movement of a free camera.
  18585. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18586. */
  18587. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18588. /**
  18589. * Defines the camera the input is attached to.
  18590. */
  18591. camera: FreeCamera;
  18592. /**
  18593. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18594. */
  18595. keysUp: number[];
  18596. /**
  18597. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18598. */
  18599. keysUpward: number[];
  18600. /**
  18601. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18602. */
  18603. keysDown: number[];
  18604. /**
  18605. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18606. */
  18607. keysDownward: number[];
  18608. /**
  18609. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18610. */
  18611. keysLeft: number[];
  18612. /**
  18613. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18614. */
  18615. keysRight: number[];
  18616. private _keys;
  18617. private _onCanvasBlurObserver;
  18618. private _onKeyboardObserver;
  18619. private _engine;
  18620. private _scene;
  18621. /**
  18622. * Attach the input controls to a specific dom element to get the input from.
  18623. * @param element Defines the element the controls should be listened from
  18624. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18625. */
  18626. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18627. /**
  18628. * Detach the current controls from the specified dom element.
  18629. * @param element Defines the element to stop listening the inputs from
  18630. */
  18631. detachControl(element: Nullable<HTMLElement>): void;
  18632. /**
  18633. * Update the current camera state depending on the inputs that have been used this frame.
  18634. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18635. */
  18636. checkInputs(): void;
  18637. /**
  18638. * Gets the class name of the current intput.
  18639. * @returns the class name
  18640. */
  18641. getClassName(): string;
  18642. /** @hidden */
  18643. _onLostFocus(): void;
  18644. /**
  18645. * Get the friendly name associated with the input class.
  18646. * @returns the input friendly name
  18647. */
  18648. getSimpleName(): string;
  18649. }
  18650. }
  18651. declare module BABYLON {
  18652. /**
  18653. * Gather the list of pointer event types as constants.
  18654. */
  18655. export class PointerEventTypes {
  18656. /**
  18657. * 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.
  18658. */
  18659. static readonly POINTERDOWN: number;
  18660. /**
  18661. * The pointerup event is fired when a pointer is no longer active.
  18662. */
  18663. static readonly POINTERUP: number;
  18664. /**
  18665. * The pointermove event is fired when a pointer changes coordinates.
  18666. */
  18667. static readonly POINTERMOVE: number;
  18668. /**
  18669. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18670. */
  18671. static readonly POINTERWHEEL: number;
  18672. /**
  18673. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18674. */
  18675. static readonly POINTERPICK: number;
  18676. /**
  18677. * The pointertap event is fired when a the object has been touched and released without drag.
  18678. */
  18679. static readonly POINTERTAP: number;
  18680. /**
  18681. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18682. */
  18683. static readonly POINTERDOUBLETAP: number;
  18684. }
  18685. /**
  18686. * Base class of pointer info types.
  18687. */
  18688. export class PointerInfoBase {
  18689. /**
  18690. * Defines the type of event (PointerEventTypes)
  18691. */
  18692. type: number;
  18693. /**
  18694. * Defines the related dom event
  18695. */
  18696. event: PointerEvent | MouseWheelEvent;
  18697. /**
  18698. * Instantiates the base class of pointers info.
  18699. * @param type Defines the type of event (PointerEventTypes)
  18700. * @param event Defines the related dom event
  18701. */
  18702. constructor(
  18703. /**
  18704. * Defines the type of event (PointerEventTypes)
  18705. */
  18706. type: number,
  18707. /**
  18708. * Defines the related dom event
  18709. */
  18710. event: PointerEvent | MouseWheelEvent);
  18711. }
  18712. /**
  18713. * This class is used to store pointer related info for the onPrePointerObservable event.
  18714. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18715. */
  18716. export class PointerInfoPre extends PointerInfoBase {
  18717. /**
  18718. * Ray from a pointer if availible (eg. 6dof controller)
  18719. */
  18720. ray: Nullable<Ray>;
  18721. /**
  18722. * Defines the local position of the pointer on the canvas.
  18723. */
  18724. localPosition: Vector2;
  18725. /**
  18726. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18727. */
  18728. skipOnPointerObservable: boolean;
  18729. /**
  18730. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18731. * @param type Defines the type of event (PointerEventTypes)
  18732. * @param event Defines the related dom event
  18733. * @param localX Defines the local x coordinates of the pointer when the event occured
  18734. * @param localY Defines the local y coordinates of the pointer when the event occured
  18735. */
  18736. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18737. }
  18738. /**
  18739. * This type contains all the data related to a pointer event in Babylon.js.
  18740. * 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.
  18741. */
  18742. export class PointerInfo extends PointerInfoBase {
  18743. /**
  18744. * Defines the picking info associated to the info (if any)\
  18745. */
  18746. pickInfo: Nullable<PickingInfo>;
  18747. /**
  18748. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18749. * @param type Defines the type of event (PointerEventTypes)
  18750. * @param event Defines the related dom event
  18751. * @param pickInfo Defines the picking info associated to the info (if any)\
  18752. */
  18753. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18754. /**
  18755. * Defines the picking info associated to the info (if any)\
  18756. */
  18757. pickInfo: Nullable<PickingInfo>);
  18758. }
  18759. /**
  18760. * Data relating to a touch event on the screen.
  18761. */
  18762. export interface PointerTouch {
  18763. /**
  18764. * X coordinate of touch.
  18765. */
  18766. x: number;
  18767. /**
  18768. * Y coordinate of touch.
  18769. */
  18770. y: number;
  18771. /**
  18772. * Id of touch. Unique for each finger.
  18773. */
  18774. pointerId: number;
  18775. /**
  18776. * Event type passed from DOM.
  18777. */
  18778. type: any;
  18779. }
  18780. }
  18781. declare module BABYLON {
  18782. /**
  18783. * Manage the mouse inputs to control the movement of a free camera.
  18784. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18785. */
  18786. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18787. /**
  18788. * Define if touch is enabled in the mouse input
  18789. */
  18790. touchEnabled: boolean;
  18791. /**
  18792. * Defines the camera the input is attached to.
  18793. */
  18794. camera: FreeCamera;
  18795. /**
  18796. * Defines the buttons associated with the input to handle camera move.
  18797. */
  18798. buttons: number[];
  18799. /**
  18800. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18801. */
  18802. angularSensibility: number;
  18803. private _pointerInput;
  18804. private _onMouseMove;
  18805. private _observer;
  18806. private previousPosition;
  18807. /**
  18808. * Observable for when a pointer move event occurs containing the move offset
  18809. */
  18810. onPointerMovedObservable: Observable<{
  18811. offsetX: number;
  18812. offsetY: number;
  18813. }>;
  18814. /**
  18815. * @hidden
  18816. * If the camera should be rotated automatically based on pointer movement
  18817. */
  18818. _allowCameraRotation: boolean;
  18819. /**
  18820. * Manage the mouse inputs to control the movement of a free camera.
  18821. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18822. * @param touchEnabled Defines if touch is enabled or not
  18823. */
  18824. constructor(
  18825. /**
  18826. * Define if touch is enabled in the mouse input
  18827. */
  18828. touchEnabled?: boolean);
  18829. /**
  18830. * Attach the input controls to a specific dom element to get the input from.
  18831. * @param element Defines the element the controls should be listened from
  18832. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18833. */
  18834. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18835. /**
  18836. * Called on JS contextmenu event.
  18837. * Override this method to provide functionality.
  18838. */
  18839. protected onContextMenu(evt: PointerEvent): void;
  18840. /**
  18841. * Detach the current controls from the specified dom element.
  18842. * @param element Defines the element to stop listening the inputs from
  18843. */
  18844. detachControl(element: Nullable<HTMLElement>): void;
  18845. /**
  18846. * Gets the class name of the current intput.
  18847. * @returns the class name
  18848. */
  18849. getClassName(): string;
  18850. /**
  18851. * Get the friendly name associated with the input class.
  18852. * @returns the input friendly name
  18853. */
  18854. getSimpleName(): string;
  18855. }
  18856. }
  18857. declare module BABYLON {
  18858. /**
  18859. * Manage the touch inputs to control the movement of a free camera.
  18860. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18861. */
  18862. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18863. /**
  18864. * Defines the camera the input is attached to.
  18865. */
  18866. camera: FreeCamera;
  18867. /**
  18868. * Defines the touch sensibility for rotation.
  18869. * The higher the faster.
  18870. */
  18871. touchAngularSensibility: number;
  18872. /**
  18873. * Defines the touch sensibility for move.
  18874. * The higher the faster.
  18875. */
  18876. touchMoveSensibility: number;
  18877. private _offsetX;
  18878. private _offsetY;
  18879. private _pointerPressed;
  18880. private _pointerInput;
  18881. private _observer;
  18882. private _onLostFocus;
  18883. /**
  18884. * Attach the input controls to a specific dom element to get the input from.
  18885. * @param element Defines the element the controls should be listened from
  18886. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18887. */
  18888. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18889. /**
  18890. * Detach the current controls from the specified dom element.
  18891. * @param element Defines the element to stop listening the inputs from
  18892. */
  18893. detachControl(element: Nullable<HTMLElement>): void;
  18894. /**
  18895. * Update the current camera state depending on the inputs that have been used this frame.
  18896. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18897. */
  18898. checkInputs(): void;
  18899. /**
  18900. * Gets the class name of the current intput.
  18901. * @returns the class name
  18902. */
  18903. getClassName(): string;
  18904. /**
  18905. * Get the friendly name associated with the input class.
  18906. * @returns the input friendly name
  18907. */
  18908. getSimpleName(): string;
  18909. }
  18910. }
  18911. declare module BABYLON {
  18912. /**
  18913. * Default Inputs manager for the FreeCamera.
  18914. * It groups all the default supported inputs for ease of use.
  18915. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18916. */
  18917. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18918. /**
  18919. * @hidden
  18920. */
  18921. _mouseInput: Nullable<FreeCameraMouseInput>;
  18922. /**
  18923. * Instantiates a new FreeCameraInputsManager.
  18924. * @param camera Defines the camera the inputs belong to
  18925. */
  18926. constructor(camera: FreeCamera);
  18927. /**
  18928. * Add keyboard input support to the input manager.
  18929. * @returns the current input manager
  18930. */
  18931. addKeyboard(): FreeCameraInputsManager;
  18932. /**
  18933. * Add mouse input support to the input manager.
  18934. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18935. * @returns the current input manager
  18936. */
  18937. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18938. /**
  18939. * Removes the mouse input support from the manager
  18940. * @returns the current input manager
  18941. */
  18942. removeMouse(): FreeCameraInputsManager;
  18943. /**
  18944. * Add touch input support to the input manager.
  18945. * @returns the current input manager
  18946. */
  18947. addTouch(): FreeCameraInputsManager;
  18948. /**
  18949. * Remove all attached input methods from a camera
  18950. */
  18951. clear(): void;
  18952. }
  18953. }
  18954. declare module BABYLON {
  18955. /**
  18956. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18957. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18958. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  18959. */
  18960. export class FreeCamera extends TargetCamera {
  18961. /**
  18962. * Define the collision ellipsoid of the camera.
  18963. * This is helpful to simulate a camera body like the player body around the camera
  18964. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18965. */
  18966. ellipsoid: Vector3;
  18967. /**
  18968. * Define an offset for the position of the ellipsoid around the camera.
  18969. * This can be helpful to determine the center of the body near the gravity center of the body
  18970. * instead of its head.
  18971. */
  18972. ellipsoidOffset: Vector3;
  18973. /**
  18974. * Enable or disable collisions of the camera with the rest of the scene objects.
  18975. */
  18976. checkCollisions: boolean;
  18977. /**
  18978. * Enable or disable gravity on the camera.
  18979. */
  18980. applyGravity: boolean;
  18981. /**
  18982. * Define the input manager associated to the camera.
  18983. */
  18984. inputs: FreeCameraInputsManager;
  18985. /**
  18986. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18987. * Higher values reduce sensitivity.
  18988. */
  18989. get angularSensibility(): number;
  18990. /**
  18991. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18992. * Higher values reduce sensitivity.
  18993. */
  18994. set angularSensibility(value: number);
  18995. /**
  18996. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18997. */
  18998. get keysUp(): number[];
  18999. set keysUp(value: number[]);
  19000. /**
  19001. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19002. */
  19003. get keysUpward(): number[];
  19004. set keysUpward(value: number[]);
  19005. /**
  19006. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19007. */
  19008. get keysDown(): number[];
  19009. set keysDown(value: number[]);
  19010. /**
  19011. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19012. */
  19013. get keysDownward(): number[];
  19014. set keysDownward(value: number[]);
  19015. /**
  19016. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19017. */
  19018. get keysLeft(): number[];
  19019. set keysLeft(value: number[]);
  19020. /**
  19021. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19022. */
  19023. get keysRight(): number[];
  19024. set keysRight(value: number[]);
  19025. /**
  19026. * Event raised when the camera collide with a mesh in the scene.
  19027. */
  19028. onCollide: (collidedMesh: AbstractMesh) => void;
  19029. private _collider;
  19030. private _needMoveForGravity;
  19031. private _oldPosition;
  19032. private _diffPosition;
  19033. private _newPosition;
  19034. /** @hidden */
  19035. _localDirection: Vector3;
  19036. /** @hidden */
  19037. _transformedDirection: Vector3;
  19038. /**
  19039. * Instantiates a Free Camera.
  19040. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19041. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19042. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19043. * @param name Define the name of the camera in the scene
  19044. * @param position Define the start position of the camera in the scene
  19045. * @param scene Define the scene the camera belongs to
  19046. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19047. */
  19048. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19049. /**
  19050. * Attached controls to the current camera.
  19051. * @param element Defines the element the controls should be listened from
  19052. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19053. */
  19054. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19055. /**
  19056. * Detach the current controls from the camera.
  19057. * The camera will stop reacting to inputs.
  19058. * @param element Defines the element to stop listening the inputs from
  19059. */
  19060. detachControl(element: HTMLElement): void;
  19061. private _collisionMask;
  19062. /**
  19063. * Define a collision mask to limit the list of object the camera can collide with
  19064. */
  19065. get collisionMask(): number;
  19066. set collisionMask(mask: number);
  19067. /** @hidden */
  19068. _collideWithWorld(displacement: Vector3): void;
  19069. private _onCollisionPositionChange;
  19070. /** @hidden */
  19071. _checkInputs(): void;
  19072. /** @hidden */
  19073. _decideIfNeedsToMove(): boolean;
  19074. /** @hidden */
  19075. _updatePosition(): void;
  19076. /**
  19077. * Destroy the camera and release the current resources hold by it.
  19078. */
  19079. dispose(): void;
  19080. /**
  19081. * Gets the current object class name.
  19082. * @return the class name
  19083. */
  19084. getClassName(): string;
  19085. }
  19086. }
  19087. declare module BABYLON {
  19088. /**
  19089. * Represents a gamepad control stick position
  19090. */
  19091. export class StickValues {
  19092. /**
  19093. * The x component of the control stick
  19094. */
  19095. x: number;
  19096. /**
  19097. * The y component of the control stick
  19098. */
  19099. y: number;
  19100. /**
  19101. * Initializes the gamepad x and y control stick values
  19102. * @param x The x component of the gamepad control stick value
  19103. * @param y The y component of the gamepad control stick value
  19104. */
  19105. constructor(
  19106. /**
  19107. * The x component of the control stick
  19108. */
  19109. x: number,
  19110. /**
  19111. * The y component of the control stick
  19112. */
  19113. y: number);
  19114. }
  19115. /**
  19116. * An interface which manages callbacks for gamepad button changes
  19117. */
  19118. export interface GamepadButtonChanges {
  19119. /**
  19120. * Called when a gamepad has been changed
  19121. */
  19122. changed: boolean;
  19123. /**
  19124. * Called when a gamepad press event has been triggered
  19125. */
  19126. pressChanged: boolean;
  19127. /**
  19128. * Called when a touch event has been triggered
  19129. */
  19130. touchChanged: boolean;
  19131. /**
  19132. * Called when a value has changed
  19133. */
  19134. valueChanged: boolean;
  19135. }
  19136. /**
  19137. * Represents a gamepad
  19138. */
  19139. export class Gamepad {
  19140. /**
  19141. * The id of the gamepad
  19142. */
  19143. id: string;
  19144. /**
  19145. * The index of the gamepad
  19146. */
  19147. index: number;
  19148. /**
  19149. * The browser gamepad
  19150. */
  19151. browserGamepad: any;
  19152. /**
  19153. * Specifies what type of gamepad this represents
  19154. */
  19155. type: number;
  19156. private _leftStick;
  19157. private _rightStick;
  19158. /** @hidden */
  19159. _isConnected: boolean;
  19160. private _leftStickAxisX;
  19161. private _leftStickAxisY;
  19162. private _rightStickAxisX;
  19163. private _rightStickAxisY;
  19164. /**
  19165. * Triggered when the left control stick has been changed
  19166. */
  19167. private _onleftstickchanged;
  19168. /**
  19169. * Triggered when the right control stick has been changed
  19170. */
  19171. private _onrightstickchanged;
  19172. /**
  19173. * Represents a gamepad controller
  19174. */
  19175. static GAMEPAD: number;
  19176. /**
  19177. * Represents a generic controller
  19178. */
  19179. static GENERIC: number;
  19180. /**
  19181. * Represents an XBox controller
  19182. */
  19183. static XBOX: number;
  19184. /**
  19185. * Represents a pose-enabled controller
  19186. */
  19187. static POSE_ENABLED: number;
  19188. /**
  19189. * Represents an Dual Shock controller
  19190. */
  19191. static DUALSHOCK: number;
  19192. /**
  19193. * Specifies whether the left control stick should be Y-inverted
  19194. */
  19195. protected _invertLeftStickY: boolean;
  19196. /**
  19197. * Specifies if the gamepad has been connected
  19198. */
  19199. get isConnected(): boolean;
  19200. /**
  19201. * Initializes the gamepad
  19202. * @param id The id of the gamepad
  19203. * @param index The index of the gamepad
  19204. * @param browserGamepad The browser gamepad
  19205. * @param leftStickX The x component of the left joystick
  19206. * @param leftStickY The y component of the left joystick
  19207. * @param rightStickX The x component of the right joystick
  19208. * @param rightStickY The y component of the right joystick
  19209. */
  19210. constructor(
  19211. /**
  19212. * The id of the gamepad
  19213. */
  19214. id: string,
  19215. /**
  19216. * The index of the gamepad
  19217. */
  19218. index: number,
  19219. /**
  19220. * The browser gamepad
  19221. */
  19222. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19223. /**
  19224. * Callback triggered when the left joystick has changed
  19225. * @param callback
  19226. */
  19227. onleftstickchanged(callback: (values: StickValues) => void): void;
  19228. /**
  19229. * Callback triggered when the right joystick has changed
  19230. * @param callback
  19231. */
  19232. onrightstickchanged(callback: (values: StickValues) => void): void;
  19233. /**
  19234. * Gets the left joystick
  19235. */
  19236. get leftStick(): StickValues;
  19237. /**
  19238. * Sets the left joystick values
  19239. */
  19240. set leftStick(newValues: StickValues);
  19241. /**
  19242. * Gets the right joystick
  19243. */
  19244. get rightStick(): StickValues;
  19245. /**
  19246. * Sets the right joystick value
  19247. */
  19248. set rightStick(newValues: StickValues);
  19249. /**
  19250. * Updates the gamepad joystick positions
  19251. */
  19252. update(): void;
  19253. /**
  19254. * Disposes the gamepad
  19255. */
  19256. dispose(): void;
  19257. }
  19258. /**
  19259. * Represents a generic gamepad
  19260. */
  19261. export class GenericPad extends Gamepad {
  19262. private _buttons;
  19263. private _onbuttondown;
  19264. private _onbuttonup;
  19265. /**
  19266. * Observable triggered when a button has been pressed
  19267. */
  19268. onButtonDownObservable: Observable<number>;
  19269. /**
  19270. * Observable triggered when a button has been released
  19271. */
  19272. onButtonUpObservable: Observable<number>;
  19273. /**
  19274. * Callback triggered when a button has been pressed
  19275. * @param callback Called when a button has been pressed
  19276. */
  19277. onbuttondown(callback: (buttonPressed: number) => void): void;
  19278. /**
  19279. * Callback triggered when a button has been released
  19280. * @param callback Called when a button has been released
  19281. */
  19282. onbuttonup(callback: (buttonReleased: number) => void): void;
  19283. /**
  19284. * Initializes the generic gamepad
  19285. * @param id The id of the generic gamepad
  19286. * @param index The index of the generic gamepad
  19287. * @param browserGamepad The browser gamepad
  19288. */
  19289. constructor(id: string, index: number, browserGamepad: any);
  19290. private _setButtonValue;
  19291. /**
  19292. * Updates the generic gamepad
  19293. */
  19294. update(): void;
  19295. /**
  19296. * Disposes the generic gamepad
  19297. */
  19298. dispose(): void;
  19299. }
  19300. }
  19301. declare module BABYLON {
  19302. /**
  19303. * Defines the types of pose enabled controllers that are supported
  19304. */
  19305. export enum PoseEnabledControllerType {
  19306. /**
  19307. * HTC Vive
  19308. */
  19309. VIVE = 0,
  19310. /**
  19311. * Oculus Rift
  19312. */
  19313. OCULUS = 1,
  19314. /**
  19315. * Windows mixed reality
  19316. */
  19317. WINDOWS = 2,
  19318. /**
  19319. * Samsung gear VR
  19320. */
  19321. GEAR_VR = 3,
  19322. /**
  19323. * Google Daydream
  19324. */
  19325. DAYDREAM = 4,
  19326. /**
  19327. * Generic
  19328. */
  19329. GENERIC = 5
  19330. }
  19331. /**
  19332. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19333. */
  19334. export interface MutableGamepadButton {
  19335. /**
  19336. * Value of the button/trigger
  19337. */
  19338. value: number;
  19339. /**
  19340. * If the button/trigger is currently touched
  19341. */
  19342. touched: boolean;
  19343. /**
  19344. * If the button/trigger is currently pressed
  19345. */
  19346. pressed: boolean;
  19347. }
  19348. /**
  19349. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19350. * @hidden
  19351. */
  19352. export interface ExtendedGamepadButton extends GamepadButton {
  19353. /**
  19354. * If the button/trigger is currently pressed
  19355. */
  19356. readonly pressed: boolean;
  19357. /**
  19358. * If the button/trigger is currently touched
  19359. */
  19360. readonly touched: boolean;
  19361. /**
  19362. * Value of the button/trigger
  19363. */
  19364. readonly value: number;
  19365. }
  19366. /** @hidden */
  19367. export interface _GamePadFactory {
  19368. /**
  19369. * Returns whether or not the current gamepad can be created for this type of controller.
  19370. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19371. * @returns true if it can be created, otherwise false
  19372. */
  19373. canCreate(gamepadInfo: any): boolean;
  19374. /**
  19375. * Creates a new instance of the Gamepad.
  19376. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19377. * @returns the new gamepad instance
  19378. */
  19379. create(gamepadInfo: any): Gamepad;
  19380. }
  19381. /**
  19382. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19383. */
  19384. export class PoseEnabledControllerHelper {
  19385. /** @hidden */
  19386. static _ControllerFactories: _GamePadFactory[];
  19387. /** @hidden */
  19388. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19389. /**
  19390. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19391. * @param vrGamepad the gamepad to initialized
  19392. * @returns a vr controller of the type the gamepad identified as
  19393. */
  19394. static InitiateController(vrGamepad: any): Gamepad;
  19395. }
  19396. /**
  19397. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19398. */
  19399. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19400. /**
  19401. * If the controller is used in a webXR session
  19402. */
  19403. isXR: boolean;
  19404. private _deviceRoomPosition;
  19405. private _deviceRoomRotationQuaternion;
  19406. /**
  19407. * The device position in babylon space
  19408. */
  19409. devicePosition: Vector3;
  19410. /**
  19411. * The device rotation in babylon space
  19412. */
  19413. deviceRotationQuaternion: Quaternion;
  19414. /**
  19415. * The scale factor of the device in babylon space
  19416. */
  19417. deviceScaleFactor: number;
  19418. /**
  19419. * (Likely devicePosition should be used instead) The device position in its room space
  19420. */
  19421. position: Vector3;
  19422. /**
  19423. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19424. */
  19425. rotationQuaternion: Quaternion;
  19426. /**
  19427. * The type of controller (Eg. Windows mixed reality)
  19428. */
  19429. controllerType: PoseEnabledControllerType;
  19430. protected _calculatedPosition: Vector3;
  19431. private _calculatedRotation;
  19432. /**
  19433. * The raw pose from the device
  19434. */
  19435. rawPose: DevicePose;
  19436. private _trackPosition;
  19437. private _maxRotationDistFromHeadset;
  19438. private _draggedRoomRotation;
  19439. /**
  19440. * @hidden
  19441. */
  19442. _disableTrackPosition(fixedPosition: Vector3): void;
  19443. /**
  19444. * Internal, the mesh attached to the controller
  19445. * @hidden
  19446. */
  19447. _mesh: Nullable<AbstractMesh>;
  19448. private _poseControlledCamera;
  19449. private _leftHandSystemQuaternion;
  19450. /**
  19451. * Internal, matrix used to convert room space to babylon space
  19452. * @hidden
  19453. */
  19454. _deviceToWorld: Matrix;
  19455. /**
  19456. * Node to be used when casting a ray from the controller
  19457. * @hidden
  19458. */
  19459. _pointingPoseNode: Nullable<TransformNode>;
  19460. /**
  19461. * Name of the child mesh that can be used to cast a ray from the controller
  19462. */
  19463. static readonly POINTING_POSE: string;
  19464. /**
  19465. * Creates a new PoseEnabledController from a gamepad
  19466. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19467. */
  19468. constructor(browserGamepad: any);
  19469. private _workingMatrix;
  19470. /**
  19471. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19472. */
  19473. update(): void;
  19474. /**
  19475. * Updates only the pose device and mesh without doing any button event checking
  19476. */
  19477. protected _updatePoseAndMesh(): void;
  19478. /**
  19479. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19480. * @param poseData raw pose fromthe device
  19481. */
  19482. updateFromDevice(poseData: DevicePose): void;
  19483. /**
  19484. * @hidden
  19485. */
  19486. _meshAttachedObservable: Observable<AbstractMesh>;
  19487. /**
  19488. * Attaches a mesh to the controller
  19489. * @param mesh the mesh to be attached
  19490. */
  19491. attachToMesh(mesh: AbstractMesh): void;
  19492. /**
  19493. * Attaches the controllers mesh to a camera
  19494. * @param camera the camera the mesh should be attached to
  19495. */
  19496. attachToPoseControlledCamera(camera: TargetCamera): void;
  19497. /**
  19498. * Disposes of the controller
  19499. */
  19500. dispose(): void;
  19501. /**
  19502. * The mesh that is attached to the controller
  19503. */
  19504. get mesh(): Nullable<AbstractMesh>;
  19505. /**
  19506. * Gets the ray of the controller in the direction the controller is pointing
  19507. * @param length the length the resulting ray should be
  19508. * @returns a ray in the direction the controller is pointing
  19509. */
  19510. getForwardRay(length?: number): Ray;
  19511. }
  19512. }
  19513. declare module BABYLON {
  19514. /**
  19515. * Defines the WebVRController object that represents controllers tracked in 3D space
  19516. */
  19517. export abstract class WebVRController extends PoseEnabledController {
  19518. /**
  19519. * Internal, the default controller model for the controller
  19520. */
  19521. protected _defaultModel: Nullable<AbstractMesh>;
  19522. /**
  19523. * Fired when the trigger state has changed
  19524. */
  19525. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19526. /**
  19527. * Fired when the main button state has changed
  19528. */
  19529. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19530. /**
  19531. * Fired when the secondary button state has changed
  19532. */
  19533. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19534. /**
  19535. * Fired when the pad state has changed
  19536. */
  19537. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19538. /**
  19539. * Fired when controllers stick values have changed
  19540. */
  19541. onPadValuesChangedObservable: Observable<StickValues>;
  19542. /**
  19543. * Array of button availible on the controller
  19544. */
  19545. protected _buttons: Array<MutableGamepadButton>;
  19546. private _onButtonStateChange;
  19547. /**
  19548. * Fired when a controller button's state has changed
  19549. * @param callback the callback containing the button that was modified
  19550. */
  19551. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19552. /**
  19553. * X and Y axis corresponding to the controllers joystick
  19554. */
  19555. pad: StickValues;
  19556. /**
  19557. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19558. */
  19559. hand: string;
  19560. /**
  19561. * The default controller model for the controller
  19562. */
  19563. get defaultModel(): Nullable<AbstractMesh>;
  19564. /**
  19565. * Creates a new WebVRController from a gamepad
  19566. * @param vrGamepad the gamepad that the WebVRController should be created from
  19567. */
  19568. constructor(vrGamepad: any);
  19569. /**
  19570. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19571. */
  19572. update(): void;
  19573. /**
  19574. * Function to be called when a button is modified
  19575. */
  19576. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19577. /**
  19578. * Loads a mesh and attaches it to the controller
  19579. * @param scene the scene the mesh should be added to
  19580. * @param meshLoaded callback for when the mesh has been loaded
  19581. */
  19582. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19583. private _setButtonValue;
  19584. private _changes;
  19585. private _checkChanges;
  19586. /**
  19587. * Disposes of th webVRCOntroller
  19588. */
  19589. dispose(): void;
  19590. }
  19591. }
  19592. declare module BABYLON {
  19593. /**
  19594. * The HemisphericLight simulates the ambient environment light,
  19595. * so the passed direction is the light reflection direction, not the incoming direction.
  19596. */
  19597. export class HemisphericLight extends Light {
  19598. /**
  19599. * The groundColor is the light in the opposite direction to the one specified during creation.
  19600. * 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.
  19601. */
  19602. groundColor: Color3;
  19603. /**
  19604. * The light reflection direction, not the incoming direction.
  19605. */
  19606. direction: Vector3;
  19607. /**
  19608. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19609. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19610. * The HemisphericLight can't cast shadows.
  19611. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19612. * @param name The friendly name of the light
  19613. * @param direction The direction of the light reflection
  19614. * @param scene The scene the light belongs to
  19615. */
  19616. constructor(name: string, direction: Vector3, scene: Scene);
  19617. protected _buildUniformLayout(): void;
  19618. /**
  19619. * Returns the string "HemisphericLight".
  19620. * @return The class name
  19621. */
  19622. getClassName(): string;
  19623. /**
  19624. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19625. * Returns the updated direction.
  19626. * @param target The target the direction should point to
  19627. * @return The computed direction
  19628. */
  19629. setDirectionToTarget(target: Vector3): Vector3;
  19630. /**
  19631. * Returns the shadow generator associated to the light.
  19632. * @returns Always null for hemispheric lights because it does not support shadows.
  19633. */
  19634. getShadowGenerator(): Nullable<IShadowGenerator>;
  19635. /**
  19636. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19637. * @param effect The effect to update
  19638. * @param lightIndex The index of the light in the effect to update
  19639. * @returns The hemispheric light
  19640. */
  19641. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19642. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19643. /**
  19644. * Computes the world matrix of the node
  19645. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19646. * @param useWasUpdatedFlag defines a reserved property
  19647. * @returns the world matrix
  19648. */
  19649. computeWorldMatrix(): Matrix;
  19650. /**
  19651. * Returns the integer 3.
  19652. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19653. */
  19654. getTypeID(): number;
  19655. /**
  19656. * Prepares the list of defines specific to the light type.
  19657. * @param defines the list of defines
  19658. * @param lightIndex defines the index of the light for the effect
  19659. */
  19660. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19661. }
  19662. }
  19663. declare module BABYLON {
  19664. /** @hidden */
  19665. export var vrMultiviewToSingleviewPixelShader: {
  19666. name: string;
  19667. shader: string;
  19668. };
  19669. }
  19670. declare module BABYLON {
  19671. /**
  19672. * Renders to multiple views with a single draw call
  19673. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19674. */
  19675. export class MultiviewRenderTarget extends RenderTargetTexture {
  19676. /**
  19677. * Creates a multiview render target
  19678. * @param scene scene used with the render target
  19679. * @param size the size of the render target (used for each view)
  19680. */
  19681. constructor(scene: Scene, size?: number | {
  19682. width: number;
  19683. height: number;
  19684. } | {
  19685. ratio: number;
  19686. });
  19687. /**
  19688. * @hidden
  19689. * @param faceIndex the face index, if its a cube texture
  19690. */
  19691. _bindFrameBuffer(faceIndex?: number): void;
  19692. /**
  19693. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19694. * @returns the view count
  19695. */
  19696. getViewCount(): number;
  19697. }
  19698. }
  19699. declare module BABYLON {
  19700. interface Engine {
  19701. /**
  19702. * Creates a new multiview render target
  19703. * @param width defines the width of the texture
  19704. * @param height defines the height of the texture
  19705. * @returns the created multiview texture
  19706. */
  19707. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19708. /**
  19709. * Binds a multiview framebuffer to be drawn to
  19710. * @param multiviewTexture texture to bind
  19711. */
  19712. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19713. }
  19714. interface Camera {
  19715. /**
  19716. * @hidden
  19717. * 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)
  19718. */
  19719. _useMultiviewToSingleView: boolean;
  19720. /**
  19721. * @hidden
  19722. * 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)
  19723. */
  19724. _multiviewTexture: Nullable<RenderTargetTexture>;
  19725. /**
  19726. * @hidden
  19727. * ensures the multiview texture of the camera exists and has the specified width/height
  19728. * @param width height to set on the multiview texture
  19729. * @param height width to set on the multiview texture
  19730. */
  19731. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19732. }
  19733. interface Scene {
  19734. /** @hidden */
  19735. _transformMatrixR: Matrix;
  19736. /** @hidden */
  19737. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19738. /** @hidden */
  19739. _createMultiviewUbo(): void;
  19740. /** @hidden */
  19741. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19742. /** @hidden */
  19743. _renderMultiviewToSingleView(camera: Camera): void;
  19744. }
  19745. }
  19746. declare module BABYLON {
  19747. /**
  19748. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19749. * This will not be used for webXR as it supports displaying texture arrays directly
  19750. */
  19751. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19752. /**
  19753. * Gets a string identifying the name of the class
  19754. * @returns "VRMultiviewToSingleviewPostProcess" string
  19755. */
  19756. getClassName(): string;
  19757. /**
  19758. * Initializes a VRMultiviewToSingleview
  19759. * @param name name of the post process
  19760. * @param camera camera to be applied to
  19761. * @param scaleFactor scaling factor to the size of the output texture
  19762. */
  19763. constructor(name: string, camera: Camera, scaleFactor: number);
  19764. }
  19765. }
  19766. declare module BABYLON {
  19767. /**
  19768. * Interface used to define additional presentation attributes
  19769. */
  19770. export interface IVRPresentationAttributes {
  19771. /**
  19772. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19773. */
  19774. highRefreshRate: boolean;
  19775. /**
  19776. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19777. */
  19778. foveationLevel: number;
  19779. }
  19780. interface Engine {
  19781. /** @hidden */
  19782. _vrDisplay: any;
  19783. /** @hidden */
  19784. _vrSupported: boolean;
  19785. /** @hidden */
  19786. _oldSize: Size;
  19787. /** @hidden */
  19788. _oldHardwareScaleFactor: number;
  19789. /** @hidden */
  19790. _vrExclusivePointerMode: boolean;
  19791. /** @hidden */
  19792. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19793. /** @hidden */
  19794. _onVRDisplayPointerRestricted: () => void;
  19795. /** @hidden */
  19796. _onVRDisplayPointerUnrestricted: () => void;
  19797. /** @hidden */
  19798. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19799. /** @hidden */
  19800. _onVrDisplayDisconnect: Nullable<() => void>;
  19801. /** @hidden */
  19802. _onVrDisplayPresentChange: Nullable<() => void>;
  19803. /**
  19804. * Observable signaled when VR display mode changes
  19805. */
  19806. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19807. /**
  19808. * Observable signaled when VR request present is complete
  19809. */
  19810. onVRRequestPresentComplete: Observable<boolean>;
  19811. /**
  19812. * Observable signaled when VR request present starts
  19813. */
  19814. onVRRequestPresentStart: Observable<Engine>;
  19815. /**
  19816. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19817. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19818. */
  19819. isInVRExclusivePointerMode: boolean;
  19820. /**
  19821. * Gets a boolean indicating if a webVR device was detected
  19822. * @returns true if a webVR device was detected
  19823. */
  19824. isVRDevicePresent(): boolean;
  19825. /**
  19826. * Gets the current webVR device
  19827. * @returns the current webVR device (or null)
  19828. */
  19829. getVRDevice(): any;
  19830. /**
  19831. * Initializes a webVR display and starts listening to display change events
  19832. * The onVRDisplayChangedObservable will be notified upon these changes
  19833. * @returns A promise containing a VRDisplay and if vr is supported
  19834. */
  19835. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19836. /** @hidden */
  19837. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19838. /**
  19839. * Gets or sets the presentation attributes used to configure VR rendering
  19840. */
  19841. vrPresentationAttributes?: IVRPresentationAttributes;
  19842. /**
  19843. * Call this function to switch to webVR mode
  19844. * Will do nothing if webVR is not supported or if there is no webVR device
  19845. * @param options the webvr options provided to the camera. mainly used for multiview
  19846. * @see https://doc.babylonjs.com/how_to/webvr_camera
  19847. */
  19848. enableVR(options: WebVROptions): void;
  19849. /** @hidden */
  19850. _onVRFullScreenTriggered(): void;
  19851. }
  19852. }
  19853. declare module BABYLON {
  19854. /**
  19855. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19856. * IMPORTANT!! The data is right-hand data.
  19857. * @export
  19858. * @interface DevicePose
  19859. */
  19860. export interface DevicePose {
  19861. /**
  19862. * The position of the device, values in array are [x,y,z].
  19863. */
  19864. readonly position: Nullable<Float32Array>;
  19865. /**
  19866. * The linearVelocity of the device, values in array are [x,y,z].
  19867. */
  19868. readonly linearVelocity: Nullable<Float32Array>;
  19869. /**
  19870. * The linearAcceleration of the device, values in array are [x,y,z].
  19871. */
  19872. readonly linearAcceleration: Nullable<Float32Array>;
  19873. /**
  19874. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19875. */
  19876. readonly orientation: Nullable<Float32Array>;
  19877. /**
  19878. * The angularVelocity of the device, values in array are [x,y,z].
  19879. */
  19880. readonly angularVelocity: Nullable<Float32Array>;
  19881. /**
  19882. * The angularAcceleration of the device, values in array are [x,y,z].
  19883. */
  19884. readonly angularAcceleration: Nullable<Float32Array>;
  19885. }
  19886. /**
  19887. * Interface representing a pose controlled object in Babylon.
  19888. * A pose controlled object has both regular pose values as well as pose values
  19889. * from an external device such as a VR head mounted display
  19890. */
  19891. export interface PoseControlled {
  19892. /**
  19893. * The position of the object in babylon space.
  19894. */
  19895. position: Vector3;
  19896. /**
  19897. * The rotation quaternion of the object in babylon space.
  19898. */
  19899. rotationQuaternion: Quaternion;
  19900. /**
  19901. * The position of the device in babylon space.
  19902. */
  19903. devicePosition?: Vector3;
  19904. /**
  19905. * The rotation quaternion of the device in babylon space.
  19906. */
  19907. deviceRotationQuaternion: Quaternion;
  19908. /**
  19909. * The raw pose coming from the device.
  19910. */
  19911. rawPose: Nullable<DevicePose>;
  19912. /**
  19913. * The scale of the device to be used when translating from device space to babylon space.
  19914. */
  19915. deviceScaleFactor: number;
  19916. /**
  19917. * Updates the poseControlled values based on the input device pose.
  19918. * @param poseData the pose data to update the object with
  19919. */
  19920. updateFromDevice(poseData: DevicePose): void;
  19921. }
  19922. /**
  19923. * Set of options to customize the webVRCamera
  19924. */
  19925. export interface WebVROptions {
  19926. /**
  19927. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19928. */
  19929. trackPosition?: boolean;
  19930. /**
  19931. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19932. */
  19933. positionScale?: number;
  19934. /**
  19935. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19936. */
  19937. displayName?: string;
  19938. /**
  19939. * Should the native controller meshes be initialized. (default: true)
  19940. */
  19941. controllerMeshes?: boolean;
  19942. /**
  19943. * Creating a default HemiLight only on controllers. (default: true)
  19944. */
  19945. defaultLightingOnControllers?: boolean;
  19946. /**
  19947. * If you don't want to use the default VR button of the helper. (default: false)
  19948. */
  19949. useCustomVRButton?: boolean;
  19950. /**
  19951. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19952. */
  19953. customVRButton?: HTMLButtonElement;
  19954. /**
  19955. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19956. */
  19957. rayLength?: number;
  19958. /**
  19959. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19960. */
  19961. defaultHeight?: number;
  19962. /**
  19963. * If multiview should be used if availible (default: false)
  19964. */
  19965. useMultiview?: boolean;
  19966. }
  19967. /**
  19968. * This represents a WebVR camera.
  19969. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19970. * @example https://doc.babylonjs.com/how_to/webvr_camera
  19971. */
  19972. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19973. private webVROptions;
  19974. /**
  19975. * @hidden
  19976. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19977. */
  19978. _vrDevice: any;
  19979. /**
  19980. * The rawPose of the vrDevice.
  19981. */
  19982. rawPose: Nullable<DevicePose>;
  19983. private _onVREnabled;
  19984. private _specsVersion;
  19985. private _attached;
  19986. private _frameData;
  19987. protected _descendants: Array<Node>;
  19988. private _deviceRoomPosition;
  19989. /** @hidden */
  19990. _deviceRoomRotationQuaternion: Quaternion;
  19991. private _standingMatrix;
  19992. /**
  19993. * Represents device position in babylon space.
  19994. */
  19995. devicePosition: Vector3;
  19996. /**
  19997. * Represents device rotation in babylon space.
  19998. */
  19999. deviceRotationQuaternion: Quaternion;
  20000. /**
  20001. * The scale of the device to be used when translating from device space to babylon space.
  20002. */
  20003. deviceScaleFactor: number;
  20004. private _deviceToWorld;
  20005. private _worldToDevice;
  20006. /**
  20007. * References to the webVR controllers for the vrDevice.
  20008. */
  20009. controllers: Array<WebVRController>;
  20010. /**
  20011. * Emits an event when a controller is attached.
  20012. */
  20013. onControllersAttachedObservable: Observable<WebVRController[]>;
  20014. /**
  20015. * Emits an event when a controller's mesh has been loaded;
  20016. */
  20017. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20018. /**
  20019. * Emits an event when the HMD's pose has been updated.
  20020. */
  20021. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20022. private _poseSet;
  20023. /**
  20024. * If the rig cameras be used as parent instead of this camera.
  20025. */
  20026. rigParenting: boolean;
  20027. private _lightOnControllers;
  20028. private _defaultHeight?;
  20029. /**
  20030. * Instantiates a WebVRFreeCamera.
  20031. * @param name The name of the WebVRFreeCamera
  20032. * @param position The starting anchor position for the camera
  20033. * @param scene The scene the camera belongs to
  20034. * @param webVROptions a set of customizable options for the webVRCamera
  20035. */
  20036. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20037. /**
  20038. * Gets the device distance from the ground in meters.
  20039. * @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.
  20040. */
  20041. deviceDistanceToRoomGround(): number;
  20042. /**
  20043. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20044. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20045. */
  20046. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20047. /**
  20048. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20049. * @returns A promise with a boolean set to if the standing matrix is supported.
  20050. */
  20051. useStandingMatrixAsync(): Promise<boolean>;
  20052. /**
  20053. * Disposes the camera
  20054. */
  20055. dispose(): void;
  20056. /**
  20057. * Gets a vrController by name.
  20058. * @param name The name of the controller to retreive
  20059. * @returns the controller matching the name specified or null if not found
  20060. */
  20061. getControllerByName(name: string): Nullable<WebVRController>;
  20062. private _leftController;
  20063. /**
  20064. * The controller corresponding to the users left hand.
  20065. */
  20066. get leftController(): Nullable<WebVRController>;
  20067. private _rightController;
  20068. /**
  20069. * The controller corresponding to the users right hand.
  20070. */
  20071. get rightController(): Nullable<WebVRController>;
  20072. /**
  20073. * Casts a ray forward from the vrCamera's gaze.
  20074. * @param length Length of the ray (default: 100)
  20075. * @returns the ray corresponding to the gaze
  20076. */
  20077. getForwardRay(length?: number): Ray;
  20078. /**
  20079. * @hidden
  20080. * Updates the camera based on device's frame data
  20081. */
  20082. _checkInputs(): void;
  20083. /**
  20084. * Updates the poseControlled values based on the input device pose.
  20085. * @param poseData Pose coming from the device
  20086. */
  20087. updateFromDevice(poseData: DevicePose): void;
  20088. private _htmlElementAttached;
  20089. private _detachIfAttached;
  20090. /**
  20091. * WebVR's attach control will start broadcasting frames to the device.
  20092. * Note that in certain browsers (chrome for example) this function must be called
  20093. * within a user-interaction callback. Example:
  20094. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20095. *
  20096. * @param element html element to attach the vrDevice to
  20097. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20098. */
  20099. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20100. /**
  20101. * Detaches the camera from the html element and disables VR
  20102. *
  20103. * @param element html element to detach from
  20104. */
  20105. detachControl(element: HTMLElement): void;
  20106. /**
  20107. * @returns the name of this class
  20108. */
  20109. getClassName(): string;
  20110. /**
  20111. * Calls resetPose on the vrDisplay
  20112. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20113. */
  20114. resetToCurrentRotation(): void;
  20115. /**
  20116. * @hidden
  20117. * Updates the rig cameras (left and right eye)
  20118. */
  20119. _updateRigCameras(): void;
  20120. private _workingVector;
  20121. private _oneVector;
  20122. private _workingMatrix;
  20123. private updateCacheCalled;
  20124. private _correctPositionIfNotTrackPosition;
  20125. /**
  20126. * @hidden
  20127. * Updates the cached values of the camera
  20128. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20129. */
  20130. _updateCache(ignoreParentClass?: boolean): void;
  20131. /**
  20132. * @hidden
  20133. * Get current device position in babylon world
  20134. */
  20135. _computeDevicePosition(): void;
  20136. /**
  20137. * Updates the current device position and rotation in the babylon world
  20138. */
  20139. update(): void;
  20140. /**
  20141. * @hidden
  20142. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20143. * @returns an identity matrix
  20144. */
  20145. _getViewMatrix(): Matrix;
  20146. private _tmpMatrix;
  20147. /**
  20148. * This function is called by the two RIG cameras.
  20149. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20150. * @hidden
  20151. */
  20152. _getWebVRViewMatrix(): Matrix;
  20153. /** @hidden */
  20154. _getWebVRProjectionMatrix(): Matrix;
  20155. private _onGamepadConnectedObserver;
  20156. private _onGamepadDisconnectedObserver;
  20157. private _updateCacheWhenTrackingDisabledObserver;
  20158. /**
  20159. * Initializes the controllers and their meshes
  20160. */
  20161. initControllers(): void;
  20162. }
  20163. }
  20164. declare module BABYLON {
  20165. /**
  20166. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20167. *
  20168. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20169. *
  20170. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20171. */
  20172. export class MaterialHelper {
  20173. /**
  20174. * Bind the current view position to an effect.
  20175. * @param effect The effect to be bound
  20176. * @param scene The scene the eyes position is used from
  20177. * @param variableName name of the shader variable that will hold the eye position
  20178. */
  20179. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20180. /**
  20181. * Helps preparing the defines values about the UVs in used in the effect.
  20182. * UVs are shared as much as we can accross channels in the shaders.
  20183. * @param texture The texture we are preparing the UVs for
  20184. * @param defines The defines to update
  20185. * @param key The channel key "diffuse", "specular"... used in the shader
  20186. */
  20187. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20188. /**
  20189. * Binds a texture matrix value to its corrsponding uniform
  20190. * @param texture The texture to bind the matrix for
  20191. * @param uniformBuffer The uniform buffer receivin the data
  20192. * @param key The channel key "diffuse", "specular"... used in the shader
  20193. */
  20194. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20195. /**
  20196. * Gets the current status of the fog (should it be enabled?)
  20197. * @param mesh defines the mesh to evaluate for fog support
  20198. * @param scene defines the hosting scene
  20199. * @returns true if fog must be enabled
  20200. */
  20201. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20202. /**
  20203. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20204. * @param mesh defines the current mesh
  20205. * @param scene defines the current scene
  20206. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20207. * @param pointsCloud defines if point cloud rendering has to be turned on
  20208. * @param fogEnabled defines if fog has to be turned on
  20209. * @param alphaTest defines if alpha testing has to be turned on
  20210. * @param defines defines the current list of defines
  20211. */
  20212. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20213. /**
  20214. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20215. * @param scene defines the current scene
  20216. * @param engine defines the current engine
  20217. * @param defines specifies the list of active defines
  20218. * @param useInstances defines if instances have to be turned on
  20219. * @param useClipPlane defines if clip plane have to be turned on
  20220. * @param useInstances defines if instances have to be turned on
  20221. * @param useThinInstances defines if thin instances have to be turned on
  20222. */
  20223. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20224. /**
  20225. * Prepares the defines for bones
  20226. * @param mesh The mesh containing the geometry data we will draw
  20227. * @param defines The defines to update
  20228. */
  20229. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20230. /**
  20231. * Prepares the defines for morph targets
  20232. * @param mesh The mesh containing the geometry data we will draw
  20233. * @param defines The defines to update
  20234. */
  20235. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20236. /**
  20237. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20238. * @param mesh The mesh containing the geometry data we will draw
  20239. * @param defines The defines to update
  20240. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20241. * @param useBones Precise whether bones should be used or not (override mesh info)
  20242. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20243. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20244. * @returns false if defines are considered not dirty and have not been checked
  20245. */
  20246. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20247. /**
  20248. * Prepares the defines related to multiview
  20249. * @param scene The scene we are intending to draw
  20250. * @param defines The defines to update
  20251. */
  20252. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20253. /**
  20254. * Prepares the defines related to the prepass
  20255. * @param scene The scene we are intending to draw
  20256. * @param defines The defines to update
  20257. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20258. */
  20259. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20260. /**
  20261. * Prepares the defines related to the light information passed in parameter
  20262. * @param scene The scene we are intending to draw
  20263. * @param mesh The mesh the effect is compiling for
  20264. * @param light The light the effect is compiling for
  20265. * @param lightIndex The index of the light
  20266. * @param defines The defines to update
  20267. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20268. * @param state Defines the current state regarding what is needed (normals, etc...)
  20269. */
  20270. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20271. needNormals: boolean;
  20272. needRebuild: boolean;
  20273. shadowEnabled: boolean;
  20274. specularEnabled: boolean;
  20275. lightmapMode: boolean;
  20276. }): void;
  20277. /**
  20278. * Prepares the defines related to the light information passed in parameter
  20279. * @param scene The scene we are intending to draw
  20280. * @param mesh The mesh the effect is compiling for
  20281. * @param defines The defines to update
  20282. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20283. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20284. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20285. * @returns true if normals will be required for the rest of the effect
  20286. */
  20287. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20288. /**
  20289. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20290. * @param lightIndex defines the light index
  20291. * @param uniformsList The uniform list
  20292. * @param samplersList The sampler list
  20293. * @param projectedLightTexture defines if projected texture must be used
  20294. * @param uniformBuffersList defines an optional list of uniform buffers
  20295. */
  20296. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20297. /**
  20298. * Prepares the uniforms and samplers list to be used in the effect
  20299. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20300. * @param samplersList The sampler list
  20301. * @param defines The defines helping in the list generation
  20302. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20303. */
  20304. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20305. /**
  20306. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20307. * @param defines The defines to update while falling back
  20308. * @param fallbacks The authorized effect fallbacks
  20309. * @param maxSimultaneousLights The maximum number of lights allowed
  20310. * @param rank the current rank of the Effect
  20311. * @returns The newly affected rank
  20312. */
  20313. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20314. private static _TmpMorphInfluencers;
  20315. /**
  20316. * Prepares the list of attributes required for morph targets according to the effect defines.
  20317. * @param attribs The current list of supported attribs
  20318. * @param mesh The mesh to prepare the morph targets attributes for
  20319. * @param influencers The number of influencers
  20320. */
  20321. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20322. /**
  20323. * Prepares the list of attributes required for morph targets according to the effect defines.
  20324. * @param attribs The current list of supported attribs
  20325. * @param mesh The mesh to prepare the morph targets attributes for
  20326. * @param defines The current Defines of the effect
  20327. */
  20328. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20329. /**
  20330. * Prepares the list of attributes required for bones according to the effect defines.
  20331. * @param attribs The current list of supported attribs
  20332. * @param mesh The mesh to prepare the bones attributes for
  20333. * @param defines The current Defines of the effect
  20334. * @param fallbacks The current efffect fallback strategy
  20335. */
  20336. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20337. /**
  20338. * Check and prepare the list of attributes required for instances according to the effect defines.
  20339. * @param attribs The current list of supported attribs
  20340. * @param defines The current MaterialDefines of the effect
  20341. */
  20342. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20343. /**
  20344. * Add the list of attributes required for instances to the attribs array.
  20345. * @param attribs The current list of supported attribs
  20346. */
  20347. static PushAttributesForInstances(attribs: string[]): void;
  20348. /**
  20349. * Binds the light information to the effect.
  20350. * @param light The light containing the generator
  20351. * @param effect The effect we are binding the data to
  20352. * @param lightIndex The light index in the effect used to render
  20353. */
  20354. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20355. /**
  20356. * Binds the lights information from the scene to the effect for the given mesh.
  20357. * @param light Light to bind
  20358. * @param lightIndex Light index
  20359. * @param scene The scene where the light belongs to
  20360. * @param effect The effect we are binding the data to
  20361. * @param useSpecular Defines if specular is supported
  20362. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20363. */
  20364. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20365. /**
  20366. * Binds the lights information from the scene to the effect for the given mesh.
  20367. * @param scene The scene the lights belongs to
  20368. * @param mesh The mesh we are binding the information to render
  20369. * @param effect The effect we are binding the data to
  20370. * @param defines The generated defines for the effect
  20371. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20372. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20373. */
  20374. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20375. private static _tempFogColor;
  20376. /**
  20377. * Binds the fog information from the scene to the effect for the given mesh.
  20378. * @param scene The scene the lights belongs to
  20379. * @param mesh The mesh we are binding the information to render
  20380. * @param effect The effect we are binding the data to
  20381. * @param linearSpace Defines if the fog effect is applied in linear space
  20382. */
  20383. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20384. /**
  20385. * Binds the bones information from the mesh to the effect.
  20386. * @param mesh The mesh we are binding the information to render
  20387. * @param effect The effect we are binding the data to
  20388. */
  20389. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20390. /**
  20391. * Binds the morph targets information from the mesh to the effect.
  20392. * @param abstractMesh The mesh we are binding the information to render
  20393. * @param effect The effect we are binding the data to
  20394. */
  20395. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20396. /**
  20397. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20398. * @param defines The generated defines used in the effect
  20399. * @param effect The effect we are binding the data to
  20400. * @param scene The scene we are willing to render with logarithmic scale for
  20401. */
  20402. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20403. /**
  20404. * Binds the clip plane information from the scene to the effect.
  20405. * @param scene The scene the clip plane information are extracted from
  20406. * @param effect The effect we are binding the data to
  20407. */
  20408. static BindClipPlane(effect: Effect, scene: Scene): void;
  20409. }
  20410. }
  20411. declare module BABYLON {
  20412. /**
  20413. * Block used to expose an input value
  20414. */
  20415. export class InputBlock extends NodeMaterialBlock {
  20416. private _mode;
  20417. private _associatedVariableName;
  20418. private _storedValue;
  20419. private _valueCallback;
  20420. private _type;
  20421. private _animationType;
  20422. /** Gets or set a value used to limit the range of float values */
  20423. min: number;
  20424. /** Gets or set a value used to limit the range of float values */
  20425. max: number;
  20426. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20427. isBoolean: boolean;
  20428. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20429. matrixMode: number;
  20430. /** @hidden */
  20431. _systemValue: Nullable<NodeMaterialSystemValues>;
  20432. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20433. visibleInInspector: boolean;
  20434. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20435. isConstant: boolean;
  20436. /** Gets or sets the group to use to display this block in the Inspector */
  20437. groupInInspector: string;
  20438. /** Gets an observable raised when the value is changed */
  20439. onValueChangedObservable: Observable<InputBlock>;
  20440. /**
  20441. * Gets or sets the connection point type (default is float)
  20442. */
  20443. get type(): NodeMaterialBlockConnectionPointTypes;
  20444. /**
  20445. * Creates a new InputBlock
  20446. * @param name defines the block name
  20447. * @param target defines the target of that block (Vertex by default)
  20448. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20449. */
  20450. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20451. /**
  20452. * Validates if a name is a reserve word.
  20453. * @param newName the new name to be given to the node.
  20454. * @returns false if the name is a reserve word, else true.
  20455. */
  20456. validateBlockName(newName: string): boolean;
  20457. /**
  20458. * Gets the output component
  20459. */
  20460. get output(): NodeMaterialConnectionPoint;
  20461. /**
  20462. * Set the source of this connection point to a vertex attribute
  20463. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20464. * @returns the current connection point
  20465. */
  20466. setAsAttribute(attributeName?: string): InputBlock;
  20467. /**
  20468. * Set the source of this connection point to a system value
  20469. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20470. * @returns the current connection point
  20471. */
  20472. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20473. /**
  20474. * Gets or sets the value of that point.
  20475. * Please note that this value will be ignored if valueCallback is defined
  20476. */
  20477. get value(): any;
  20478. set value(value: any);
  20479. /**
  20480. * Gets or sets a callback used to get the value of that point.
  20481. * Please note that setting this value will force the connection point to ignore the value property
  20482. */
  20483. get valueCallback(): () => any;
  20484. set valueCallback(value: () => any);
  20485. /**
  20486. * Gets or sets the associated variable name in the shader
  20487. */
  20488. get associatedVariableName(): string;
  20489. set associatedVariableName(value: string);
  20490. /** Gets or sets the type of animation applied to the input */
  20491. get animationType(): AnimatedInputBlockTypes;
  20492. set animationType(value: AnimatedInputBlockTypes);
  20493. /**
  20494. * Gets a boolean indicating that this connection point not defined yet
  20495. */
  20496. get isUndefined(): boolean;
  20497. /**
  20498. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20499. * In this case the connection point name must be the name of the uniform to use.
  20500. * Can only be set on inputs
  20501. */
  20502. get isUniform(): boolean;
  20503. set isUniform(value: boolean);
  20504. /**
  20505. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20506. * In this case the connection point name must be the name of the attribute to use
  20507. * Can only be set on inputs
  20508. */
  20509. get isAttribute(): boolean;
  20510. set isAttribute(value: boolean);
  20511. /**
  20512. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20513. * Can only be set on exit points
  20514. */
  20515. get isVarying(): boolean;
  20516. set isVarying(value: boolean);
  20517. /**
  20518. * Gets a boolean indicating that the current connection point is a system value
  20519. */
  20520. get isSystemValue(): boolean;
  20521. /**
  20522. * Gets or sets the current well known value or null if not defined as a system value
  20523. */
  20524. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20525. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20526. /**
  20527. * Gets the current class name
  20528. * @returns the class name
  20529. */
  20530. getClassName(): string;
  20531. /**
  20532. * Animate the input if animationType !== None
  20533. * @param scene defines the rendering scene
  20534. */
  20535. animate(scene: Scene): void;
  20536. private _emitDefine;
  20537. initialize(state: NodeMaterialBuildState): void;
  20538. /**
  20539. * Set the input block to its default value (based on its type)
  20540. */
  20541. setDefaultValue(): void;
  20542. private _emitConstant;
  20543. /** @hidden */
  20544. get _noContextSwitch(): boolean;
  20545. private _emit;
  20546. /** @hidden */
  20547. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20548. /** @hidden */
  20549. _transmit(effect: Effect, scene: Scene): void;
  20550. protected _buildBlock(state: NodeMaterialBuildState): void;
  20551. protected _dumpPropertiesCode(): string;
  20552. dispose(): void;
  20553. serialize(): any;
  20554. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20555. }
  20556. }
  20557. declare module BABYLON {
  20558. /**
  20559. * Enum used to define the compatibility state between two connection points
  20560. */
  20561. export enum NodeMaterialConnectionPointCompatibilityStates {
  20562. /** Points are compatibles */
  20563. Compatible = 0,
  20564. /** Points are incompatible because of their types */
  20565. TypeIncompatible = 1,
  20566. /** Points are incompatible because of their targets (vertex vs fragment) */
  20567. TargetIncompatible = 2
  20568. }
  20569. /**
  20570. * Defines the direction of a connection point
  20571. */
  20572. export enum NodeMaterialConnectionPointDirection {
  20573. /** Input */
  20574. Input = 0,
  20575. /** Output */
  20576. Output = 1
  20577. }
  20578. /**
  20579. * Defines a connection point for a block
  20580. */
  20581. export class NodeMaterialConnectionPoint {
  20582. /** @hidden */
  20583. _ownerBlock: NodeMaterialBlock;
  20584. /** @hidden */
  20585. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20586. private _endpoints;
  20587. private _associatedVariableName;
  20588. private _direction;
  20589. /** @hidden */
  20590. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20591. /** @hidden */
  20592. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20593. private _type;
  20594. /** @hidden */
  20595. _enforceAssociatedVariableName: boolean;
  20596. /** Gets the direction of the point */
  20597. get direction(): NodeMaterialConnectionPointDirection;
  20598. /** Indicates that this connection point needs dual validation before being connected to another point */
  20599. needDualDirectionValidation: boolean;
  20600. /**
  20601. * Gets or sets the additional types supported by this connection point
  20602. */
  20603. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20604. /**
  20605. * Gets or sets the additional types excluded by this connection point
  20606. */
  20607. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20608. /**
  20609. * Observable triggered when this point is connected
  20610. */
  20611. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20612. /**
  20613. * Gets or sets the associated variable name in the shader
  20614. */
  20615. get associatedVariableName(): string;
  20616. set associatedVariableName(value: string);
  20617. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20618. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20619. /**
  20620. * Gets or sets the connection point type (default is float)
  20621. */
  20622. get type(): NodeMaterialBlockConnectionPointTypes;
  20623. set type(value: NodeMaterialBlockConnectionPointTypes);
  20624. /**
  20625. * Gets or sets the connection point name
  20626. */
  20627. name: string;
  20628. /**
  20629. * Gets or sets the connection point name
  20630. */
  20631. displayName: string;
  20632. /**
  20633. * Gets or sets a boolean indicating that this connection point can be omitted
  20634. */
  20635. isOptional: boolean;
  20636. /**
  20637. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20638. */
  20639. isExposedOnFrame: boolean;
  20640. /**
  20641. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20642. */
  20643. define: string;
  20644. /** @hidden */
  20645. _prioritizeVertex: boolean;
  20646. private _target;
  20647. /** Gets or sets the target of that connection point */
  20648. get target(): NodeMaterialBlockTargets;
  20649. set target(value: NodeMaterialBlockTargets);
  20650. /**
  20651. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20652. */
  20653. get isConnected(): boolean;
  20654. /**
  20655. * Gets a boolean indicating that the current point is connected to an input block
  20656. */
  20657. get isConnectedToInputBlock(): boolean;
  20658. /**
  20659. * Gets a the connected input block (if any)
  20660. */
  20661. get connectInputBlock(): Nullable<InputBlock>;
  20662. /** Get the other side of the connection (if any) */
  20663. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20664. /** Get the block that owns this connection point */
  20665. get ownerBlock(): NodeMaterialBlock;
  20666. /** Get the block connected on the other side of this connection (if any) */
  20667. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20668. /** Get the block connected on the endpoints of this connection (if any) */
  20669. get connectedBlocks(): Array<NodeMaterialBlock>;
  20670. /** Gets the list of connected endpoints */
  20671. get endpoints(): NodeMaterialConnectionPoint[];
  20672. /** Gets a boolean indicating if that output point is connected to at least one input */
  20673. get hasEndpoints(): boolean;
  20674. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20675. get isConnectedInVertexShader(): boolean;
  20676. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20677. get isConnectedInFragmentShader(): boolean;
  20678. /**
  20679. * Creates a block suitable to be used as an input for this input point.
  20680. * If null is returned, a block based on the point type will be created.
  20681. * @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
  20682. */
  20683. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20684. /**
  20685. * Creates a new connection point
  20686. * @param name defines the connection point name
  20687. * @param ownerBlock defines the block hosting this connection point
  20688. * @param direction defines the direction of the connection point
  20689. */
  20690. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20691. /**
  20692. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20693. * @returns the class name
  20694. */
  20695. getClassName(): string;
  20696. /**
  20697. * Gets a boolean indicating if the current point can be connected to another point
  20698. * @param connectionPoint defines the other connection point
  20699. * @returns a boolean
  20700. */
  20701. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20702. /**
  20703. * Gets a number indicating if the current point can be connected to another point
  20704. * @param connectionPoint defines the other connection point
  20705. * @returns a number defining the compatibility state
  20706. */
  20707. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20708. /**
  20709. * Connect this point to another connection point
  20710. * @param connectionPoint defines the other connection point
  20711. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20712. * @returns the current connection point
  20713. */
  20714. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20715. /**
  20716. * Disconnect this point from one of his endpoint
  20717. * @param endpoint defines the other connection point
  20718. * @returns the current connection point
  20719. */
  20720. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20721. /**
  20722. * Serializes this point in a JSON representation
  20723. * @param isInput defines if the connection point is an input (default is true)
  20724. * @returns the serialized point object
  20725. */
  20726. serialize(isInput?: boolean): any;
  20727. /**
  20728. * Release resources
  20729. */
  20730. dispose(): void;
  20731. }
  20732. }
  20733. declare module BABYLON {
  20734. /**
  20735. * Enum used to define the material modes
  20736. */
  20737. export enum NodeMaterialModes {
  20738. /** Regular material */
  20739. Material = 0,
  20740. /** For post process */
  20741. PostProcess = 1,
  20742. /** For particle system */
  20743. Particle = 2
  20744. }
  20745. }
  20746. declare module BABYLON {
  20747. /**
  20748. * Block used to read a texture from a sampler
  20749. */
  20750. export class TextureBlock extends NodeMaterialBlock {
  20751. private _defineName;
  20752. private _linearDefineName;
  20753. private _gammaDefineName;
  20754. private _tempTextureRead;
  20755. private _samplerName;
  20756. private _transformedUVName;
  20757. private _textureTransformName;
  20758. private _textureInfoName;
  20759. private _mainUVName;
  20760. private _mainUVDefineName;
  20761. private _fragmentOnly;
  20762. /**
  20763. * Gets or sets the texture associated with the node
  20764. */
  20765. texture: Nullable<Texture>;
  20766. /**
  20767. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20768. */
  20769. convertToGammaSpace: boolean;
  20770. /**
  20771. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20772. */
  20773. convertToLinearSpace: boolean;
  20774. /**
  20775. * Create a new TextureBlock
  20776. * @param name defines the block name
  20777. */
  20778. constructor(name: string, fragmentOnly?: boolean);
  20779. /**
  20780. * Gets the current class name
  20781. * @returns the class name
  20782. */
  20783. getClassName(): string;
  20784. /**
  20785. * Gets the uv input component
  20786. */
  20787. get uv(): NodeMaterialConnectionPoint;
  20788. /**
  20789. * Gets the rgba output component
  20790. */
  20791. get rgba(): NodeMaterialConnectionPoint;
  20792. /**
  20793. * Gets the rgb output component
  20794. */
  20795. get rgb(): NodeMaterialConnectionPoint;
  20796. /**
  20797. * Gets the r output component
  20798. */
  20799. get r(): NodeMaterialConnectionPoint;
  20800. /**
  20801. * Gets the g output component
  20802. */
  20803. get g(): NodeMaterialConnectionPoint;
  20804. /**
  20805. * Gets the b output component
  20806. */
  20807. get b(): NodeMaterialConnectionPoint;
  20808. /**
  20809. * Gets the a output component
  20810. */
  20811. get a(): NodeMaterialConnectionPoint;
  20812. get target(): NodeMaterialBlockTargets;
  20813. autoConfigure(material: NodeMaterial): void;
  20814. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20815. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20816. isReady(): boolean;
  20817. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20818. private get _isMixed();
  20819. private _injectVertexCode;
  20820. private _writeTextureRead;
  20821. private _writeOutput;
  20822. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20823. protected _dumpPropertiesCode(): string;
  20824. serialize(): any;
  20825. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20826. }
  20827. }
  20828. declare module BABYLON {
  20829. /** @hidden */
  20830. export var reflectionFunction: {
  20831. name: string;
  20832. shader: string;
  20833. };
  20834. }
  20835. declare module BABYLON {
  20836. /**
  20837. * Base block used to read a reflection texture from a sampler
  20838. */
  20839. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20840. /** @hidden */
  20841. _define3DName: string;
  20842. /** @hidden */
  20843. _defineCubicName: string;
  20844. /** @hidden */
  20845. _defineExplicitName: string;
  20846. /** @hidden */
  20847. _defineProjectionName: string;
  20848. /** @hidden */
  20849. _defineLocalCubicName: string;
  20850. /** @hidden */
  20851. _defineSphericalName: string;
  20852. /** @hidden */
  20853. _definePlanarName: string;
  20854. /** @hidden */
  20855. _defineEquirectangularName: string;
  20856. /** @hidden */
  20857. _defineMirroredEquirectangularFixedName: string;
  20858. /** @hidden */
  20859. _defineEquirectangularFixedName: string;
  20860. /** @hidden */
  20861. _defineSkyboxName: string;
  20862. /** @hidden */
  20863. _defineOppositeZ: string;
  20864. /** @hidden */
  20865. _cubeSamplerName: string;
  20866. /** @hidden */
  20867. _2DSamplerName: string;
  20868. protected _positionUVWName: string;
  20869. protected _directionWName: string;
  20870. protected _reflectionVectorName: string;
  20871. /** @hidden */
  20872. _reflectionCoordsName: string;
  20873. /** @hidden */
  20874. _reflectionMatrixName: string;
  20875. protected _reflectionColorName: string;
  20876. /**
  20877. * Gets or sets the texture associated with the node
  20878. */
  20879. texture: Nullable<BaseTexture>;
  20880. /**
  20881. * Create a new ReflectionTextureBaseBlock
  20882. * @param name defines the block name
  20883. */
  20884. constructor(name: string);
  20885. /**
  20886. * Gets the current class name
  20887. * @returns the class name
  20888. */
  20889. getClassName(): string;
  20890. /**
  20891. * Gets the world position input component
  20892. */
  20893. abstract get position(): NodeMaterialConnectionPoint;
  20894. /**
  20895. * Gets the world position input component
  20896. */
  20897. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20898. /**
  20899. * Gets the world normal input component
  20900. */
  20901. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20902. /**
  20903. * Gets the world input component
  20904. */
  20905. abstract get world(): NodeMaterialConnectionPoint;
  20906. /**
  20907. * Gets the camera (or eye) position component
  20908. */
  20909. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20910. /**
  20911. * Gets the view input component
  20912. */
  20913. abstract get view(): NodeMaterialConnectionPoint;
  20914. protected _getTexture(): Nullable<BaseTexture>;
  20915. autoConfigure(material: NodeMaterial): void;
  20916. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20917. isReady(): boolean;
  20918. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20919. /**
  20920. * Gets the code to inject in the vertex shader
  20921. * @param state current state of the node material building
  20922. * @returns the shader code
  20923. */
  20924. handleVertexSide(state: NodeMaterialBuildState): string;
  20925. /**
  20926. * Handles the inits for the fragment code path
  20927. * @param state node material build state
  20928. */
  20929. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20930. /**
  20931. * Generates the reflection coords code for the fragment code path
  20932. * @param worldNormalVarName name of the world normal variable
  20933. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20934. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20935. * @returns the shader code
  20936. */
  20937. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20938. /**
  20939. * Generates the reflection color code for the fragment code path
  20940. * @param lodVarName name of the lod variable
  20941. * @param swizzleLookupTexture swizzle to use for the final color variable
  20942. * @returns the shader code
  20943. */
  20944. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20945. /**
  20946. * Generates the code corresponding to the connected output points
  20947. * @param state node material build state
  20948. * @param varName name of the variable to output
  20949. * @returns the shader code
  20950. */
  20951. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20952. protected _buildBlock(state: NodeMaterialBuildState): this;
  20953. protected _dumpPropertiesCode(): string;
  20954. serialize(): any;
  20955. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20956. }
  20957. }
  20958. declare module BABYLON {
  20959. /**
  20960. * Defines a connection point to be used for points with a custom object type
  20961. */
  20962. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20963. private _blockType;
  20964. private _blockName;
  20965. private _nameForCheking?;
  20966. /**
  20967. * Creates a new connection point
  20968. * @param name defines the connection point name
  20969. * @param ownerBlock defines the block hosting this connection point
  20970. * @param direction defines the direction of the connection point
  20971. */
  20972. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20973. /**
  20974. * Gets a number indicating if the current point can be connected to another point
  20975. * @param connectionPoint defines the other connection point
  20976. * @returns a number defining the compatibility state
  20977. */
  20978. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20979. /**
  20980. * Creates a block suitable to be used as an input for this input point.
  20981. * If null is returned, a block based on the point type will be created.
  20982. * @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
  20983. */
  20984. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20985. }
  20986. }
  20987. declare module BABYLON {
  20988. /**
  20989. * Enum defining the type of properties that can be edited in the property pages in the NME
  20990. */
  20991. export enum PropertyTypeForEdition {
  20992. /** property is a boolean */
  20993. Boolean = 0,
  20994. /** property is a float */
  20995. Float = 1,
  20996. /** property is a Vector2 */
  20997. Vector2 = 2,
  20998. /** property is a list of values */
  20999. List = 3
  21000. }
  21001. /**
  21002. * Interface that defines an option in a variable of type list
  21003. */
  21004. export interface IEditablePropertyListOption {
  21005. /** label of the option */
  21006. "label": string;
  21007. /** value of the option */
  21008. "value": number;
  21009. }
  21010. /**
  21011. * Interface that defines the options available for an editable property
  21012. */
  21013. export interface IEditablePropertyOption {
  21014. /** min value */
  21015. "min"?: number;
  21016. /** max value */
  21017. "max"?: number;
  21018. /** notifiers: indicates which actions to take when the property is changed */
  21019. "notifiers"?: {
  21020. /** the material should be rebuilt */
  21021. "rebuild"?: boolean;
  21022. /** the preview should be updated */
  21023. "update"?: boolean;
  21024. };
  21025. /** list of the options for a variable of type list */
  21026. "options"?: IEditablePropertyListOption[];
  21027. }
  21028. /**
  21029. * Interface that describes an editable property
  21030. */
  21031. export interface IPropertyDescriptionForEdition {
  21032. /** name of the property */
  21033. "propertyName": string;
  21034. /** display name of the property */
  21035. "displayName": string;
  21036. /** type of the property */
  21037. "type": PropertyTypeForEdition;
  21038. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21039. "groupName": string;
  21040. /** options for the property */
  21041. "options": IEditablePropertyOption;
  21042. }
  21043. /**
  21044. * Decorator that flags a property in a node material block as being editable
  21045. */
  21046. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21047. }
  21048. declare module BABYLON {
  21049. /**
  21050. * Block used to implement the refraction part of the sub surface module of the PBR material
  21051. */
  21052. export class RefractionBlock extends NodeMaterialBlock {
  21053. /** @hidden */
  21054. _define3DName: string;
  21055. /** @hidden */
  21056. _refractionMatrixName: string;
  21057. /** @hidden */
  21058. _defineLODRefractionAlpha: string;
  21059. /** @hidden */
  21060. _defineLinearSpecularRefraction: string;
  21061. /** @hidden */
  21062. _defineOppositeZ: string;
  21063. /** @hidden */
  21064. _cubeSamplerName: string;
  21065. /** @hidden */
  21066. _2DSamplerName: string;
  21067. /** @hidden */
  21068. _vRefractionMicrosurfaceInfosName: string;
  21069. /** @hidden */
  21070. _vRefractionInfosName: string;
  21071. private _scene;
  21072. /**
  21073. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21074. * Materials half opaque for instance using refraction could benefit from this control.
  21075. */
  21076. linkRefractionWithTransparency: boolean;
  21077. /**
  21078. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21079. */
  21080. invertRefractionY: boolean;
  21081. /**
  21082. * Gets or sets the texture associated with the node
  21083. */
  21084. texture: Nullable<BaseTexture>;
  21085. /**
  21086. * Create a new RefractionBlock
  21087. * @param name defines the block name
  21088. */
  21089. constructor(name: string);
  21090. /**
  21091. * Gets the current class name
  21092. * @returns the class name
  21093. */
  21094. getClassName(): string;
  21095. /**
  21096. * Gets the intensity input component
  21097. */
  21098. get intensity(): NodeMaterialConnectionPoint;
  21099. /**
  21100. * Gets the index of refraction input component
  21101. */
  21102. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21103. /**
  21104. * Gets the tint at distance input component
  21105. */
  21106. get tintAtDistance(): NodeMaterialConnectionPoint;
  21107. /**
  21108. * Gets the view input component
  21109. */
  21110. get view(): NodeMaterialConnectionPoint;
  21111. /**
  21112. * Gets the refraction object output component
  21113. */
  21114. get refraction(): NodeMaterialConnectionPoint;
  21115. /**
  21116. * Returns true if the block has a texture
  21117. */
  21118. get hasTexture(): boolean;
  21119. protected _getTexture(): Nullable<BaseTexture>;
  21120. autoConfigure(material: NodeMaterial): void;
  21121. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21122. isReady(): boolean;
  21123. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21124. /**
  21125. * Gets the main code of the block (fragment side)
  21126. * @param state current state of the node material building
  21127. * @returns the shader code
  21128. */
  21129. getCode(state: NodeMaterialBuildState): string;
  21130. protected _buildBlock(state: NodeMaterialBuildState): this;
  21131. protected _dumpPropertiesCode(): string;
  21132. serialize(): any;
  21133. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21134. }
  21135. }
  21136. declare module BABYLON {
  21137. /**
  21138. * Base block used as input for post process
  21139. */
  21140. export class CurrentScreenBlock extends NodeMaterialBlock {
  21141. private _samplerName;
  21142. private _linearDefineName;
  21143. private _gammaDefineName;
  21144. private _mainUVName;
  21145. private _tempTextureRead;
  21146. /**
  21147. * Gets or sets the texture associated with the node
  21148. */
  21149. texture: Nullable<BaseTexture>;
  21150. /**
  21151. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21152. */
  21153. convertToGammaSpace: boolean;
  21154. /**
  21155. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21156. */
  21157. convertToLinearSpace: boolean;
  21158. /**
  21159. * Create a new CurrentScreenBlock
  21160. * @param name defines the block name
  21161. */
  21162. constructor(name: string);
  21163. /**
  21164. * Gets the current class name
  21165. * @returns the class name
  21166. */
  21167. getClassName(): string;
  21168. /**
  21169. * Gets the uv input component
  21170. */
  21171. get uv(): NodeMaterialConnectionPoint;
  21172. /**
  21173. * Gets the rgba output component
  21174. */
  21175. get rgba(): NodeMaterialConnectionPoint;
  21176. /**
  21177. * Gets the rgb output component
  21178. */
  21179. get rgb(): NodeMaterialConnectionPoint;
  21180. /**
  21181. * Gets the r output component
  21182. */
  21183. get r(): NodeMaterialConnectionPoint;
  21184. /**
  21185. * Gets the g output component
  21186. */
  21187. get g(): NodeMaterialConnectionPoint;
  21188. /**
  21189. * Gets the b output component
  21190. */
  21191. get b(): NodeMaterialConnectionPoint;
  21192. /**
  21193. * Gets the a output component
  21194. */
  21195. get a(): NodeMaterialConnectionPoint;
  21196. /**
  21197. * Initialize the block and prepare the context for build
  21198. * @param state defines the state that will be used for the build
  21199. */
  21200. initialize(state: NodeMaterialBuildState): void;
  21201. get target(): NodeMaterialBlockTargets;
  21202. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21203. isReady(): boolean;
  21204. private _injectVertexCode;
  21205. private _writeTextureRead;
  21206. private _writeOutput;
  21207. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21208. serialize(): any;
  21209. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21210. }
  21211. }
  21212. declare module BABYLON {
  21213. /**
  21214. * Base block used for the particle texture
  21215. */
  21216. export class ParticleTextureBlock extends NodeMaterialBlock {
  21217. private _samplerName;
  21218. private _linearDefineName;
  21219. private _gammaDefineName;
  21220. private _tempTextureRead;
  21221. /**
  21222. * Gets or sets the texture associated with the node
  21223. */
  21224. texture: Nullable<BaseTexture>;
  21225. /**
  21226. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21227. */
  21228. convertToGammaSpace: boolean;
  21229. /**
  21230. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21231. */
  21232. convertToLinearSpace: boolean;
  21233. /**
  21234. * Create a new ParticleTextureBlock
  21235. * @param name defines the block name
  21236. */
  21237. constructor(name: string);
  21238. /**
  21239. * Gets the current class name
  21240. * @returns the class name
  21241. */
  21242. getClassName(): string;
  21243. /**
  21244. * Gets the uv input component
  21245. */
  21246. get uv(): NodeMaterialConnectionPoint;
  21247. /**
  21248. * Gets the rgba output component
  21249. */
  21250. get rgba(): NodeMaterialConnectionPoint;
  21251. /**
  21252. * Gets the rgb output component
  21253. */
  21254. get rgb(): NodeMaterialConnectionPoint;
  21255. /**
  21256. * Gets the r output component
  21257. */
  21258. get r(): NodeMaterialConnectionPoint;
  21259. /**
  21260. * Gets the g output component
  21261. */
  21262. get g(): NodeMaterialConnectionPoint;
  21263. /**
  21264. * Gets the b output component
  21265. */
  21266. get b(): NodeMaterialConnectionPoint;
  21267. /**
  21268. * Gets the a output component
  21269. */
  21270. get a(): NodeMaterialConnectionPoint;
  21271. /**
  21272. * Initialize the block and prepare the context for build
  21273. * @param state defines the state that will be used for the build
  21274. */
  21275. initialize(state: NodeMaterialBuildState): void;
  21276. autoConfigure(material: NodeMaterial): void;
  21277. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21278. isReady(): boolean;
  21279. private _writeOutput;
  21280. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21281. serialize(): any;
  21282. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21283. }
  21284. }
  21285. declare module BABYLON {
  21286. /**
  21287. * Class used to store shared data between 2 NodeMaterialBuildState
  21288. */
  21289. export class NodeMaterialBuildStateSharedData {
  21290. /**
  21291. * Gets the list of emitted varyings
  21292. */
  21293. temps: string[];
  21294. /**
  21295. * Gets the list of emitted varyings
  21296. */
  21297. varyings: string[];
  21298. /**
  21299. * Gets the varying declaration string
  21300. */
  21301. varyingDeclaration: string;
  21302. /**
  21303. * Input blocks
  21304. */
  21305. inputBlocks: InputBlock[];
  21306. /**
  21307. * Input blocks
  21308. */
  21309. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21310. /**
  21311. * Bindable blocks (Blocks that need to set data to the effect)
  21312. */
  21313. bindableBlocks: NodeMaterialBlock[];
  21314. /**
  21315. * List of blocks that can provide a compilation fallback
  21316. */
  21317. blocksWithFallbacks: NodeMaterialBlock[];
  21318. /**
  21319. * List of blocks that can provide a define update
  21320. */
  21321. blocksWithDefines: NodeMaterialBlock[];
  21322. /**
  21323. * List of blocks that can provide a repeatable content
  21324. */
  21325. repeatableContentBlocks: NodeMaterialBlock[];
  21326. /**
  21327. * List of blocks that can provide a dynamic list of uniforms
  21328. */
  21329. dynamicUniformBlocks: NodeMaterialBlock[];
  21330. /**
  21331. * List of blocks that can block the isReady function for the material
  21332. */
  21333. blockingBlocks: NodeMaterialBlock[];
  21334. /**
  21335. * Gets the list of animated inputs
  21336. */
  21337. animatedInputs: InputBlock[];
  21338. /**
  21339. * Build Id used to avoid multiple recompilations
  21340. */
  21341. buildId: number;
  21342. /** List of emitted variables */
  21343. variableNames: {
  21344. [key: string]: number;
  21345. };
  21346. /** List of emitted defines */
  21347. defineNames: {
  21348. [key: string]: number;
  21349. };
  21350. /** Should emit comments? */
  21351. emitComments: boolean;
  21352. /** Emit build activity */
  21353. verbose: boolean;
  21354. /** Gets or sets the hosting scene */
  21355. scene: Scene;
  21356. /**
  21357. * Gets the compilation hints emitted at compilation time
  21358. */
  21359. hints: {
  21360. needWorldViewMatrix: boolean;
  21361. needWorldViewProjectionMatrix: boolean;
  21362. needAlphaBlending: boolean;
  21363. needAlphaTesting: boolean;
  21364. };
  21365. /**
  21366. * List of compilation checks
  21367. */
  21368. checks: {
  21369. emitVertex: boolean;
  21370. emitFragment: boolean;
  21371. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21372. };
  21373. /**
  21374. * Is vertex program allowed to be empty?
  21375. */
  21376. allowEmptyVertexProgram: boolean;
  21377. /** Creates a new shared data */
  21378. constructor();
  21379. /**
  21380. * Emits console errors and exceptions if there is a failing check
  21381. */
  21382. emitErrors(): void;
  21383. }
  21384. }
  21385. declare module BABYLON {
  21386. /**
  21387. * Class used to store node based material build state
  21388. */
  21389. export class NodeMaterialBuildState {
  21390. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21391. supportUniformBuffers: boolean;
  21392. /**
  21393. * Gets the list of emitted attributes
  21394. */
  21395. attributes: string[];
  21396. /**
  21397. * Gets the list of emitted uniforms
  21398. */
  21399. uniforms: string[];
  21400. /**
  21401. * Gets the list of emitted constants
  21402. */
  21403. constants: string[];
  21404. /**
  21405. * Gets the list of emitted samplers
  21406. */
  21407. samplers: string[];
  21408. /**
  21409. * Gets the list of emitted functions
  21410. */
  21411. functions: {
  21412. [key: string]: string;
  21413. };
  21414. /**
  21415. * Gets the list of emitted extensions
  21416. */
  21417. extensions: {
  21418. [key: string]: string;
  21419. };
  21420. /**
  21421. * Gets the target of the compilation state
  21422. */
  21423. target: NodeMaterialBlockTargets;
  21424. /**
  21425. * Gets the list of emitted counters
  21426. */
  21427. counters: {
  21428. [key: string]: number;
  21429. };
  21430. /**
  21431. * Shared data between multiple NodeMaterialBuildState instances
  21432. */
  21433. sharedData: NodeMaterialBuildStateSharedData;
  21434. /** @hidden */
  21435. _vertexState: NodeMaterialBuildState;
  21436. /** @hidden */
  21437. _attributeDeclaration: string;
  21438. /** @hidden */
  21439. _uniformDeclaration: string;
  21440. /** @hidden */
  21441. _constantDeclaration: string;
  21442. /** @hidden */
  21443. _samplerDeclaration: string;
  21444. /** @hidden */
  21445. _varyingTransfer: string;
  21446. /** @hidden */
  21447. _injectAtEnd: string;
  21448. private _repeatableContentAnchorIndex;
  21449. /** @hidden */
  21450. _builtCompilationString: string;
  21451. /**
  21452. * Gets the emitted compilation strings
  21453. */
  21454. compilationString: string;
  21455. /**
  21456. * Finalize the compilation strings
  21457. * @param state defines the current compilation state
  21458. */
  21459. finalize(state: NodeMaterialBuildState): void;
  21460. /** @hidden */
  21461. get _repeatableContentAnchor(): string;
  21462. /** @hidden */
  21463. _getFreeVariableName(prefix: string): string;
  21464. /** @hidden */
  21465. _getFreeDefineName(prefix: string): string;
  21466. /** @hidden */
  21467. _excludeVariableName(name: string): void;
  21468. /** @hidden */
  21469. _emit2DSampler(name: string): void;
  21470. /** @hidden */
  21471. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21472. /** @hidden */
  21473. _emitExtension(name: string, extension: string, define?: string): void;
  21474. /** @hidden */
  21475. _emitFunction(name: string, code: string, comments: string): void;
  21476. /** @hidden */
  21477. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21478. replaceStrings?: {
  21479. search: RegExp;
  21480. replace: string;
  21481. }[];
  21482. repeatKey?: string;
  21483. }): string;
  21484. /** @hidden */
  21485. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21486. repeatKey?: string;
  21487. removeAttributes?: boolean;
  21488. removeUniforms?: boolean;
  21489. removeVaryings?: boolean;
  21490. removeIfDef?: boolean;
  21491. replaceStrings?: {
  21492. search: RegExp;
  21493. replace: string;
  21494. }[];
  21495. }, storeKey?: string): void;
  21496. /** @hidden */
  21497. _registerTempVariable(name: string): boolean;
  21498. /** @hidden */
  21499. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21500. /** @hidden */
  21501. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21502. /** @hidden */
  21503. _emitFloat(value: number): string;
  21504. }
  21505. }
  21506. declare module BABYLON {
  21507. /**
  21508. * Helper class used to generate session unique ID
  21509. */
  21510. export class UniqueIdGenerator {
  21511. private static _UniqueIdCounter;
  21512. /**
  21513. * Gets an unique (relatively to the current scene) Id
  21514. */
  21515. static get UniqueId(): number;
  21516. }
  21517. }
  21518. declare module BABYLON {
  21519. /**
  21520. * Defines a block that can be used inside a node based material
  21521. */
  21522. export class NodeMaterialBlock {
  21523. private _buildId;
  21524. private _buildTarget;
  21525. private _target;
  21526. private _isFinalMerger;
  21527. private _isInput;
  21528. private _name;
  21529. protected _isUnique: boolean;
  21530. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21531. inputsAreExclusive: boolean;
  21532. /** @hidden */
  21533. _codeVariableName: string;
  21534. /** @hidden */
  21535. _inputs: NodeMaterialConnectionPoint[];
  21536. /** @hidden */
  21537. _outputs: NodeMaterialConnectionPoint[];
  21538. /** @hidden */
  21539. _preparationId: number;
  21540. /**
  21541. * Gets the name of the block
  21542. */
  21543. get name(): string;
  21544. /**
  21545. * Sets the name of the block. Will check if the name is valid.
  21546. */
  21547. set name(newName: string);
  21548. /**
  21549. * Gets or sets the unique id of the node
  21550. */
  21551. uniqueId: number;
  21552. /**
  21553. * Gets or sets the comments associated with this block
  21554. */
  21555. comments: string;
  21556. /**
  21557. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21558. */
  21559. get isUnique(): boolean;
  21560. /**
  21561. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21562. */
  21563. get isFinalMerger(): boolean;
  21564. /**
  21565. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21566. */
  21567. get isInput(): boolean;
  21568. /**
  21569. * Gets or sets the build Id
  21570. */
  21571. get buildId(): number;
  21572. set buildId(value: number);
  21573. /**
  21574. * Gets or sets the target of the block
  21575. */
  21576. get target(): NodeMaterialBlockTargets;
  21577. set target(value: NodeMaterialBlockTargets);
  21578. /**
  21579. * Gets the list of input points
  21580. */
  21581. get inputs(): NodeMaterialConnectionPoint[];
  21582. /** Gets the list of output points */
  21583. get outputs(): NodeMaterialConnectionPoint[];
  21584. /**
  21585. * Find an input by its name
  21586. * @param name defines the name of the input to look for
  21587. * @returns the input or null if not found
  21588. */
  21589. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21590. /**
  21591. * Find an output by its name
  21592. * @param name defines the name of the outputto look for
  21593. * @returns the output or null if not found
  21594. */
  21595. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21596. /**
  21597. * Creates a new NodeMaterialBlock
  21598. * @param name defines the block name
  21599. * @param target defines the target of that block (Vertex by default)
  21600. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21601. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21602. */
  21603. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21604. /**
  21605. * Initialize the block and prepare the context for build
  21606. * @param state defines the state that will be used for the build
  21607. */
  21608. initialize(state: NodeMaterialBuildState): void;
  21609. /**
  21610. * Bind data to effect. Will only be called for blocks with isBindable === true
  21611. * @param effect defines the effect to bind data to
  21612. * @param nodeMaterial defines the hosting NodeMaterial
  21613. * @param mesh defines the mesh that will be rendered
  21614. * @param subMesh defines the submesh that will be rendered
  21615. */
  21616. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21617. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21618. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21619. protected _writeFloat(value: number): string;
  21620. /**
  21621. * Gets the current class name e.g. "NodeMaterialBlock"
  21622. * @returns the class name
  21623. */
  21624. getClassName(): string;
  21625. /**
  21626. * Register a new input. Must be called inside a block constructor
  21627. * @param name defines the connection point name
  21628. * @param type defines the connection point type
  21629. * @param isOptional defines a boolean indicating that this input can be omitted
  21630. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21631. * @param point an already created connection point. If not provided, create a new one
  21632. * @returns the current block
  21633. */
  21634. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21635. /**
  21636. * Register a new output. Must be called inside a block constructor
  21637. * @param name defines the connection point name
  21638. * @param type defines the connection point type
  21639. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21640. * @param point an already created connection point. If not provided, create a new one
  21641. * @returns the current block
  21642. */
  21643. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21644. /**
  21645. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21646. * @param forOutput defines an optional connection point to check compatibility with
  21647. * @returns the first available input or null
  21648. */
  21649. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21650. /**
  21651. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21652. * @param forBlock defines an optional block to check compatibility with
  21653. * @returns the first available input or null
  21654. */
  21655. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21656. /**
  21657. * Gets the sibling of the given output
  21658. * @param current defines the current output
  21659. * @returns the next output in the list or null
  21660. */
  21661. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21662. /**
  21663. * Connect current block with another block
  21664. * @param other defines the block to connect with
  21665. * @param options define the various options to help pick the right connections
  21666. * @returns the current block
  21667. */
  21668. connectTo(other: NodeMaterialBlock, options?: {
  21669. input?: string;
  21670. output?: string;
  21671. outputSwizzle?: string;
  21672. }): this | undefined;
  21673. protected _buildBlock(state: NodeMaterialBuildState): void;
  21674. /**
  21675. * Add uniforms, samplers and uniform buffers at compilation time
  21676. * @param state defines the state to update
  21677. * @param nodeMaterial defines the node material requesting the update
  21678. * @param defines defines the material defines to update
  21679. * @param uniformBuffers defines the list of uniform buffer names
  21680. */
  21681. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21682. /**
  21683. * Add potential fallbacks if shader compilation fails
  21684. * @param mesh defines the mesh to be rendered
  21685. * @param fallbacks defines the current prioritized list of fallbacks
  21686. */
  21687. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21688. /**
  21689. * Initialize defines for shader compilation
  21690. * @param mesh defines the mesh to be rendered
  21691. * @param nodeMaterial defines the node material requesting the update
  21692. * @param defines defines the material defines to update
  21693. * @param useInstances specifies that instances should be used
  21694. */
  21695. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21696. /**
  21697. * Update defines for shader compilation
  21698. * @param mesh defines the mesh to be rendered
  21699. * @param nodeMaterial defines the node material requesting the update
  21700. * @param defines defines the material defines to update
  21701. * @param useInstances specifies that instances should be used
  21702. * @param subMesh defines which submesh to render
  21703. */
  21704. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21705. /**
  21706. * Lets the block try to connect some inputs automatically
  21707. * @param material defines the hosting NodeMaterial
  21708. */
  21709. autoConfigure(material: NodeMaterial): void;
  21710. /**
  21711. * Function called when a block is declared as repeatable content generator
  21712. * @param vertexShaderState defines the current compilation state for the vertex shader
  21713. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21714. * @param mesh defines the mesh to be rendered
  21715. * @param defines defines the material defines to update
  21716. */
  21717. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21718. /**
  21719. * Checks if the block is ready
  21720. * @param mesh defines the mesh to be rendered
  21721. * @param nodeMaterial defines the node material requesting the update
  21722. * @param defines defines the material defines to update
  21723. * @param useInstances specifies that instances should be used
  21724. * @returns true if the block is ready
  21725. */
  21726. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21727. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21728. private _processBuild;
  21729. /**
  21730. * Validates the new name for the block node.
  21731. * @param newName the new name to be given to the node.
  21732. * @returns false if the name is a reserve word, else true.
  21733. */
  21734. validateBlockName(newName: string): boolean;
  21735. /**
  21736. * Compile the current node and generate the shader code
  21737. * @param state defines the current compilation state (uniforms, samplers, current string)
  21738. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21739. * @returns true if already built
  21740. */
  21741. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21742. protected _inputRename(name: string): string;
  21743. protected _outputRename(name: string): string;
  21744. protected _dumpPropertiesCode(): string;
  21745. /** @hidden */
  21746. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21747. /** @hidden */
  21748. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21749. /**
  21750. * Clone the current block to a new identical block
  21751. * @param scene defines the hosting scene
  21752. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21753. * @returns a copy of the current block
  21754. */
  21755. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21756. /**
  21757. * Serializes this block in a JSON representation
  21758. * @returns the serialized block object
  21759. */
  21760. serialize(): any;
  21761. /** @hidden */
  21762. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21763. private _deserializePortDisplayNamesAndExposedOnFrame;
  21764. /**
  21765. * Release resources
  21766. */
  21767. dispose(): void;
  21768. }
  21769. }
  21770. declare module BABYLON {
  21771. /**
  21772. * Base class of materials working in push mode in babylon JS
  21773. * @hidden
  21774. */
  21775. export class PushMaterial extends Material {
  21776. protected _activeEffect: Effect;
  21777. protected _normalMatrix: Matrix;
  21778. constructor(name: string, scene: Scene);
  21779. getEffect(): Effect;
  21780. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21781. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21782. /**
  21783. * Binds the given world matrix to the active effect
  21784. *
  21785. * @param world the matrix to bind
  21786. */
  21787. bindOnlyWorldMatrix(world: Matrix): void;
  21788. /**
  21789. * Binds the given normal matrix to the active effect
  21790. *
  21791. * @param normalMatrix the matrix to bind
  21792. */
  21793. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21794. bind(world: Matrix, mesh?: Mesh): void;
  21795. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21796. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21797. }
  21798. }
  21799. declare module BABYLON {
  21800. /**
  21801. * Root class for all node material optimizers
  21802. */
  21803. export class NodeMaterialOptimizer {
  21804. /**
  21805. * Function used to optimize a NodeMaterial graph
  21806. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21807. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21808. */
  21809. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21810. }
  21811. }
  21812. declare module BABYLON {
  21813. /**
  21814. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21815. */
  21816. export class TransformBlock extends NodeMaterialBlock {
  21817. /**
  21818. * Defines the value to use to complement W value to transform it to a Vector4
  21819. */
  21820. complementW: number;
  21821. /**
  21822. * Defines the value to use to complement z value to transform it to a Vector4
  21823. */
  21824. complementZ: number;
  21825. /**
  21826. * Creates a new TransformBlock
  21827. * @param name defines the block name
  21828. */
  21829. constructor(name: string);
  21830. /**
  21831. * Gets the current class name
  21832. * @returns the class name
  21833. */
  21834. getClassName(): string;
  21835. /**
  21836. * Gets the vector input
  21837. */
  21838. get vector(): NodeMaterialConnectionPoint;
  21839. /**
  21840. * Gets the output component
  21841. */
  21842. get output(): NodeMaterialConnectionPoint;
  21843. /**
  21844. * Gets the xyz output component
  21845. */
  21846. get xyz(): NodeMaterialConnectionPoint;
  21847. /**
  21848. * Gets the matrix transform input
  21849. */
  21850. get transform(): NodeMaterialConnectionPoint;
  21851. protected _buildBlock(state: NodeMaterialBuildState): this;
  21852. /**
  21853. * Update defines for shader compilation
  21854. * @param mesh defines the mesh to be rendered
  21855. * @param nodeMaterial defines the node material requesting the update
  21856. * @param defines defines the material defines to update
  21857. * @param useInstances specifies that instances should be used
  21858. * @param subMesh defines which submesh to render
  21859. */
  21860. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21861. serialize(): any;
  21862. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21863. protected _dumpPropertiesCode(): string;
  21864. }
  21865. }
  21866. declare module BABYLON {
  21867. /**
  21868. * Block used to output the vertex position
  21869. */
  21870. export class VertexOutputBlock extends NodeMaterialBlock {
  21871. /**
  21872. * Creates a new VertexOutputBlock
  21873. * @param name defines the block name
  21874. */
  21875. constructor(name: string);
  21876. /**
  21877. * Gets the current class name
  21878. * @returns the class name
  21879. */
  21880. getClassName(): string;
  21881. /**
  21882. * Gets the vector input component
  21883. */
  21884. get vector(): NodeMaterialConnectionPoint;
  21885. protected _buildBlock(state: NodeMaterialBuildState): this;
  21886. }
  21887. }
  21888. declare module BABYLON {
  21889. /**
  21890. * Block used to output the final color
  21891. */
  21892. export class FragmentOutputBlock extends NodeMaterialBlock {
  21893. /**
  21894. * Create a new FragmentOutputBlock
  21895. * @param name defines the block name
  21896. */
  21897. constructor(name: string);
  21898. /**
  21899. * Gets the current class name
  21900. * @returns the class name
  21901. */
  21902. getClassName(): string;
  21903. /**
  21904. * Gets the rgba input component
  21905. */
  21906. get rgba(): NodeMaterialConnectionPoint;
  21907. /**
  21908. * Gets the rgb input component
  21909. */
  21910. get rgb(): NodeMaterialConnectionPoint;
  21911. /**
  21912. * Gets the a input component
  21913. */
  21914. get a(): NodeMaterialConnectionPoint;
  21915. protected _buildBlock(state: NodeMaterialBuildState): this;
  21916. }
  21917. }
  21918. declare module BABYLON {
  21919. /**
  21920. * Block used for the particle ramp gradient section
  21921. */
  21922. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21923. /**
  21924. * Create a new ParticleRampGradientBlock
  21925. * @param name defines the block name
  21926. */
  21927. constructor(name: string);
  21928. /**
  21929. * Gets the current class name
  21930. * @returns the class name
  21931. */
  21932. getClassName(): string;
  21933. /**
  21934. * Gets the color input component
  21935. */
  21936. get color(): NodeMaterialConnectionPoint;
  21937. /**
  21938. * Gets the rampColor output component
  21939. */
  21940. get rampColor(): NodeMaterialConnectionPoint;
  21941. /**
  21942. * Initialize the block and prepare the context for build
  21943. * @param state defines the state that will be used for the build
  21944. */
  21945. initialize(state: NodeMaterialBuildState): void;
  21946. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21947. }
  21948. }
  21949. declare module BABYLON {
  21950. /**
  21951. * Block used for the particle blend multiply section
  21952. */
  21953. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21954. /**
  21955. * Create a new ParticleBlendMultiplyBlock
  21956. * @param name defines the block name
  21957. */
  21958. constructor(name: string);
  21959. /**
  21960. * Gets the current class name
  21961. * @returns the class name
  21962. */
  21963. getClassName(): string;
  21964. /**
  21965. * Gets the color input component
  21966. */
  21967. get color(): NodeMaterialConnectionPoint;
  21968. /**
  21969. * Gets the alphaTexture input component
  21970. */
  21971. get alphaTexture(): NodeMaterialConnectionPoint;
  21972. /**
  21973. * Gets the alphaColor input component
  21974. */
  21975. get alphaColor(): NodeMaterialConnectionPoint;
  21976. /**
  21977. * Gets the blendColor output component
  21978. */
  21979. get blendColor(): NodeMaterialConnectionPoint;
  21980. /**
  21981. * Initialize the block and prepare the context for build
  21982. * @param state defines the state that will be used for the build
  21983. */
  21984. initialize(state: NodeMaterialBuildState): void;
  21985. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21986. }
  21987. }
  21988. declare module BABYLON {
  21989. /**
  21990. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  21991. */
  21992. export class VectorMergerBlock extends NodeMaterialBlock {
  21993. /**
  21994. * Create a new VectorMergerBlock
  21995. * @param name defines the block name
  21996. */
  21997. constructor(name: string);
  21998. /**
  21999. * Gets the current class name
  22000. * @returns the class name
  22001. */
  22002. getClassName(): string;
  22003. /**
  22004. * Gets the xyz component (input)
  22005. */
  22006. get xyzIn(): NodeMaterialConnectionPoint;
  22007. /**
  22008. * Gets the xy component (input)
  22009. */
  22010. get xyIn(): NodeMaterialConnectionPoint;
  22011. /**
  22012. * Gets the x component (input)
  22013. */
  22014. get x(): NodeMaterialConnectionPoint;
  22015. /**
  22016. * Gets the y component (input)
  22017. */
  22018. get y(): NodeMaterialConnectionPoint;
  22019. /**
  22020. * Gets the z component (input)
  22021. */
  22022. get z(): NodeMaterialConnectionPoint;
  22023. /**
  22024. * Gets the w component (input)
  22025. */
  22026. get w(): NodeMaterialConnectionPoint;
  22027. /**
  22028. * Gets the xyzw component (output)
  22029. */
  22030. get xyzw(): NodeMaterialConnectionPoint;
  22031. /**
  22032. * Gets the xyz component (output)
  22033. */
  22034. get xyzOut(): NodeMaterialConnectionPoint;
  22035. /**
  22036. * Gets the xy component (output)
  22037. */
  22038. get xyOut(): NodeMaterialConnectionPoint;
  22039. /**
  22040. * Gets the xy component (output)
  22041. * @deprecated Please use xyOut instead.
  22042. */
  22043. get xy(): NodeMaterialConnectionPoint;
  22044. /**
  22045. * Gets the xyz component (output)
  22046. * @deprecated Please use xyzOut instead.
  22047. */
  22048. get xyz(): NodeMaterialConnectionPoint;
  22049. protected _buildBlock(state: NodeMaterialBuildState): this;
  22050. }
  22051. }
  22052. declare module BABYLON {
  22053. /**
  22054. * Block used to remap a float from a range to a new one
  22055. */
  22056. export class RemapBlock extends NodeMaterialBlock {
  22057. /**
  22058. * Gets or sets the source range
  22059. */
  22060. sourceRange: Vector2;
  22061. /**
  22062. * Gets or sets the target range
  22063. */
  22064. targetRange: Vector2;
  22065. /**
  22066. * Creates a new RemapBlock
  22067. * @param name defines the block name
  22068. */
  22069. constructor(name: string);
  22070. /**
  22071. * Gets the current class name
  22072. * @returns the class name
  22073. */
  22074. getClassName(): string;
  22075. /**
  22076. * Gets the input component
  22077. */
  22078. get input(): NodeMaterialConnectionPoint;
  22079. /**
  22080. * Gets the source min input component
  22081. */
  22082. get sourceMin(): NodeMaterialConnectionPoint;
  22083. /**
  22084. * Gets the source max input component
  22085. */
  22086. get sourceMax(): NodeMaterialConnectionPoint;
  22087. /**
  22088. * Gets the target min input component
  22089. */
  22090. get targetMin(): NodeMaterialConnectionPoint;
  22091. /**
  22092. * Gets the target max input component
  22093. */
  22094. get targetMax(): NodeMaterialConnectionPoint;
  22095. /**
  22096. * Gets the output component
  22097. */
  22098. get output(): NodeMaterialConnectionPoint;
  22099. protected _buildBlock(state: NodeMaterialBuildState): this;
  22100. protected _dumpPropertiesCode(): string;
  22101. serialize(): any;
  22102. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22103. }
  22104. }
  22105. declare module BABYLON {
  22106. /**
  22107. * Block used to multiply 2 values
  22108. */
  22109. export class MultiplyBlock extends NodeMaterialBlock {
  22110. /**
  22111. * Creates a new MultiplyBlock
  22112. * @param name defines the block name
  22113. */
  22114. constructor(name: string);
  22115. /**
  22116. * Gets the current class name
  22117. * @returns the class name
  22118. */
  22119. getClassName(): string;
  22120. /**
  22121. * Gets the left operand input component
  22122. */
  22123. get left(): NodeMaterialConnectionPoint;
  22124. /**
  22125. * Gets the right operand input component
  22126. */
  22127. get right(): NodeMaterialConnectionPoint;
  22128. /**
  22129. * Gets the output component
  22130. */
  22131. get output(): NodeMaterialConnectionPoint;
  22132. protected _buildBlock(state: NodeMaterialBuildState): this;
  22133. }
  22134. }
  22135. declare module BABYLON {
  22136. /**
  22137. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22138. */
  22139. export class ColorSplitterBlock extends NodeMaterialBlock {
  22140. /**
  22141. * Create a new ColorSplitterBlock
  22142. * @param name defines the block name
  22143. */
  22144. constructor(name: string);
  22145. /**
  22146. * Gets the current class name
  22147. * @returns the class name
  22148. */
  22149. getClassName(): string;
  22150. /**
  22151. * Gets the rgba component (input)
  22152. */
  22153. get rgba(): NodeMaterialConnectionPoint;
  22154. /**
  22155. * Gets the rgb component (input)
  22156. */
  22157. get rgbIn(): NodeMaterialConnectionPoint;
  22158. /**
  22159. * Gets the rgb component (output)
  22160. */
  22161. get rgbOut(): NodeMaterialConnectionPoint;
  22162. /**
  22163. * Gets the r component (output)
  22164. */
  22165. get r(): NodeMaterialConnectionPoint;
  22166. /**
  22167. * Gets the g component (output)
  22168. */
  22169. get g(): NodeMaterialConnectionPoint;
  22170. /**
  22171. * Gets the b component (output)
  22172. */
  22173. get b(): NodeMaterialConnectionPoint;
  22174. /**
  22175. * Gets the a component (output)
  22176. */
  22177. get a(): NodeMaterialConnectionPoint;
  22178. protected _inputRename(name: string): string;
  22179. protected _outputRename(name: string): string;
  22180. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22181. }
  22182. }
  22183. declare module BABYLON {
  22184. /**
  22185. * Interface used to configure the node material editor
  22186. */
  22187. export interface INodeMaterialEditorOptions {
  22188. /** Define the URl to load node editor script */
  22189. editorURL?: string;
  22190. }
  22191. /** @hidden */
  22192. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22193. NORMAL: boolean;
  22194. TANGENT: boolean;
  22195. UV1: boolean;
  22196. /** BONES */
  22197. NUM_BONE_INFLUENCERS: number;
  22198. BonesPerMesh: number;
  22199. BONETEXTURE: boolean;
  22200. /** MORPH TARGETS */
  22201. MORPHTARGETS: boolean;
  22202. MORPHTARGETS_NORMAL: boolean;
  22203. MORPHTARGETS_TANGENT: boolean;
  22204. MORPHTARGETS_UV: boolean;
  22205. NUM_MORPH_INFLUENCERS: number;
  22206. /** IMAGE PROCESSING */
  22207. IMAGEPROCESSING: boolean;
  22208. VIGNETTE: boolean;
  22209. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22210. VIGNETTEBLENDMODEOPAQUE: boolean;
  22211. TONEMAPPING: boolean;
  22212. TONEMAPPING_ACES: boolean;
  22213. CONTRAST: boolean;
  22214. EXPOSURE: boolean;
  22215. COLORCURVES: boolean;
  22216. COLORGRADING: boolean;
  22217. COLORGRADING3D: boolean;
  22218. SAMPLER3DGREENDEPTH: boolean;
  22219. SAMPLER3DBGRMAP: boolean;
  22220. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22221. /** MISC. */
  22222. BUMPDIRECTUV: number;
  22223. constructor();
  22224. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22225. }
  22226. /**
  22227. * Class used to configure NodeMaterial
  22228. */
  22229. export interface INodeMaterialOptions {
  22230. /**
  22231. * Defines if blocks should emit comments
  22232. */
  22233. emitComments: boolean;
  22234. }
  22235. /**
  22236. * Class used to create a node based material built by assembling shader blocks
  22237. */
  22238. export class NodeMaterial extends PushMaterial {
  22239. private static _BuildIdGenerator;
  22240. private _options;
  22241. private _vertexCompilationState;
  22242. private _fragmentCompilationState;
  22243. private _sharedData;
  22244. private _buildId;
  22245. private _buildWasSuccessful;
  22246. private _cachedWorldViewMatrix;
  22247. private _cachedWorldViewProjectionMatrix;
  22248. private _optimizers;
  22249. private _animationFrame;
  22250. /** Define the Url to load node editor script */
  22251. static EditorURL: string;
  22252. /** Define the Url to load snippets */
  22253. static SnippetUrl: string;
  22254. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22255. static IgnoreTexturesAtLoadTime: boolean;
  22256. private BJSNODEMATERIALEDITOR;
  22257. /** Get the inspector from bundle or global */
  22258. private _getGlobalNodeMaterialEditor;
  22259. /**
  22260. * Snippet ID if the material was created from the snippet server
  22261. */
  22262. snippetId: string;
  22263. /**
  22264. * Gets or sets data used by visual editor
  22265. * @see https://nme.babylonjs.com
  22266. */
  22267. editorData: any;
  22268. /**
  22269. * 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)
  22270. */
  22271. ignoreAlpha: boolean;
  22272. /**
  22273. * Defines the maximum number of lights that can be used in the material
  22274. */
  22275. maxSimultaneousLights: number;
  22276. /**
  22277. * Observable raised when the material is built
  22278. */
  22279. onBuildObservable: Observable<NodeMaterial>;
  22280. /**
  22281. * Gets or sets the root nodes of the material vertex shader
  22282. */
  22283. _vertexOutputNodes: NodeMaterialBlock[];
  22284. /**
  22285. * Gets or sets the root nodes of the material fragment (pixel) shader
  22286. */
  22287. _fragmentOutputNodes: NodeMaterialBlock[];
  22288. /** Gets or sets options to control the node material overall behavior */
  22289. get options(): INodeMaterialOptions;
  22290. set options(options: INodeMaterialOptions);
  22291. /**
  22292. * Default configuration related to image processing available in the standard Material.
  22293. */
  22294. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22295. /**
  22296. * Gets the image processing configuration used either in this material.
  22297. */
  22298. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22299. /**
  22300. * Sets the Default image processing configuration used either in the this material.
  22301. *
  22302. * If sets to null, the scene one is in use.
  22303. */
  22304. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22305. /**
  22306. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22307. */
  22308. attachedBlocks: NodeMaterialBlock[];
  22309. /**
  22310. * Specifies the mode of the node material
  22311. * @hidden
  22312. */
  22313. _mode: NodeMaterialModes;
  22314. /**
  22315. * Gets the mode property
  22316. */
  22317. get mode(): NodeMaterialModes;
  22318. /**
  22319. * Create a new node based material
  22320. * @param name defines the material name
  22321. * @param scene defines the hosting scene
  22322. * @param options defines creation option
  22323. */
  22324. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22325. /**
  22326. * Gets the current class name of the material e.g. "NodeMaterial"
  22327. * @returns the class name
  22328. */
  22329. getClassName(): string;
  22330. /**
  22331. * Keep track of the image processing observer to allow dispose and replace.
  22332. */
  22333. private _imageProcessingObserver;
  22334. /**
  22335. * Attaches a new image processing configuration to the Standard Material.
  22336. * @param configuration
  22337. */
  22338. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22339. /**
  22340. * Get a block by its name
  22341. * @param name defines the name of the block to retrieve
  22342. * @returns the required block or null if not found
  22343. */
  22344. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22345. /**
  22346. * Get a block by its name
  22347. * @param predicate defines the predicate used to find the good candidate
  22348. * @returns the required block or null if not found
  22349. */
  22350. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22351. /**
  22352. * Get an input block by its name
  22353. * @param predicate defines the predicate used to find the good candidate
  22354. * @returns the required input block or null if not found
  22355. */
  22356. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22357. /**
  22358. * Gets the list of input blocks attached to this material
  22359. * @returns an array of InputBlocks
  22360. */
  22361. getInputBlocks(): InputBlock[];
  22362. /**
  22363. * Adds a new optimizer to the list of optimizers
  22364. * @param optimizer defines the optimizers to add
  22365. * @returns the current material
  22366. */
  22367. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22368. /**
  22369. * Remove an optimizer from the list of optimizers
  22370. * @param optimizer defines the optimizers to remove
  22371. * @returns the current material
  22372. */
  22373. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22374. /**
  22375. * Add a new block to the list of output nodes
  22376. * @param node defines the node to add
  22377. * @returns the current material
  22378. */
  22379. addOutputNode(node: NodeMaterialBlock): this;
  22380. /**
  22381. * Remove a block from the list of root nodes
  22382. * @param node defines the node to remove
  22383. * @returns the current material
  22384. */
  22385. removeOutputNode(node: NodeMaterialBlock): this;
  22386. private _addVertexOutputNode;
  22387. private _removeVertexOutputNode;
  22388. private _addFragmentOutputNode;
  22389. private _removeFragmentOutputNode;
  22390. /**
  22391. * Specifies if the material will require alpha blending
  22392. * @returns a boolean specifying if alpha blending is needed
  22393. */
  22394. needAlphaBlending(): boolean;
  22395. /**
  22396. * Specifies if this material should be rendered in alpha test mode
  22397. * @returns a boolean specifying if an alpha test is needed.
  22398. */
  22399. needAlphaTesting(): boolean;
  22400. private _initializeBlock;
  22401. private _resetDualBlocks;
  22402. /**
  22403. * Remove a block from the current node material
  22404. * @param block defines the block to remove
  22405. */
  22406. removeBlock(block: NodeMaterialBlock): void;
  22407. /**
  22408. * Build the material and generates the inner effect
  22409. * @param verbose defines if the build should log activity
  22410. */
  22411. build(verbose?: boolean): void;
  22412. /**
  22413. * Runs an otpimization phase to try to improve the shader code
  22414. */
  22415. optimize(): void;
  22416. private _prepareDefinesForAttributes;
  22417. /**
  22418. * Create a post process from the material
  22419. * @param camera The camera to apply the render pass to.
  22420. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22421. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22422. * @param engine The engine which the post process will be applied. (default: current engine)
  22423. * @param reusable If the post process can be reused on the same frame. (default: false)
  22424. * @param textureType Type of textures used when performing the post process. (default: 0)
  22425. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22426. * @returns the post process created
  22427. */
  22428. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22429. /**
  22430. * Create the post process effect from the material
  22431. * @param postProcess The post process to create the effect for
  22432. */
  22433. createEffectForPostProcess(postProcess: PostProcess): void;
  22434. private _createEffectOrPostProcess;
  22435. private _createEffectForParticles;
  22436. /**
  22437. * Create the effect to be used as the custom effect for a particle system
  22438. * @param particleSystem Particle system to create the effect for
  22439. * @param onCompiled defines a function to call when the effect creation is successful
  22440. * @param onError defines a function to call when the effect creation has failed
  22441. */
  22442. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22443. private _processDefines;
  22444. /**
  22445. * Get if the submesh is ready to be used and all its information available.
  22446. * Child classes can use it to update shaders
  22447. * @param mesh defines the mesh to check
  22448. * @param subMesh defines which submesh to check
  22449. * @param useInstances specifies that instances should be used
  22450. * @returns a boolean indicating that the submesh is ready or not
  22451. */
  22452. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22453. /**
  22454. * Get a string representing the shaders built by the current node graph
  22455. */
  22456. get compiledShaders(): string;
  22457. /**
  22458. * Binds the world matrix to the material
  22459. * @param world defines the world transformation matrix
  22460. */
  22461. bindOnlyWorldMatrix(world: Matrix): void;
  22462. /**
  22463. * Binds the submesh to this material by preparing the effect and shader to draw
  22464. * @param world defines the world transformation matrix
  22465. * @param mesh defines the mesh containing the submesh
  22466. * @param subMesh defines the submesh to bind the material to
  22467. */
  22468. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22469. /**
  22470. * Gets the active textures from the material
  22471. * @returns an array of textures
  22472. */
  22473. getActiveTextures(): BaseTexture[];
  22474. /**
  22475. * Gets the list of texture blocks
  22476. * @returns an array of texture blocks
  22477. */
  22478. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22479. /**
  22480. * Specifies if the material uses a texture
  22481. * @param texture defines the texture to check against the material
  22482. * @returns a boolean specifying if the material uses the texture
  22483. */
  22484. hasTexture(texture: BaseTexture): boolean;
  22485. /**
  22486. * Disposes the material
  22487. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22488. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22489. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22490. */
  22491. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22492. /** Creates the node editor window. */
  22493. private _createNodeEditor;
  22494. /**
  22495. * Launch the node material editor
  22496. * @param config Define the configuration of the editor
  22497. * @return a promise fulfilled when the node editor is visible
  22498. */
  22499. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22500. /**
  22501. * Clear the current material
  22502. */
  22503. clear(): void;
  22504. /**
  22505. * Clear the current material and set it to a default state
  22506. */
  22507. setToDefault(): void;
  22508. /**
  22509. * Clear the current material and set it to a default state for post process
  22510. */
  22511. setToDefaultPostProcess(): void;
  22512. /**
  22513. * Clear the current material and set it to a default state for particle
  22514. */
  22515. setToDefaultParticle(): void;
  22516. /**
  22517. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22518. * @param url defines the url to load from
  22519. * @returns a promise that will fullfil when the material is fully loaded
  22520. */
  22521. loadAsync(url: string): Promise<void>;
  22522. private _gatherBlocks;
  22523. /**
  22524. * Generate a string containing the code declaration required to create an equivalent of this material
  22525. * @returns a string
  22526. */
  22527. generateCode(): string;
  22528. /**
  22529. * Serializes this material in a JSON representation
  22530. * @returns the serialized material object
  22531. */
  22532. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22533. private _restoreConnections;
  22534. /**
  22535. * Clear the current graph and load a new one from a serialization object
  22536. * @param source defines the JSON representation of the material
  22537. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22538. * @param merge defines whether or not the source must be merged or replace the current content
  22539. */
  22540. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22541. /**
  22542. * Makes a duplicate of the current material.
  22543. * @param name - name to use for the new material.
  22544. */
  22545. clone(name: string): NodeMaterial;
  22546. /**
  22547. * Creates a node material from parsed material data
  22548. * @param source defines the JSON representation of the material
  22549. * @param scene defines the hosting scene
  22550. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22551. * @returns a new node material
  22552. */
  22553. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22554. /**
  22555. * Creates a node material from a snippet saved in a remote file
  22556. * @param name defines the name of the material to create
  22557. * @param url defines the url to load from
  22558. * @param scene defines the hosting scene
  22559. * @returns a promise that will resolve to the new node material
  22560. */
  22561. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22562. /**
  22563. * Creates a node material from a snippet saved by the node material editor
  22564. * @param snippetId defines the snippet to load
  22565. * @param scene defines the hosting scene
  22566. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22567. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22568. * @returns a promise that will resolve to the new node material
  22569. */
  22570. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22571. /**
  22572. * Creates a new node material set to default basic configuration
  22573. * @param name defines the name of the material
  22574. * @param scene defines the hosting scene
  22575. * @returns a new NodeMaterial
  22576. */
  22577. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22578. }
  22579. }
  22580. declare module BABYLON {
  22581. /**
  22582. * Size options for a post process
  22583. */
  22584. export type PostProcessOptions = {
  22585. width: number;
  22586. height: number;
  22587. };
  22588. /**
  22589. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22590. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22591. */
  22592. export class PostProcess {
  22593. /**
  22594. * Gets or sets the unique id of the post process
  22595. */
  22596. uniqueId: number;
  22597. /** Name of the PostProcess. */
  22598. name: string;
  22599. /**
  22600. * Width of the texture to apply the post process on
  22601. */
  22602. width: number;
  22603. /**
  22604. * Height of the texture to apply the post process on
  22605. */
  22606. height: number;
  22607. /**
  22608. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22609. */
  22610. nodeMaterialSource: Nullable<NodeMaterial>;
  22611. /**
  22612. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22613. * @hidden
  22614. */
  22615. _outputTexture: Nullable<InternalTexture>;
  22616. /**
  22617. * Sampling mode used by the shader
  22618. * See https://doc.babylonjs.com/classes/3.1/texture
  22619. */
  22620. renderTargetSamplingMode: number;
  22621. /**
  22622. * Clear color to use when screen clearing
  22623. */
  22624. clearColor: Color4;
  22625. /**
  22626. * If the buffer needs to be cleared before applying the post process. (default: true)
  22627. * Should be set to false if shader will overwrite all previous pixels.
  22628. */
  22629. autoClear: boolean;
  22630. /**
  22631. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22632. */
  22633. alphaMode: number;
  22634. /**
  22635. * Sets the setAlphaBlendConstants of the babylon engine
  22636. */
  22637. alphaConstants: Color4;
  22638. /**
  22639. * Animations to be used for the post processing
  22640. */
  22641. animations: Animation[];
  22642. /**
  22643. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22644. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22645. */
  22646. enablePixelPerfectMode: boolean;
  22647. /**
  22648. * Force the postprocess to be applied without taking in account viewport
  22649. */
  22650. forceFullscreenViewport: boolean;
  22651. /**
  22652. * List of inspectable custom properties (used by the Inspector)
  22653. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22654. */
  22655. inspectableCustomProperties: IInspectable[];
  22656. /**
  22657. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22658. *
  22659. * | Value | Type | Description |
  22660. * | ----- | ----------------------------------- | ----------- |
  22661. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22662. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22663. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22664. *
  22665. */
  22666. scaleMode: number;
  22667. /**
  22668. * Force textures to be a power of two (default: false)
  22669. */
  22670. alwaysForcePOT: boolean;
  22671. private _samples;
  22672. /**
  22673. * Number of sample textures (default: 1)
  22674. */
  22675. get samples(): number;
  22676. set samples(n: number);
  22677. /**
  22678. * Modify the scale of the post process to be the same as the viewport (default: false)
  22679. */
  22680. adaptScaleToCurrentViewport: boolean;
  22681. private _camera;
  22682. protected _scene: Scene;
  22683. private _engine;
  22684. private _options;
  22685. private _reusable;
  22686. private _textureType;
  22687. private _textureFormat;
  22688. /**
  22689. * Smart array of input and output textures for the post process.
  22690. * @hidden
  22691. */
  22692. _textures: SmartArray<InternalTexture>;
  22693. /**
  22694. * The index in _textures that corresponds to the output texture.
  22695. * @hidden
  22696. */
  22697. _currentRenderTextureInd: number;
  22698. private _effect;
  22699. private _samplers;
  22700. private _fragmentUrl;
  22701. private _vertexUrl;
  22702. private _parameters;
  22703. private _scaleRatio;
  22704. protected _indexParameters: any;
  22705. private _shareOutputWithPostProcess;
  22706. private _texelSize;
  22707. private _forcedOutputTexture;
  22708. /**
  22709. * Returns the fragment url or shader name used in the post process.
  22710. * @returns the fragment url or name in the shader store.
  22711. */
  22712. getEffectName(): string;
  22713. /**
  22714. * An event triggered when the postprocess is activated.
  22715. */
  22716. onActivateObservable: Observable<Camera>;
  22717. private _onActivateObserver;
  22718. /**
  22719. * A function that is added to the onActivateObservable
  22720. */
  22721. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22722. /**
  22723. * An event triggered when the postprocess changes its size.
  22724. */
  22725. onSizeChangedObservable: Observable<PostProcess>;
  22726. private _onSizeChangedObserver;
  22727. /**
  22728. * A function that is added to the onSizeChangedObservable
  22729. */
  22730. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22731. /**
  22732. * An event triggered when the postprocess applies its effect.
  22733. */
  22734. onApplyObservable: Observable<Effect>;
  22735. private _onApplyObserver;
  22736. /**
  22737. * A function that is added to the onApplyObservable
  22738. */
  22739. set onApply(callback: (effect: Effect) => void);
  22740. /**
  22741. * An event triggered before rendering the postprocess
  22742. */
  22743. onBeforeRenderObservable: Observable<Effect>;
  22744. private _onBeforeRenderObserver;
  22745. /**
  22746. * A function that is added to the onBeforeRenderObservable
  22747. */
  22748. set onBeforeRender(callback: (effect: Effect) => void);
  22749. /**
  22750. * An event triggered after rendering the postprocess
  22751. */
  22752. onAfterRenderObservable: Observable<Effect>;
  22753. private _onAfterRenderObserver;
  22754. /**
  22755. * A function that is added to the onAfterRenderObservable
  22756. */
  22757. set onAfterRender(callback: (efect: Effect) => void);
  22758. /**
  22759. * 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
  22760. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22761. */
  22762. get inputTexture(): InternalTexture;
  22763. set inputTexture(value: InternalTexture);
  22764. /**
  22765. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  22766. * the only way to unset it is to use this function to restore its internal state
  22767. */
  22768. restoreDefaultInputTexture(): void;
  22769. /**
  22770. * Gets the camera which post process is applied to.
  22771. * @returns The camera the post process is applied to.
  22772. */
  22773. getCamera(): Camera;
  22774. /**
  22775. * Gets the texel size of the postprocess.
  22776. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22777. */
  22778. get texelSize(): Vector2;
  22779. /**
  22780. * Creates a new instance PostProcess
  22781. * @param name The name of the PostProcess.
  22782. * @param fragmentUrl The url of the fragment shader to be used.
  22783. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22784. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22785. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22786. * @param camera The camera to apply the render pass to.
  22787. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22788. * @param engine The engine which the post process will be applied. (default: current engine)
  22789. * @param reusable If the post process can be reused on the same frame. (default: false)
  22790. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22791. * @param textureType Type of textures used when performing the post process. (default: 0)
  22792. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22793. * @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
  22794. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22795. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22796. */
  22797. 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);
  22798. /**
  22799. * Gets a string identifying the name of the class
  22800. * @returns "PostProcess" string
  22801. */
  22802. getClassName(): string;
  22803. /**
  22804. * Gets the engine which this post process belongs to.
  22805. * @returns The engine the post process was enabled with.
  22806. */
  22807. getEngine(): Engine;
  22808. /**
  22809. * The effect that is created when initializing the post process.
  22810. * @returns The created effect corresponding the the postprocess.
  22811. */
  22812. getEffect(): Effect;
  22813. /**
  22814. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22815. * @param postProcess The post process to share the output with.
  22816. * @returns This post process.
  22817. */
  22818. shareOutputWith(postProcess: PostProcess): PostProcess;
  22819. /**
  22820. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22821. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22822. */
  22823. useOwnOutput(): void;
  22824. /**
  22825. * Updates the effect with the current post process compile time values and recompiles the shader.
  22826. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22827. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22828. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22829. * @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
  22830. * @param onCompiled Called when the shader has been compiled.
  22831. * @param onError Called if there is an error when compiling a shader.
  22832. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22833. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22834. */
  22835. 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;
  22836. /**
  22837. * The post process is reusable if it can be used multiple times within one frame.
  22838. * @returns If the post process is reusable
  22839. */
  22840. isReusable(): boolean;
  22841. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22842. markTextureDirty(): void;
  22843. /**
  22844. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22845. * 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.
  22846. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22847. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22848. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22849. * @returns The target texture that was bound to be written to.
  22850. */
  22851. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22852. /**
  22853. * If the post process is supported.
  22854. */
  22855. get isSupported(): boolean;
  22856. /**
  22857. * The aspect ratio of the output texture.
  22858. */
  22859. get aspectRatio(): number;
  22860. /**
  22861. * Get a value indicating if the post-process is ready to be used
  22862. * @returns true if the post-process is ready (shader is compiled)
  22863. */
  22864. isReady(): boolean;
  22865. /**
  22866. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22867. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22868. */
  22869. apply(): Nullable<Effect>;
  22870. private _disposeTextures;
  22871. /**
  22872. * Disposes the post process.
  22873. * @param camera The camera to dispose the post process on.
  22874. */
  22875. dispose(camera?: Camera): void;
  22876. /**
  22877. * Serializes the particle system to a JSON object
  22878. * @returns the JSON object
  22879. */
  22880. serialize(): any;
  22881. /**
  22882. * Creates a material from parsed material data
  22883. * @param parsedPostProcess defines parsed post process data
  22884. * @param scene defines the hosting scene
  22885. * @param rootUrl defines the root URL to use to load textures
  22886. * @returns a new post process
  22887. */
  22888. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  22889. }
  22890. }
  22891. declare module BABYLON {
  22892. /** @hidden */
  22893. export var kernelBlurVaryingDeclaration: {
  22894. name: string;
  22895. shader: string;
  22896. };
  22897. }
  22898. declare module BABYLON {
  22899. /** @hidden */
  22900. export var kernelBlurFragment: {
  22901. name: string;
  22902. shader: string;
  22903. };
  22904. }
  22905. declare module BABYLON {
  22906. /** @hidden */
  22907. export var kernelBlurFragment2: {
  22908. name: string;
  22909. shader: string;
  22910. };
  22911. }
  22912. declare module BABYLON {
  22913. /** @hidden */
  22914. export var kernelBlurPixelShader: {
  22915. name: string;
  22916. shader: string;
  22917. };
  22918. }
  22919. declare module BABYLON {
  22920. /** @hidden */
  22921. export var kernelBlurVertex: {
  22922. name: string;
  22923. shader: string;
  22924. };
  22925. }
  22926. declare module BABYLON {
  22927. /** @hidden */
  22928. export var kernelBlurVertexShader: {
  22929. name: string;
  22930. shader: string;
  22931. };
  22932. }
  22933. declare module BABYLON {
  22934. /**
  22935. * The Blur Post Process which blurs an image based on a kernel and direction.
  22936. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22937. */
  22938. export class BlurPostProcess extends PostProcess {
  22939. private blockCompilation;
  22940. protected _kernel: number;
  22941. protected _idealKernel: number;
  22942. protected _packedFloat: boolean;
  22943. private _staticDefines;
  22944. /** The direction in which to blur the image. */
  22945. direction: Vector2;
  22946. /**
  22947. * Sets the length in pixels of the blur sample region
  22948. */
  22949. set kernel(v: number);
  22950. /**
  22951. * Gets the length in pixels of the blur sample region
  22952. */
  22953. get kernel(): number;
  22954. /**
  22955. * Sets wether or not the blur needs to unpack/repack floats
  22956. */
  22957. set packedFloat(v: boolean);
  22958. /**
  22959. * Gets wether or not the blur is unpacking/repacking floats
  22960. */
  22961. get packedFloat(): boolean;
  22962. /**
  22963. * Gets a string identifying the name of the class
  22964. * @returns "BlurPostProcess" string
  22965. */
  22966. getClassName(): string;
  22967. /**
  22968. * Creates a new instance BlurPostProcess
  22969. * @param name The name of the effect.
  22970. * @param direction The direction in which to blur the image.
  22971. * @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.
  22972. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22973. * @param camera The camera to apply the render pass to.
  22974. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22975. * @param engine The engine which the post process will be applied. (default: current engine)
  22976. * @param reusable If the post process can be reused on the same frame. (default: false)
  22977. * @param textureType Type of textures used when performing the post process. (default: 0)
  22978. * @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)
  22979. */
  22980. 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);
  22981. /**
  22982. * Updates the effect with the current post process compile time values and recompiles the shader.
  22983. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22984. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22985. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22986. * @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
  22987. * @param onCompiled Called when the shader has been compiled.
  22988. * @param onError Called if there is an error when compiling a shader.
  22989. */
  22990. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22991. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22992. /**
  22993. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22994. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22995. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22996. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22997. * The gaps between physical kernels are compensated for in the weighting of the samples
  22998. * @param idealKernel Ideal blur kernel.
  22999. * @return Nearest best kernel.
  23000. */
  23001. protected _nearestBestKernel(idealKernel: number): number;
  23002. /**
  23003. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23004. * @param x The point on the Gaussian distribution to sample.
  23005. * @return the value of the Gaussian function at x.
  23006. */
  23007. protected _gaussianWeight(x: number): number;
  23008. /**
  23009. * Generates a string that can be used as a floating point number in GLSL.
  23010. * @param x Value to print.
  23011. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23012. * @return GLSL float string.
  23013. */
  23014. protected _glslFloat(x: number, decimalFigures?: number): string;
  23015. /** @hidden */
  23016. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23017. }
  23018. }
  23019. declare module BABYLON {
  23020. /**
  23021. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23022. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23023. * You can then easily use it as a reflectionTexture on a flat surface.
  23024. * In case the surface is not a plane, please consider relying on reflection probes.
  23025. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23026. */
  23027. export class MirrorTexture extends RenderTargetTexture {
  23028. private scene;
  23029. /**
  23030. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23031. * 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.
  23032. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23033. */
  23034. mirrorPlane: Plane;
  23035. /**
  23036. * Define the blur ratio used to blur the reflection if needed.
  23037. */
  23038. set blurRatio(value: number);
  23039. get blurRatio(): number;
  23040. /**
  23041. * Define the adaptive blur kernel used to blur the reflection if needed.
  23042. * This will autocompute the closest best match for the `blurKernel`
  23043. */
  23044. set adaptiveBlurKernel(value: number);
  23045. /**
  23046. * Define the blur kernel used to blur the reflection if needed.
  23047. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23048. */
  23049. set blurKernel(value: number);
  23050. /**
  23051. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23052. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23053. */
  23054. set blurKernelX(value: number);
  23055. get blurKernelX(): number;
  23056. /**
  23057. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23058. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23059. */
  23060. set blurKernelY(value: number);
  23061. get blurKernelY(): number;
  23062. private _autoComputeBlurKernel;
  23063. protected _onRatioRescale(): void;
  23064. private _updateGammaSpace;
  23065. private _imageProcessingConfigChangeObserver;
  23066. private _transformMatrix;
  23067. private _mirrorMatrix;
  23068. private _savedViewMatrix;
  23069. private _blurX;
  23070. private _blurY;
  23071. private _adaptiveBlurKernel;
  23072. private _blurKernelX;
  23073. private _blurKernelY;
  23074. private _blurRatio;
  23075. /**
  23076. * Instantiates a Mirror Texture.
  23077. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23078. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23079. * You can then easily use it as a reflectionTexture on a flat surface.
  23080. * In case the surface is not a plane, please consider relying on reflection probes.
  23081. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23082. * @param name
  23083. * @param size
  23084. * @param scene
  23085. * @param generateMipMaps
  23086. * @param type
  23087. * @param samplingMode
  23088. * @param generateDepthBuffer
  23089. */
  23090. constructor(name: string, size: number | {
  23091. width: number;
  23092. height: number;
  23093. } | {
  23094. ratio: number;
  23095. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23096. private _preparePostProcesses;
  23097. /**
  23098. * Clone the mirror texture.
  23099. * @returns the cloned texture
  23100. */
  23101. clone(): MirrorTexture;
  23102. /**
  23103. * Serialize the texture to a JSON representation you could use in Parse later on
  23104. * @returns the serialized JSON representation
  23105. */
  23106. serialize(): any;
  23107. /**
  23108. * Dispose the texture and release its associated resources.
  23109. */
  23110. dispose(): void;
  23111. }
  23112. }
  23113. declare module BABYLON {
  23114. /**
  23115. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23116. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23117. */
  23118. export class Texture extends BaseTexture {
  23119. /**
  23120. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23121. */
  23122. static SerializeBuffers: boolean;
  23123. /** @hidden */
  23124. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23125. /** @hidden */
  23126. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23127. /** @hidden */
  23128. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23129. /** nearest is mag = nearest and min = nearest and mip = linear */
  23130. static readonly NEAREST_SAMPLINGMODE: number;
  23131. /** nearest is mag = nearest and min = nearest and mip = linear */
  23132. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23133. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23134. static readonly BILINEAR_SAMPLINGMODE: number;
  23135. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23136. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23137. /** Trilinear is mag = linear and min = linear and mip = linear */
  23138. static readonly TRILINEAR_SAMPLINGMODE: number;
  23139. /** Trilinear is mag = linear and min = linear and mip = linear */
  23140. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23141. /** mag = nearest and min = nearest and mip = nearest */
  23142. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23143. /** mag = nearest and min = linear and mip = nearest */
  23144. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23145. /** mag = nearest and min = linear and mip = linear */
  23146. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23147. /** mag = nearest and min = linear and mip = none */
  23148. static readonly NEAREST_LINEAR: number;
  23149. /** mag = nearest and min = nearest and mip = none */
  23150. static readonly NEAREST_NEAREST: number;
  23151. /** mag = linear and min = nearest and mip = nearest */
  23152. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23153. /** mag = linear and min = nearest and mip = linear */
  23154. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23155. /** mag = linear and min = linear and mip = none */
  23156. static readonly LINEAR_LINEAR: number;
  23157. /** mag = linear and min = nearest and mip = none */
  23158. static readonly LINEAR_NEAREST: number;
  23159. /** Explicit coordinates mode */
  23160. static readonly EXPLICIT_MODE: number;
  23161. /** Spherical coordinates mode */
  23162. static readonly SPHERICAL_MODE: number;
  23163. /** Planar coordinates mode */
  23164. static readonly PLANAR_MODE: number;
  23165. /** Cubic coordinates mode */
  23166. static readonly CUBIC_MODE: number;
  23167. /** Projection coordinates mode */
  23168. static readonly PROJECTION_MODE: number;
  23169. /** Inverse Cubic coordinates mode */
  23170. static readonly SKYBOX_MODE: number;
  23171. /** Inverse Cubic coordinates mode */
  23172. static readonly INVCUBIC_MODE: number;
  23173. /** Equirectangular coordinates mode */
  23174. static readonly EQUIRECTANGULAR_MODE: number;
  23175. /** Equirectangular Fixed coordinates mode */
  23176. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23177. /** Equirectangular Fixed Mirrored coordinates mode */
  23178. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23179. /** Texture is not repeating outside of 0..1 UVs */
  23180. static readonly CLAMP_ADDRESSMODE: number;
  23181. /** Texture is repeating outside of 0..1 UVs */
  23182. static readonly WRAP_ADDRESSMODE: number;
  23183. /** Texture is repeating and mirrored */
  23184. static readonly MIRROR_ADDRESSMODE: number;
  23185. /**
  23186. * 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
  23187. */
  23188. static UseSerializedUrlIfAny: boolean;
  23189. /**
  23190. * Define the url of the texture.
  23191. */
  23192. url: Nullable<string>;
  23193. /**
  23194. * Define an offset on the texture to offset the u coordinates of the UVs
  23195. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23196. */
  23197. uOffset: number;
  23198. /**
  23199. * Define an offset on the texture to offset the v coordinates of the UVs
  23200. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23201. */
  23202. vOffset: number;
  23203. /**
  23204. * Define an offset on the texture to scale the u coordinates of the UVs
  23205. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23206. */
  23207. uScale: number;
  23208. /**
  23209. * Define an offset on the texture to scale the v coordinates of the UVs
  23210. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23211. */
  23212. vScale: number;
  23213. /**
  23214. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23215. * @see https://doc.babylonjs.com/how_to/more_materials
  23216. */
  23217. uAng: number;
  23218. /**
  23219. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23220. * @see https://doc.babylonjs.com/how_to/more_materials
  23221. */
  23222. vAng: number;
  23223. /**
  23224. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23225. * @see https://doc.babylonjs.com/how_to/more_materials
  23226. */
  23227. wAng: number;
  23228. /**
  23229. * Defines the center of rotation (U)
  23230. */
  23231. uRotationCenter: number;
  23232. /**
  23233. * Defines the center of rotation (V)
  23234. */
  23235. vRotationCenter: number;
  23236. /**
  23237. * Defines the center of rotation (W)
  23238. */
  23239. wRotationCenter: number;
  23240. /**
  23241. * Are mip maps generated for this texture or not.
  23242. */
  23243. get noMipmap(): boolean;
  23244. /**
  23245. * List of inspectable custom properties (used by the Inspector)
  23246. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23247. */
  23248. inspectableCustomProperties: Nullable<IInspectable[]>;
  23249. private _noMipmap;
  23250. /** @hidden */
  23251. _invertY: boolean;
  23252. private _rowGenerationMatrix;
  23253. private _cachedTextureMatrix;
  23254. private _projectionModeMatrix;
  23255. private _t0;
  23256. private _t1;
  23257. private _t2;
  23258. private _cachedUOffset;
  23259. private _cachedVOffset;
  23260. private _cachedUScale;
  23261. private _cachedVScale;
  23262. private _cachedUAng;
  23263. private _cachedVAng;
  23264. private _cachedWAng;
  23265. private _cachedProjectionMatrixId;
  23266. private _cachedCoordinatesMode;
  23267. /** @hidden */
  23268. protected _initialSamplingMode: number;
  23269. /** @hidden */
  23270. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23271. private _deleteBuffer;
  23272. protected _format: Nullable<number>;
  23273. private _delayedOnLoad;
  23274. private _delayedOnError;
  23275. private _mimeType?;
  23276. /**
  23277. * Observable triggered once the texture has been loaded.
  23278. */
  23279. onLoadObservable: Observable<Texture>;
  23280. protected _isBlocking: boolean;
  23281. /**
  23282. * Is the texture preventing material to render while loading.
  23283. * If false, a default texture will be used instead of the loading one during the preparation step.
  23284. */
  23285. set isBlocking(value: boolean);
  23286. get isBlocking(): boolean;
  23287. /**
  23288. * Get the current sampling mode associated with the texture.
  23289. */
  23290. get samplingMode(): number;
  23291. /**
  23292. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23293. */
  23294. get invertY(): boolean;
  23295. /**
  23296. * Instantiates a new texture.
  23297. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23298. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23299. * @param url defines the url of the picture to load as a texture
  23300. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23301. * @param noMipmap defines if the texture will require mip maps or not
  23302. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23303. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23304. * @param onLoad defines a callback triggered when the texture has been loaded
  23305. * @param onError defines a callback triggered when an error occurred during the loading session
  23306. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23307. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23308. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23309. * @param mimeType defines an optional mime type information
  23310. */
  23311. 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);
  23312. /**
  23313. * Update the url (and optional buffer) of this texture if url was null during construction.
  23314. * @param url the url of the texture
  23315. * @param buffer the buffer of the texture (defaults to null)
  23316. * @param onLoad callback called when the texture is loaded (defaults to null)
  23317. */
  23318. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23319. /**
  23320. * Finish the loading sequence of a texture flagged as delayed load.
  23321. * @hidden
  23322. */
  23323. delayLoad(): void;
  23324. private _prepareRowForTextureGeneration;
  23325. /**
  23326. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23327. * @returns the transform matrix of the texture.
  23328. */
  23329. getTextureMatrix(uBase?: number): Matrix;
  23330. /**
  23331. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23332. * @returns The reflection texture transform
  23333. */
  23334. getReflectionTextureMatrix(): Matrix;
  23335. /**
  23336. * Clones the texture.
  23337. * @returns the cloned texture
  23338. */
  23339. clone(): Texture;
  23340. /**
  23341. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23342. * @returns The JSON representation of the texture
  23343. */
  23344. serialize(): any;
  23345. /**
  23346. * Get the current class name of the texture useful for serialization or dynamic coding.
  23347. * @returns "Texture"
  23348. */
  23349. getClassName(): string;
  23350. /**
  23351. * Dispose the texture and release its associated resources.
  23352. */
  23353. dispose(): void;
  23354. /**
  23355. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23356. * @param parsedTexture Define the JSON representation of the texture
  23357. * @param scene Define the scene the parsed texture should be instantiated in
  23358. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23359. * @returns The parsed texture if successful
  23360. */
  23361. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23362. /**
  23363. * Creates a texture from its base 64 representation.
  23364. * @param data Define the base64 payload without the data: prefix
  23365. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23366. * @param scene Define the scene the texture should belong to
  23367. * @param noMipmap Forces the texture to not create mip map information if true
  23368. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23369. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23370. * @param onLoad define a callback triggered when the texture has been loaded
  23371. * @param onError define a callback triggered when an error occurred during the loading session
  23372. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23373. * @returns the created texture
  23374. */
  23375. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23376. /**
  23377. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23378. * @param data Define the base64 payload without the data: prefix
  23379. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23380. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23381. * @param scene Define the scene the texture should belong to
  23382. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23383. * @param noMipmap Forces the texture to not create mip map information if true
  23384. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23385. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23386. * @param onLoad define a callback triggered when the texture has been loaded
  23387. * @param onError define a callback triggered when an error occurred during the loading session
  23388. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23389. * @returns the created texture
  23390. */
  23391. 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;
  23392. }
  23393. }
  23394. declare module BABYLON {
  23395. /**
  23396. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23397. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23398. */
  23399. export class PostProcessManager {
  23400. private _scene;
  23401. private _indexBuffer;
  23402. private _vertexBuffers;
  23403. /**
  23404. * Creates a new instance PostProcess
  23405. * @param scene The scene that the post process is associated with.
  23406. */
  23407. constructor(scene: Scene);
  23408. private _prepareBuffers;
  23409. private _buildIndexBuffer;
  23410. /**
  23411. * Rebuilds the vertex buffers of the manager.
  23412. * @hidden
  23413. */
  23414. _rebuild(): void;
  23415. /**
  23416. * Prepares a frame to be run through a post process.
  23417. * @param sourceTexture The input texture to the post procesess. (default: null)
  23418. * @param postProcesses An array of post processes to be run. (default: null)
  23419. * @returns True if the post processes were able to be run.
  23420. * @hidden
  23421. */
  23422. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23423. /**
  23424. * Manually render a set of post processes to a texture.
  23425. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23426. * @param postProcesses An array of post processes to be run.
  23427. * @param targetTexture The target texture to render to.
  23428. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23429. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23430. * @param lodLevel defines which lod of the texture to render to
  23431. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  23432. */
  23433. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  23434. /**
  23435. * Finalize the result of the output of the postprocesses.
  23436. * @param doNotPresent If true the result will not be displayed to the screen.
  23437. * @param targetTexture The target texture to render to.
  23438. * @param faceIndex The index of the face to bind the target texture to.
  23439. * @param postProcesses The array of post processes to render.
  23440. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23441. * @hidden
  23442. */
  23443. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23444. /**
  23445. * Disposes of the post process manager.
  23446. */
  23447. dispose(): void;
  23448. }
  23449. }
  23450. declare module BABYLON {
  23451. /**
  23452. * This Helps creating a texture that will be created from a camera in your scene.
  23453. * It is basically a dynamic texture that could be used to create special effects for instance.
  23454. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23455. */
  23456. export class RenderTargetTexture extends Texture {
  23457. isCube: boolean;
  23458. /**
  23459. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23460. */
  23461. static readonly REFRESHRATE_RENDER_ONCE: number;
  23462. /**
  23463. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23464. */
  23465. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23466. /**
  23467. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23468. * the central point of your effect and can save a lot of performances.
  23469. */
  23470. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23471. /**
  23472. * Use this predicate to dynamically define the list of mesh you want to render.
  23473. * If set, the renderList property will be overwritten.
  23474. */
  23475. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23476. private _renderList;
  23477. /**
  23478. * Use this list to define the list of mesh you want to render.
  23479. */
  23480. get renderList(): Nullable<Array<AbstractMesh>>;
  23481. set renderList(value: Nullable<Array<AbstractMesh>>);
  23482. /**
  23483. * Use this function to overload the renderList array at rendering time.
  23484. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23485. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23486. * the cube (if the RTT is a cube, else layerOrFace=0).
  23487. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23488. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23489. * hold dummy elements!
  23490. */
  23491. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23492. private _hookArray;
  23493. /**
  23494. * Define if particles should be rendered in your texture.
  23495. */
  23496. renderParticles: boolean;
  23497. /**
  23498. * Define if sprites should be rendered in your texture.
  23499. */
  23500. renderSprites: boolean;
  23501. /**
  23502. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  23503. */
  23504. coordinatesMode: number;
  23505. /**
  23506. * Define the camera used to render the texture.
  23507. */
  23508. activeCamera: Nullable<Camera>;
  23509. /**
  23510. * Override the mesh isReady function with your own one.
  23511. */
  23512. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23513. /**
  23514. * Override the render function of the texture with your own one.
  23515. */
  23516. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23517. /**
  23518. * Define if camera post processes should be use while rendering the texture.
  23519. */
  23520. useCameraPostProcesses: boolean;
  23521. /**
  23522. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23523. */
  23524. ignoreCameraViewport: boolean;
  23525. private _postProcessManager;
  23526. private _postProcesses;
  23527. private _resizeObserver;
  23528. /**
  23529. * An event triggered when the texture is unbind.
  23530. */
  23531. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23532. /**
  23533. * An event triggered when the texture is unbind.
  23534. */
  23535. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23536. private _onAfterUnbindObserver;
  23537. /**
  23538. * Set a after unbind callback in the texture.
  23539. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23540. */
  23541. set onAfterUnbind(callback: () => void);
  23542. /**
  23543. * An event triggered before rendering the texture
  23544. */
  23545. onBeforeRenderObservable: Observable<number>;
  23546. private _onBeforeRenderObserver;
  23547. /**
  23548. * Set a before render callback in the texture.
  23549. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23550. */
  23551. set onBeforeRender(callback: (faceIndex: number) => void);
  23552. /**
  23553. * An event triggered after rendering the texture
  23554. */
  23555. onAfterRenderObservable: Observable<number>;
  23556. private _onAfterRenderObserver;
  23557. /**
  23558. * Set a after render callback in the texture.
  23559. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23560. */
  23561. set onAfterRender(callback: (faceIndex: number) => void);
  23562. /**
  23563. * An event triggered after the texture clear
  23564. */
  23565. onClearObservable: Observable<Engine>;
  23566. private _onClearObserver;
  23567. /**
  23568. * Set a clear callback in the texture.
  23569. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23570. */
  23571. set onClear(callback: (Engine: Engine) => void);
  23572. /**
  23573. * An event triggered when the texture is resized.
  23574. */
  23575. onResizeObservable: Observable<RenderTargetTexture>;
  23576. /**
  23577. * Define the clear color of the Render Target if it should be different from the scene.
  23578. */
  23579. clearColor: Color4;
  23580. protected _size: number | {
  23581. width: number;
  23582. height: number;
  23583. layers?: number;
  23584. };
  23585. protected _initialSizeParameter: number | {
  23586. width: number;
  23587. height: number;
  23588. } | {
  23589. ratio: number;
  23590. };
  23591. protected _sizeRatio: Nullable<number>;
  23592. /** @hidden */
  23593. _generateMipMaps: boolean;
  23594. protected _renderingManager: RenderingManager;
  23595. /** @hidden */
  23596. _waitingRenderList: string[];
  23597. protected _doNotChangeAspectRatio: boolean;
  23598. protected _currentRefreshId: number;
  23599. protected _refreshRate: number;
  23600. protected _textureMatrix: Matrix;
  23601. protected _samples: number;
  23602. protected _renderTargetOptions: RenderTargetCreationOptions;
  23603. /**
  23604. * Gets render target creation options that were used.
  23605. */
  23606. get renderTargetOptions(): RenderTargetCreationOptions;
  23607. protected _onRatioRescale(): void;
  23608. /**
  23609. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23610. * It must define where the camera used to render the texture is set
  23611. */
  23612. boundingBoxPosition: Vector3;
  23613. private _boundingBoxSize;
  23614. /**
  23615. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23616. * When defined, the cubemap will switch to local mode
  23617. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23618. * @example https://www.babylonjs-playground.com/#RNASML
  23619. */
  23620. set boundingBoxSize(value: Vector3);
  23621. get boundingBoxSize(): Vector3;
  23622. /**
  23623. * In case the RTT has been created with a depth texture, get the associated
  23624. * depth texture.
  23625. * Otherwise, return null.
  23626. */
  23627. get depthStencilTexture(): Nullable<InternalTexture>;
  23628. /**
  23629. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23630. * or used a shadow, depth texture...
  23631. * @param name The friendly name of the texture
  23632. * @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)
  23633. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23634. * @param generateMipMaps True if mip maps need to be generated after render.
  23635. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23636. * @param type The type of the buffer in the RTT (int, half float, float...)
  23637. * @param isCube True if a cube texture needs to be created
  23638. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23639. * @param generateDepthBuffer True to generate a depth buffer
  23640. * @param generateStencilBuffer True to generate a stencil buffer
  23641. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23642. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23643. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23644. */
  23645. constructor(name: string, size: number | {
  23646. width: number;
  23647. height: number;
  23648. layers?: number;
  23649. } | {
  23650. ratio: number;
  23651. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23652. /**
  23653. * Creates a depth stencil texture.
  23654. * This is only available in WebGL 2 or with the depth texture extension available.
  23655. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23656. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23657. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23658. */
  23659. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23660. private _processSizeParameter;
  23661. /**
  23662. * Define the number of samples to use in case of MSAA.
  23663. * It defaults to one meaning no MSAA has been enabled.
  23664. */
  23665. get samples(): number;
  23666. set samples(value: number);
  23667. /**
  23668. * Resets the refresh counter of the texture and start bak from scratch.
  23669. * Could be useful to regenerate the texture if it is setup to render only once.
  23670. */
  23671. resetRefreshCounter(): void;
  23672. /**
  23673. * Define the refresh rate of the texture or the rendering frequency.
  23674. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23675. */
  23676. get refreshRate(): number;
  23677. set refreshRate(value: number);
  23678. /**
  23679. * Adds a post process to the render target rendering passes.
  23680. * @param postProcess define the post process to add
  23681. */
  23682. addPostProcess(postProcess: PostProcess): void;
  23683. /**
  23684. * Clear all the post processes attached to the render target
  23685. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23686. */
  23687. clearPostProcesses(dispose?: boolean): void;
  23688. /**
  23689. * Remove one of the post process from the list of attached post processes to the texture
  23690. * @param postProcess define the post process to remove from the list
  23691. */
  23692. removePostProcess(postProcess: PostProcess): void;
  23693. /** @hidden */
  23694. _shouldRender(): boolean;
  23695. /**
  23696. * Gets the actual render size of the texture.
  23697. * @returns the width of the render size
  23698. */
  23699. getRenderSize(): number;
  23700. /**
  23701. * Gets the actual render width of the texture.
  23702. * @returns the width of the render size
  23703. */
  23704. getRenderWidth(): number;
  23705. /**
  23706. * Gets the actual render height of the texture.
  23707. * @returns the height of the render size
  23708. */
  23709. getRenderHeight(): number;
  23710. /**
  23711. * Gets the actual number of layers of the texture.
  23712. * @returns the number of layers
  23713. */
  23714. getRenderLayers(): number;
  23715. /**
  23716. * Get if the texture can be rescaled or not.
  23717. */
  23718. get canRescale(): boolean;
  23719. /**
  23720. * Resize the texture using a ratio.
  23721. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23722. */
  23723. scale(ratio: number): void;
  23724. /**
  23725. * Get the texture reflection matrix used to rotate/transform the reflection.
  23726. * @returns the reflection matrix
  23727. */
  23728. getReflectionTextureMatrix(): Matrix;
  23729. /**
  23730. * Resize the texture to a new desired size.
  23731. * Be carrefull as it will recreate all the data in the new texture.
  23732. * @param size Define the new size. It can be:
  23733. * - a number for squared texture,
  23734. * - an object containing { width: number, height: number }
  23735. * - or an object containing a ratio { ratio: number }
  23736. */
  23737. resize(size: number | {
  23738. width: number;
  23739. height: number;
  23740. } | {
  23741. ratio: number;
  23742. }): void;
  23743. private _defaultRenderListPrepared;
  23744. /**
  23745. * Renders all the objects from the render list into the texture.
  23746. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23747. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23748. */
  23749. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23750. private _bestReflectionRenderTargetDimension;
  23751. private _prepareRenderingManager;
  23752. /**
  23753. * @hidden
  23754. * @param faceIndex face index to bind to if this is a cubetexture
  23755. * @param layer defines the index of the texture to bind in the array
  23756. */
  23757. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23758. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23759. private renderToTarget;
  23760. /**
  23761. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23762. * This allowed control for front to back rendering or reversly depending of the special needs.
  23763. *
  23764. * @param renderingGroupId The rendering group id corresponding to its index
  23765. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23766. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23767. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23768. */
  23769. 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;
  23770. /**
  23771. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23772. *
  23773. * @param renderingGroupId The rendering group id corresponding to its index
  23774. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23775. */
  23776. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23777. /**
  23778. * Clones the texture.
  23779. * @returns the cloned texture
  23780. */
  23781. clone(): RenderTargetTexture;
  23782. /**
  23783. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23784. * @returns The JSON representation of the texture
  23785. */
  23786. serialize(): any;
  23787. /**
  23788. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23789. */
  23790. disposeFramebufferObjects(): void;
  23791. /**
  23792. * Dispose the texture and release its associated resources.
  23793. */
  23794. dispose(): void;
  23795. /** @hidden */
  23796. _rebuild(): void;
  23797. /**
  23798. * Clear the info related to rendering groups preventing retention point in material dispose.
  23799. */
  23800. freeRenderingGroups(): void;
  23801. /**
  23802. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23803. * @returns the view count
  23804. */
  23805. getViewCount(): number;
  23806. }
  23807. }
  23808. declare module BABYLON {
  23809. /**
  23810. * Class used to manipulate GUIDs
  23811. */
  23812. export class GUID {
  23813. /**
  23814. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23815. * Be aware Math.random() could cause collisions, but:
  23816. * "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"
  23817. * @returns a pseudo random id
  23818. */
  23819. static RandomId(): string;
  23820. }
  23821. }
  23822. declare module BABYLON {
  23823. /**
  23824. * Options to be used when creating a shadow depth material
  23825. */
  23826. export interface IIOptionShadowDepthMaterial {
  23827. /** Variables in the vertex shader code that need to have their names remapped.
  23828. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23829. * "var_name" should be either: worldPos or vNormalW
  23830. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23831. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23832. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23833. */
  23834. remappedVariables?: string[];
  23835. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23836. standalone?: boolean;
  23837. }
  23838. /**
  23839. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23840. */
  23841. export class ShadowDepthWrapper {
  23842. private _scene;
  23843. private _options?;
  23844. private _baseMaterial;
  23845. private _onEffectCreatedObserver;
  23846. private _subMeshToEffect;
  23847. private _subMeshToDepthEffect;
  23848. private _meshes;
  23849. /** @hidden */
  23850. _matriceNames: any;
  23851. /** Gets the standalone status of the wrapper */
  23852. get standalone(): boolean;
  23853. /** Gets the base material the wrapper is built upon */
  23854. get baseMaterial(): Material;
  23855. /**
  23856. * Instantiate a new shadow depth wrapper.
  23857. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23858. * generate the shadow depth map. For more information, please refer to the documentation:
  23859. * https://doc.babylonjs.com/babylon101/shadows
  23860. * @param baseMaterial Material to wrap
  23861. * @param scene Define the scene the material belongs to
  23862. * @param options Options used to create the wrapper
  23863. */
  23864. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23865. /**
  23866. * Gets the effect to use to generate the depth map
  23867. * @param subMesh subMesh to get the effect for
  23868. * @param shadowGenerator shadow generator to get the effect for
  23869. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23870. */
  23871. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23872. /**
  23873. * Specifies that the submesh is ready to be used for depth rendering
  23874. * @param subMesh submesh to check
  23875. * @param defines the list of defines to take into account when checking the effect
  23876. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23877. * @param useInstances specifies that instances should be used
  23878. * @returns a boolean indicating that the submesh is ready or not
  23879. */
  23880. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23881. /**
  23882. * Disposes the resources
  23883. */
  23884. dispose(): void;
  23885. private _makeEffect;
  23886. }
  23887. }
  23888. declare module BABYLON {
  23889. interface ThinEngine {
  23890. /**
  23891. * Unbind a list of render target textures from the webGL context
  23892. * This is used only when drawBuffer extension or webGL2 are active
  23893. * @param textures defines the render target textures to unbind
  23894. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23895. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23896. */
  23897. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23898. /**
  23899. * Create a multi render target texture
  23900. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23901. * @param size defines the size of the texture
  23902. * @param options defines the creation options
  23903. * @returns the cube texture as an InternalTexture
  23904. */
  23905. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23906. /**
  23907. * Update the sample count for a given multiple render target texture
  23908. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23909. * @param textures defines the textures to update
  23910. * @param samples defines the sample count to set
  23911. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23912. */
  23913. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23914. /**
  23915. * Select a subsets of attachments to draw to.
  23916. * @param attachments gl attachments
  23917. */
  23918. bindAttachments(attachments: number[]): void;
  23919. }
  23920. }
  23921. declare module BABYLON {
  23922. /**
  23923. * Creation options of the multi render target texture.
  23924. */
  23925. export interface IMultiRenderTargetOptions {
  23926. /**
  23927. * Define if the texture needs to create mip maps after render.
  23928. */
  23929. generateMipMaps?: boolean;
  23930. /**
  23931. * Define the types of all the draw buffers we want to create
  23932. */
  23933. types?: number[];
  23934. /**
  23935. * Define the sampling modes of all the draw buffers we want to create
  23936. */
  23937. samplingModes?: number[];
  23938. /**
  23939. * Define if a depth buffer is required
  23940. */
  23941. generateDepthBuffer?: boolean;
  23942. /**
  23943. * Define if a stencil buffer is required
  23944. */
  23945. generateStencilBuffer?: boolean;
  23946. /**
  23947. * Define if a depth texture is required instead of a depth buffer
  23948. */
  23949. generateDepthTexture?: boolean;
  23950. /**
  23951. * Define the number of desired draw buffers
  23952. */
  23953. textureCount?: number;
  23954. /**
  23955. * Define if aspect ratio should be adapted to the texture or stay the scene one
  23956. */
  23957. doNotChangeAspectRatio?: boolean;
  23958. /**
  23959. * Define the default type of the buffers we are creating
  23960. */
  23961. defaultType?: number;
  23962. }
  23963. /**
  23964. * A multi render target, like a render target provides the ability to render to a texture.
  23965. * Unlike the render target, it can render to several draw buffers in one draw.
  23966. * This is specially interesting in deferred rendering or for any effects requiring more than
  23967. * just one color from a single pass.
  23968. */
  23969. export class MultiRenderTarget extends RenderTargetTexture {
  23970. private _internalTextures;
  23971. private _textures;
  23972. private _multiRenderTargetOptions;
  23973. private _count;
  23974. /**
  23975. * Get if draw buffers are currently supported by the used hardware and browser.
  23976. */
  23977. get isSupported(): boolean;
  23978. /**
  23979. * Get the list of textures generated by the multi render target.
  23980. */
  23981. get textures(): Texture[];
  23982. /**
  23983. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  23984. */
  23985. get count(): number;
  23986. /**
  23987. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  23988. */
  23989. get depthTexture(): Texture;
  23990. /**
  23991. * Set the wrapping mode on U of all the textures we are rendering to.
  23992. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23993. */
  23994. set wrapU(wrap: number);
  23995. /**
  23996. * Set the wrapping mode on V of all the textures we are rendering to.
  23997. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23998. */
  23999. set wrapV(wrap: number);
  24000. /**
  24001. * Instantiate a new multi render target texture.
  24002. * A multi render target, like a render target provides the ability to render to a texture.
  24003. * Unlike the render target, it can render to several draw buffers in one draw.
  24004. * This is specially interesting in deferred rendering or for any effects requiring more than
  24005. * just one color from a single pass.
  24006. * @param name Define the name of the texture
  24007. * @param size Define the size of the buffers to render to
  24008. * @param count Define the number of target we are rendering into
  24009. * @param scene Define the scene the texture belongs to
  24010. * @param options Define the options used to create the multi render target
  24011. */
  24012. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  24013. /** @hidden */
  24014. _rebuild(): void;
  24015. private _createInternalTextures;
  24016. private _createTextures;
  24017. /**
  24018. * Define the number of samples used if MSAA is enabled.
  24019. */
  24020. get samples(): number;
  24021. set samples(value: number);
  24022. /**
  24023. * Resize all the textures in the multi render target.
  24024. * Be carrefull as it will recreate all the data in the new texture.
  24025. * @param size Define the new size
  24026. */
  24027. resize(size: any): void;
  24028. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24029. /**
  24030. * Dispose the render targets and their associated resources
  24031. */
  24032. dispose(): void;
  24033. /**
  24034. * Release all the underlying texture used as draw buffers.
  24035. */
  24036. releaseInternalTextures(): void;
  24037. }
  24038. }
  24039. declare module BABYLON {
  24040. /** @hidden */
  24041. export var imageProcessingPixelShader: {
  24042. name: string;
  24043. shader: string;
  24044. };
  24045. }
  24046. declare module BABYLON {
  24047. /**
  24048. * ImageProcessingPostProcess
  24049. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  24050. */
  24051. export class ImageProcessingPostProcess extends PostProcess {
  24052. /**
  24053. * Default configuration related to image processing available in the PBR Material.
  24054. */
  24055. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24056. /**
  24057. * Gets the image processing configuration used either in this material.
  24058. */
  24059. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24060. /**
  24061. * Sets the Default image processing configuration used either in the this material.
  24062. *
  24063. * If sets to null, the scene one is in use.
  24064. */
  24065. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24066. /**
  24067. * Keep track of the image processing observer to allow dispose and replace.
  24068. */
  24069. private _imageProcessingObserver;
  24070. /**
  24071. * Attaches a new image processing configuration to the PBR Material.
  24072. * @param configuration
  24073. */
  24074. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  24075. /**
  24076. * If the post process is supported.
  24077. */
  24078. get isSupported(): boolean;
  24079. /**
  24080. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24081. */
  24082. get colorCurves(): Nullable<ColorCurves>;
  24083. /**
  24084. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24085. */
  24086. set colorCurves(value: Nullable<ColorCurves>);
  24087. /**
  24088. * Gets wether the color curves effect is enabled.
  24089. */
  24090. get colorCurvesEnabled(): boolean;
  24091. /**
  24092. * Sets wether the color curves effect is enabled.
  24093. */
  24094. set colorCurvesEnabled(value: boolean);
  24095. /**
  24096. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24097. */
  24098. get colorGradingTexture(): Nullable<BaseTexture>;
  24099. /**
  24100. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24101. */
  24102. set colorGradingTexture(value: Nullable<BaseTexture>);
  24103. /**
  24104. * Gets wether the color grading effect is enabled.
  24105. */
  24106. get colorGradingEnabled(): boolean;
  24107. /**
  24108. * Gets wether the color grading effect is enabled.
  24109. */
  24110. set colorGradingEnabled(value: boolean);
  24111. /**
  24112. * Gets exposure used in the effect.
  24113. */
  24114. get exposure(): number;
  24115. /**
  24116. * Sets exposure used in the effect.
  24117. */
  24118. set exposure(value: number);
  24119. /**
  24120. * Gets wether tonemapping is enabled or not.
  24121. */
  24122. get toneMappingEnabled(): boolean;
  24123. /**
  24124. * Sets wether tonemapping is enabled or not
  24125. */
  24126. set toneMappingEnabled(value: boolean);
  24127. /**
  24128. * Gets the type of tone mapping effect.
  24129. */
  24130. get toneMappingType(): number;
  24131. /**
  24132. * Sets the type of tone mapping effect.
  24133. */
  24134. set toneMappingType(value: number);
  24135. /**
  24136. * Gets contrast used in the effect.
  24137. */
  24138. get contrast(): number;
  24139. /**
  24140. * Sets contrast used in the effect.
  24141. */
  24142. set contrast(value: number);
  24143. /**
  24144. * Gets Vignette stretch size.
  24145. */
  24146. get vignetteStretch(): number;
  24147. /**
  24148. * Sets Vignette stretch size.
  24149. */
  24150. set vignetteStretch(value: number);
  24151. /**
  24152. * Gets Vignette centre X Offset.
  24153. */
  24154. get vignetteCentreX(): number;
  24155. /**
  24156. * Sets Vignette centre X Offset.
  24157. */
  24158. set vignetteCentreX(value: number);
  24159. /**
  24160. * Gets Vignette centre Y Offset.
  24161. */
  24162. get vignetteCentreY(): number;
  24163. /**
  24164. * Sets Vignette centre Y Offset.
  24165. */
  24166. set vignetteCentreY(value: number);
  24167. /**
  24168. * Gets Vignette weight or intensity of the vignette effect.
  24169. */
  24170. get vignetteWeight(): number;
  24171. /**
  24172. * Sets Vignette weight or intensity of the vignette effect.
  24173. */
  24174. set vignetteWeight(value: number);
  24175. /**
  24176. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24177. * if vignetteEnabled is set to true.
  24178. */
  24179. get vignetteColor(): Color4;
  24180. /**
  24181. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24182. * if vignetteEnabled is set to true.
  24183. */
  24184. set vignetteColor(value: Color4);
  24185. /**
  24186. * Gets Camera field of view used by the Vignette effect.
  24187. */
  24188. get vignetteCameraFov(): number;
  24189. /**
  24190. * Sets Camera field of view used by the Vignette effect.
  24191. */
  24192. set vignetteCameraFov(value: number);
  24193. /**
  24194. * Gets the vignette blend mode allowing different kind of effect.
  24195. */
  24196. get vignetteBlendMode(): number;
  24197. /**
  24198. * Sets the vignette blend mode allowing different kind of effect.
  24199. */
  24200. set vignetteBlendMode(value: number);
  24201. /**
  24202. * Gets wether the vignette effect is enabled.
  24203. */
  24204. get vignetteEnabled(): boolean;
  24205. /**
  24206. * Sets wether the vignette effect is enabled.
  24207. */
  24208. set vignetteEnabled(value: boolean);
  24209. private _fromLinearSpace;
  24210. /**
  24211. * Gets wether the input of the processing is in Gamma or Linear Space.
  24212. */
  24213. get fromLinearSpace(): boolean;
  24214. /**
  24215. * Sets wether the input of the processing is in Gamma or Linear Space.
  24216. */
  24217. set fromLinearSpace(value: boolean);
  24218. /**
  24219. * Defines cache preventing GC.
  24220. */
  24221. private _defines;
  24222. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24223. /**
  24224. * "ImageProcessingPostProcess"
  24225. * @returns "ImageProcessingPostProcess"
  24226. */
  24227. getClassName(): string;
  24228. /**
  24229. * @hidden
  24230. */
  24231. _updateParameters(): void;
  24232. dispose(camera?: Camera): void;
  24233. }
  24234. }
  24235. declare module BABYLON {
  24236. /** @hidden */
  24237. export var fibonacci: {
  24238. name: string;
  24239. shader: string;
  24240. };
  24241. }
  24242. declare module BABYLON {
  24243. /** @hidden */
  24244. export var subSurfaceScatteringFunctions: {
  24245. name: string;
  24246. shader: string;
  24247. };
  24248. }
  24249. declare module BABYLON {
  24250. /** @hidden */
  24251. export var diffusionProfile: {
  24252. name: string;
  24253. shader: string;
  24254. };
  24255. }
  24256. declare module BABYLON {
  24257. /** @hidden */
  24258. export var subSurfaceScatteringPixelShader: {
  24259. name: string;
  24260. shader: string;
  24261. };
  24262. }
  24263. declare module BABYLON {
  24264. /**
  24265. * Sub surface scattering post process
  24266. */
  24267. export class SubSurfaceScatteringPostProcess extends PostProcess {
  24268. /**
  24269. * Gets a string identifying the name of the class
  24270. * @returns "SubSurfaceScatteringPostProcess" string
  24271. */
  24272. getClassName(): string;
  24273. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  24274. }
  24275. }
  24276. declare module BABYLON {
  24277. /**
  24278. * Interface for defining prepass effects in the prepass post-process pipeline
  24279. */
  24280. export interface PrePassEffectConfiguration {
  24281. /**
  24282. * Post process to attach for this effect
  24283. */
  24284. postProcess: PostProcess;
  24285. /**
  24286. * Is the effect enabled
  24287. */
  24288. enabled: boolean;
  24289. /**
  24290. * Disposes the effect configuration
  24291. */
  24292. dispose(): void;
  24293. /**
  24294. * Disposes the effect configuration
  24295. */
  24296. createPostProcess: () => PostProcess;
  24297. }
  24298. }
  24299. declare module BABYLON {
  24300. /**
  24301. * Contains all parameters needed for the prepass to perform
  24302. * screen space subsurface scattering
  24303. */
  24304. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  24305. private _ssDiffusionS;
  24306. private _ssFilterRadii;
  24307. private _ssDiffusionD;
  24308. /**
  24309. * Post process to attach for screen space subsurface scattering
  24310. */
  24311. postProcess: SubSurfaceScatteringPostProcess;
  24312. /**
  24313. * Diffusion profile color for subsurface scattering
  24314. */
  24315. get ssDiffusionS(): number[];
  24316. /**
  24317. * Diffusion profile max color channel value for subsurface scattering
  24318. */
  24319. get ssDiffusionD(): number[];
  24320. /**
  24321. * Diffusion profile filter radius for subsurface scattering
  24322. */
  24323. get ssFilterRadii(): number[];
  24324. /**
  24325. * Is subsurface enabled
  24326. */
  24327. enabled: boolean;
  24328. /**
  24329. * Diffusion profile colors for subsurface scattering
  24330. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  24331. * See ...
  24332. * Note that you can only store up to 5 of them
  24333. */
  24334. ssDiffusionProfileColors: Color3[];
  24335. /**
  24336. * Defines the ratio real world => scene units.
  24337. * Used for subsurface scattering
  24338. */
  24339. metersPerUnit: number;
  24340. private _scene;
  24341. /**
  24342. * Builds a subsurface configuration object
  24343. * @param scene The scene
  24344. */
  24345. constructor(scene: Scene);
  24346. /**
  24347. * Adds a new diffusion profile.
  24348. * Useful for more realistic subsurface scattering on diverse materials.
  24349. * @param color The color of the diffusion profile. Should be the average color of the material.
  24350. * @return The index of the diffusion profile for the material subsurface configuration
  24351. */
  24352. addDiffusionProfile(color: Color3): number;
  24353. /**
  24354. * Creates the sss post process
  24355. * @return The created post process
  24356. */
  24357. createPostProcess(): SubSurfaceScatteringPostProcess;
  24358. /**
  24359. * Deletes all diffusion profiles.
  24360. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  24361. */
  24362. clearAllDiffusionProfiles(): void;
  24363. /**
  24364. * Disposes this object
  24365. */
  24366. dispose(): void;
  24367. /**
  24368. * @hidden
  24369. * https://zero-radiance.github.io/post/sampling-diffusion/
  24370. *
  24371. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  24372. * ------------------------------------------------------------------------------------
  24373. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  24374. * PDF[r, phi, s] = r * R[r, phi, s]
  24375. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  24376. * ------------------------------------------------------------------------------------
  24377. * We importance sample the color channel with the widest scattering distance.
  24378. */
  24379. getDiffusionProfileParameters(color: Color3): number;
  24380. /**
  24381. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  24382. * 'u' is the random number (the value of the CDF): [0, 1).
  24383. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  24384. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  24385. */
  24386. private _sampleBurleyDiffusionProfile;
  24387. }
  24388. }
  24389. declare module BABYLON {
  24390. /**
  24391. * Renders a pre pass of the scene
  24392. * This means every mesh in the scene will be rendered to a render target texture
  24393. * And then this texture will be composited to the rendering canvas with post processes
  24394. * It is necessary for effects like subsurface scattering or deferred shading
  24395. */
  24396. export class PrePassRenderer {
  24397. /** @hidden */
  24398. static _SceneComponentInitialization: (scene: Scene) => void;
  24399. private _scene;
  24400. private _engine;
  24401. private _isDirty;
  24402. /**
  24403. * Number of textures in the multi render target texture where the scene is directly rendered
  24404. */
  24405. readonly mrtCount: number;
  24406. /**
  24407. * The render target where the scene is directly rendered
  24408. */
  24409. prePassRT: MultiRenderTarget;
  24410. private _mrtTypes;
  24411. private _multiRenderAttachments;
  24412. private _defaultAttachments;
  24413. private _clearAttachments;
  24414. private _postProcesses;
  24415. private readonly _clearColor;
  24416. /**
  24417. * Image processing post process for composition
  24418. */
  24419. imageProcessingPostProcess: ImageProcessingPostProcess;
  24420. /**
  24421. * Configuration for sub surface scattering post process
  24422. */
  24423. subSurfaceConfiguration: SubSurfaceConfiguration;
  24424. /**
  24425. * Should materials render their geometry on the MRT
  24426. */
  24427. materialsShouldRenderGeometry: boolean;
  24428. /**
  24429. * Should materials render the irradiance information on the MRT
  24430. */
  24431. materialsShouldRenderIrradiance: boolean;
  24432. private _enabled;
  24433. /**
  24434. * Indicates if the prepass is enabled
  24435. */
  24436. get enabled(): boolean;
  24437. /**
  24438. * How many samples are used for MSAA of the scene render target
  24439. */
  24440. get samples(): number;
  24441. set samples(n: number);
  24442. /**
  24443. * Instanciates a prepass renderer
  24444. * @param scene The scene
  24445. */
  24446. constructor(scene: Scene);
  24447. private _initializeAttachments;
  24448. private _createCompositionEffect;
  24449. /**
  24450. * Indicates if rendering a prepass is supported
  24451. */
  24452. get isSupported(): boolean;
  24453. /**
  24454. * Sets the proper output textures to draw in the engine.
  24455. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  24456. */
  24457. bindAttachmentsForEffect(effect: Effect): void;
  24458. /**
  24459. * @hidden
  24460. */
  24461. _beforeCameraDraw(): void;
  24462. /**
  24463. * @hidden
  24464. */
  24465. _afterCameraDraw(): void;
  24466. private _checkRTSize;
  24467. private _bindFrameBuffer;
  24468. /**
  24469. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  24470. */
  24471. clear(): void;
  24472. private _setState;
  24473. private _enable;
  24474. private _disable;
  24475. private _resetPostProcessChain;
  24476. private _bindPostProcessChain;
  24477. /**
  24478. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  24479. */
  24480. markAsDirty(): void;
  24481. private _update;
  24482. /**
  24483. * Disposes the prepass renderer.
  24484. */
  24485. dispose(): void;
  24486. }
  24487. }
  24488. declare module BABYLON {
  24489. /**
  24490. * Options for compiling materials.
  24491. */
  24492. export interface IMaterialCompilationOptions {
  24493. /**
  24494. * Defines whether clip planes are enabled.
  24495. */
  24496. clipPlane: boolean;
  24497. /**
  24498. * Defines whether instances are enabled.
  24499. */
  24500. useInstances: boolean;
  24501. }
  24502. /**
  24503. * Options passed when calling customShaderNameResolve
  24504. */
  24505. export interface ICustomShaderNameResolveOptions {
  24506. /**
  24507. * 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
  24508. */
  24509. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24510. }
  24511. /**
  24512. * Base class for the main features of a material in Babylon.js
  24513. */
  24514. export class Material implements IAnimatable {
  24515. /**
  24516. * Returns the triangle fill mode
  24517. */
  24518. static readonly TriangleFillMode: number;
  24519. /**
  24520. * Returns the wireframe mode
  24521. */
  24522. static readonly WireFrameFillMode: number;
  24523. /**
  24524. * Returns the point fill mode
  24525. */
  24526. static readonly PointFillMode: number;
  24527. /**
  24528. * Returns the point list draw mode
  24529. */
  24530. static readonly PointListDrawMode: number;
  24531. /**
  24532. * Returns the line list draw mode
  24533. */
  24534. static readonly LineListDrawMode: number;
  24535. /**
  24536. * Returns the line loop draw mode
  24537. */
  24538. static readonly LineLoopDrawMode: number;
  24539. /**
  24540. * Returns the line strip draw mode
  24541. */
  24542. static readonly LineStripDrawMode: number;
  24543. /**
  24544. * Returns the triangle strip draw mode
  24545. */
  24546. static readonly TriangleStripDrawMode: number;
  24547. /**
  24548. * Returns the triangle fan draw mode
  24549. */
  24550. static readonly TriangleFanDrawMode: number;
  24551. /**
  24552. * Stores the clock-wise side orientation
  24553. */
  24554. static readonly ClockWiseSideOrientation: number;
  24555. /**
  24556. * Stores the counter clock-wise side orientation
  24557. */
  24558. static readonly CounterClockWiseSideOrientation: number;
  24559. /**
  24560. * The dirty texture flag value
  24561. */
  24562. static readonly TextureDirtyFlag: number;
  24563. /**
  24564. * The dirty light flag value
  24565. */
  24566. static readonly LightDirtyFlag: number;
  24567. /**
  24568. * The dirty fresnel flag value
  24569. */
  24570. static readonly FresnelDirtyFlag: number;
  24571. /**
  24572. * The dirty attribute flag value
  24573. */
  24574. static readonly AttributesDirtyFlag: number;
  24575. /**
  24576. * The dirty misc flag value
  24577. */
  24578. static readonly MiscDirtyFlag: number;
  24579. /**
  24580. * The all dirty flag value
  24581. */
  24582. static readonly AllDirtyFlag: number;
  24583. /**
  24584. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24585. */
  24586. static readonly MATERIAL_OPAQUE: number;
  24587. /**
  24588. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24589. */
  24590. static readonly MATERIAL_ALPHATEST: number;
  24591. /**
  24592. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24593. */
  24594. static readonly MATERIAL_ALPHABLEND: number;
  24595. /**
  24596. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24597. * They are also discarded below the alpha cutoff threshold to improve performances.
  24598. */
  24599. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24600. /**
  24601. * The Whiteout method is used to blend normals.
  24602. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24603. */
  24604. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  24605. /**
  24606. * The Reoriented Normal Mapping method is used to blend normals.
  24607. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24608. */
  24609. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  24610. /**
  24611. * Custom callback helping to override the default shader used in the material.
  24612. */
  24613. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24614. /**
  24615. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24616. */
  24617. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24618. /**
  24619. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  24620. * This means that the material can keep using a previous shader while a new one is being compiled.
  24621. * This is mostly used when shader parallel compilation is supported (true by default)
  24622. */
  24623. allowShaderHotSwapping: boolean;
  24624. /**
  24625. * The ID of the material
  24626. */
  24627. id: string;
  24628. /**
  24629. * Gets or sets the unique id of the material
  24630. */
  24631. uniqueId: number;
  24632. /**
  24633. * The name of the material
  24634. */
  24635. name: string;
  24636. /**
  24637. * Gets or sets user defined metadata
  24638. */
  24639. metadata: any;
  24640. /**
  24641. * For internal use only. Please do not use.
  24642. */
  24643. reservedDataStore: any;
  24644. /**
  24645. * Specifies if the ready state should be checked on each call
  24646. */
  24647. checkReadyOnEveryCall: boolean;
  24648. /**
  24649. * Specifies if the ready state should be checked once
  24650. */
  24651. checkReadyOnlyOnce: boolean;
  24652. /**
  24653. * The state of the material
  24654. */
  24655. state: string;
  24656. /**
  24657. * If the material can be rendered to several textures with MRT extension
  24658. */
  24659. get canRenderToMRT(): boolean;
  24660. /**
  24661. * The alpha value of the material
  24662. */
  24663. protected _alpha: number;
  24664. /**
  24665. * List of inspectable custom properties (used by the Inspector)
  24666. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24667. */
  24668. inspectableCustomProperties: IInspectable[];
  24669. /**
  24670. * Sets the alpha value of the material
  24671. */
  24672. set alpha(value: number);
  24673. /**
  24674. * Gets the alpha value of the material
  24675. */
  24676. get alpha(): number;
  24677. /**
  24678. * Specifies if back face culling is enabled
  24679. */
  24680. protected _backFaceCulling: boolean;
  24681. /**
  24682. * Sets the back-face culling state
  24683. */
  24684. set backFaceCulling(value: boolean);
  24685. /**
  24686. * Gets the back-face culling state
  24687. */
  24688. get backFaceCulling(): boolean;
  24689. /**
  24690. * Stores the value for side orientation
  24691. */
  24692. sideOrientation: number;
  24693. /**
  24694. * Callback triggered when the material is compiled
  24695. */
  24696. onCompiled: Nullable<(effect: Effect) => void>;
  24697. /**
  24698. * Callback triggered when an error occurs
  24699. */
  24700. onError: Nullable<(effect: Effect, errors: string) => void>;
  24701. /**
  24702. * Callback triggered to get the render target textures
  24703. */
  24704. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24705. /**
  24706. * Gets a boolean indicating that current material needs to register RTT
  24707. */
  24708. get hasRenderTargetTextures(): boolean;
  24709. /**
  24710. * Specifies if the material should be serialized
  24711. */
  24712. doNotSerialize: boolean;
  24713. /**
  24714. * @hidden
  24715. */
  24716. _storeEffectOnSubMeshes: boolean;
  24717. /**
  24718. * Stores the animations for the material
  24719. */
  24720. animations: Nullable<Array<Animation>>;
  24721. /**
  24722. * An event triggered when the material is disposed
  24723. */
  24724. onDisposeObservable: Observable<Material>;
  24725. /**
  24726. * An observer which watches for dispose events
  24727. */
  24728. private _onDisposeObserver;
  24729. private _onUnBindObservable;
  24730. /**
  24731. * Called during a dispose event
  24732. */
  24733. set onDispose(callback: () => void);
  24734. private _onBindObservable;
  24735. /**
  24736. * An event triggered when the material is bound
  24737. */
  24738. get onBindObservable(): Observable<AbstractMesh>;
  24739. /**
  24740. * An observer which watches for bind events
  24741. */
  24742. private _onBindObserver;
  24743. /**
  24744. * Called during a bind event
  24745. */
  24746. set onBind(callback: (Mesh: AbstractMesh) => void);
  24747. /**
  24748. * An event triggered when the material is unbound
  24749. */
  24750. get onUnBindObservable(): Observable<Material>;
  24751. protected _onEffectCreatedObservable: Nullable<Observable<{
  24752. effect: Effect;
  24753. subMesh: Nullable<SubMesh>;
  24754. }>>;
  24755. /**
  24756. * An event triggered when the effect is (re)created
  24757. */
  24758. get onEffectCreatedObservable(): Observable<{
  24759. effect: Effect;
  24760. subMesh: Nullable<SubMesh>;
  24761. }>;
  24762. /**
  24763. * Stores the value of the alpha mode
  24764. */
  24765. private _alphaMode;
  24766. /**
  24767. * Sets the value of the alpha mode.
  24768. *
  24769. * | Value | Type | Description |
  24770. * | --- | --- | --- |
  24771. * | 0 | ALPHA_DISABLE | |
  24772. * | 1 | ALPHA_ADD | |
  24773. * | 2 | ALPHA_COMBINE | |
  24774. * | 3 | ALPHA_SUBTRACT | |
  24775. * | 4 | ALPHA_MULTIPLY | |
  24776. * | 5 | ALPHA_MAXIMIZED | |
  24777. * | 6 | ALPHA_ONEONE | |
  24778. * | 7 | ALPHA_PREMULTIPLIED | |
  24779. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24780. * | 9 | ALPHA_INTERPOLATE | |
  24781. * | 10 | ALPHA_SCREENMODE | |
  24782. *
  24783. */
  24784. set alphaMode(value: number);
  24785. /**
  24786. * Gets the value of the alpha mode
  24787. */
  24788. get alphaMode(): number;
  24789. /**
  24790. * Stores the state of the need depth pre-pass value
  24791. */
  24792. private _needDepthPrePass;
  24793. /**
  24794. * Sets the need depth pre-pass value
  24795. */
  24796. set needDepthPrePass(value: boolean);
  24797. /**
  24798. * Gets the depth pre-pass value
  24799. */
  24800. get needDepthPrePass(): boolean;
  24801. /**
  24802. * Specifies if depth writing should be disabled
  24803. */
  24804. disableDepthWrite: boolean;
  24805. /**
  24806. * Specifies if color writing should be disabled
  24807. */
  24808. disableColorWrite: boolean;
  24809. /**
  24810. * Specifies if depth writing should be forced
  24811. */
  24812. forceDepthWrite: boolean;
  24813. /**
  24814. * Specifies the depth function that should be used. 0 means the default engine function
  24815. */
  24816. depthFunction: number;
  24817. /**
  24818. * Specifies if there should be a separate pass for culling
  24819. */
  24820. separateCullingPass: boolean;
  24821. /**
  24822. * Stores the state specifing if fog should be enabled
  24823. */
  24824. private _fogEnabled;
  24825. /**
  24826. * Sets the state for enabling fog
  24827. */
  24828. set fogEnabled(value: boolean);
  24829. /**
  24830. * Gets the value of the fog enabled state
  24831. */
  24832. get fogEnabled(): boolean;
  24833. /**
  24834. * Stores the size of points
  24835. */
  24836. pointSize: number;
  24837. /**
  24838. * Stores the z offset value
  24839. */
  24840. zOffset: number;
  24841. get wireframe(): boolean;
  24842. /**
  24843. * Sets the state of wireframe mode
  24844. */
  24845. set wireframe(value: boolean);
  24846. /**
  24847. * Gets the value specifying if point clouds are enabled
  24848. */
  24849. get pointsCloud(): boolean;
  24850. /**
  24851. * Sets the state of point cloud mode
  24852. */
  24853. set pointsCloud(value: boolean);
  24854. /**
  24855. * Gets the material fill mode
  24856. */
  24857. get fillMode(): number;
  24858. /**
  24859. * Sets the material fill mode
  24860. */
  24861. set fillMode(value: number);
  24862. /**
  24863. * @hidden
  24864. * Stores the effects for the material
  24865. */
  24866. _effect: Nullable<Effect>;
  24867. /**
  24868. * Specifies if uniform buffers should be used
  24869. */
  24870. private _useUBO;
  24871. /**
  24872. * Stores a reference to the scene
  24873. */
  24874. private _scene;
  24875. /**
  24876. * Stores the fill mode state
  24877. */
  24878. private _fillMode;
  24879. /**
  24880. * Specifies if the depth write state should be cached
  24881. */
  24882. private _cachedDepthWriteState;
  24883. /**
  24884. * Specifies if the color write state should be cached
  24885. */
  24886. private _cachedColorWriteState;
  24887. /**
  24888. * Specifies if the depth function state should be cached
  24889. */
  24890. private _cachedDepthFunctionState;
  24891. /**
  24892. * Stores the uniform buffer
  24893. */
  24894. protected _uniformBuffer: UniformBuffer;
  24895. /** @hidden */
  24896. _indexInSceneMaterialArray: number;
  24897. /** @hidden */
  24898. meshMap: Nullable<{
  24899. [id: string]: AbstractMesh | undefined;
  24900. }>;
  24901. /**
  24902. * Creates a material instance
  24903. * @param name defines the name of the material
  24904. * @param scene defines the scene to reference
  24905. * @param doNotAdd specifies if the material should be added to the scene
  24906. */
  24907. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24908. /**
  24909. * Returns a string representation of the current material
  24910. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24911. * @returns a string with material information
  24912. */
  24913. toString(fullDetails?: boolean): string;
  24914. /**
  24915. * Gets the class name of the material
  24916. * @returns a string with the class name of the material
  24917. */
  24918. getClassName(): string;
  24919. /**
  24920. * Specifies if updates for the material been locked
  24921. */
  24922. get isFrozen(): boolean;
  24923. /**
  24924. * Locks updates for the material
  24925. */
  24926. freeze(): void;
  24927. /**
  24928. * Unlocks updates for the material
  24929. */
  24930. unfreeze(): void;
  24931. /**
  24932. * Specifies if the material is ready to be used
  24933. * @param mesh defines the mesh to check
  24934. * @param useInstances specifies if instances should be used
  24935. * @returns a boolean indicating if the material is ready to be used
  24936. */
  24937. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24938. /**
  24939. * Specifies that the submesh is ready to be used
  24940. * @param mesh defines the mesh to check
  24941. * @param subMesh defines which submesh to check
  24942. * @param useInstances specifies that instances should be used
  24943. * @returns a boolean indicating that the submesh is ready or not
  24944. */
  24945. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24946. /**
  24947. * Returns the material effect
  24948. * @returns the effect associated with the material
  24949. */
  24950. getEffect(): Nullable<Effect>;
  24951. /**
  24952. * Returns the current scene
  24953. * @returns a Scene
  24954. */
  24955. getScene(): Scene;
  24956. /**
  24957. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24958. */
  24959. protected _forceAlphaTest: boolean;
  24960. /**
  24961. * The transparency mode of the material.
  24962. */
  24963. protected _transparencyMode: Nullable<number>;
  24964. /**
  24965. * Gets the current transparency mode.
  24966. */
  24967. get transparencyMode(): Nullable<number>;
  24968. /**
  24969. * Sets the transparency mode of the material.
  24970. *
  24971. * | Value | Type | Description |
  24972. * | ----- | ----------------------------------- | ----------- |
  24973. * | 0 | OPAQUE | |
  24974. * | 1 | ALPHATEST | |
  24975. * | 2 | ALPHABLEND | |
  24976. * | 3 | ALPHATESTANDBLEND | |
  24977. *
  24978. */
  24979. set transparencyMode(value: Nullable<number>);
  24980. /**
  24981. * Returns true if alpha blending should be disabled.
  24982. */
  24983. protected get _disableAlphaBlending(): boolean;
  24984. /**
  24985. * Specifies whether or not this material should be rendered in alpha blend mode.
  24986. * @returns a boolean specifying if alpha blending is needed
  24987. */
  24988. needAlphaBlending(): boolean;
  24989. /**
  24990. * Specifies if the mesh will require alpha blending
  24991. * @param mesh defines the mesh to check
  24992. * @returns a boolean specifying if alpha blending is needed for the mesh
  24993. */
  24994. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24995. /**
  24996. * Specifies whether or not this material should be rendered in alpha test mode.
  24997. * @returns a boolean specifying if an alpha test is needed.
  24998. */
  24999. needAlphaTesting(): boolean;
  25000. /**
  25001. * Specifies if material alpha testing should be turned on for the mesh
  25002. * @param mesh defines the mesh to check
  25003. */
  25004. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25005. /**
  25006. * Gets the texture used for the alpha test
  25007. * @returns the texture to use for alpha testing
  25008. */
  25009. getAlphaTestTexture(): Nullable<BaseTexture>;
  25010. /**
  25011. * Marks the material to indicate that it needs to be re-calculated
  25012. */
  25013. markDirty(): void;
  25014. /** @hidden */
  25015. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25016. /**
  25017. * Binds the material to the mesh
  25018. * @param world defines the world transformation matrix
  25019. * @param mesh defines the mesh to bind the material to
  25020. */
  25021. bind(world: Matrix, mesh?: Mesh): void;
  25022. /**
  25023. * Binds the submesh to the material
  25024. * @param world defines the world transformation matrix
  25025. * @param mesh defines the mesh containing the submesh
  25026. * @param subMesh defines the submesh to bind the material to
  25027. */
  25028. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25029. /**
  25030. * Binds the world matrix to the material
  25031. * @param world defines the world transformation matrix
  25032. */
  25033. bindOnlyWorldMatrix(world: Matrix): void;
  25034. /**
  25035. * Binds the scene's uniform buffer to the effect.
  25036. * @param effect defines the effect to bind to the scene uniform buffer
  25037. * @param sceneUbo defines the uniform buffer storing scene data
  25038. */
  25039. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25040. /**
  25041. * Binds the view matrix to the effect
  25042. * @param effect defines the effect to bind the view matrix to
  25043. */
  25044. bindView(effect: Effect): void;
  25045. /**
  25046. * Binds the view projection matrix to the effect
  25047. * @param effect defines the effect to bind the view projection matrix to
  25048. */
  25049. bindViewProjection(effect: Effect): void;
  25050. /**
  25051. * Processes to execute after binding the material to a mesh
  25052. * @param mesh defines the rendered mesh
  25053. */
  25054. protected _afterBind(mesh?: Mesh): void;
  25055. /**
  25056. * Unbinds the material from the mesh
  25057. */
  25058. unbind(): void;
  25059. /**
  25060. * Gets the active textures from the material
  25061. * @returns an array of textures
  25062. */
  25063. getActiveTextures(): BaseTexture[];
  25064. /**
  25065. * Specifies if the material uses a texture
  25066. * @param texture defines the texture to check against the material
  25067. * @returns a boolean specifying if the material uses the texture
  25068. */
  25069. hasTexture(texture: BaseTexture): boolean;
  25070. /**
  25071. * Makes a duplicate of the material, and gives it a new name
  25072. * @param name defines the new name for the duplicated material
  25073. * @returns the cloned material
  25074. */
  25075. clone(name: string): Nullable<Material>;
  25076. /**
  25077. * Gets the meshes bound to the material
  25078. * @returns an array of meshes bound to the material
  25079. */
  25080. getBindedMeshes(): AbstractMesh[];
  25081. /**
  25082. * Force shader compilation
  25083. * @param mesh defines the mesh associated with this material
  25084. * @param onCompiled defines a function to execute once the material is compiled
  25085. * @param options defines the options to configure the compilation
  25086. * @param onError defines a function to execute if the material fails compiling
  25087. */
  25088. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25089. /**
  25090. * Force shader compilation
  25091. * @param mesh defines the mesh that will use this material
  25092. * @param options defines additional options for compiling the shaders
  25093. * @returns a promise that resolves when the compilation completes
  25094. */
  25095. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25096. private static readonly _AllDirtyCallBack;
  25097. private static readonly _ImageProcessingDirtyCallBack;
  25098. private static readonly _TextureDirtyCallBack;
  25099. private static readonly _FresnelDirtyCallBack;
  25100. private static readonly _MiscDirtyCallBack;
  25101. private static readonly _LightsDirtyCallBack;
  25102. private static readonly _AttributeDirtyCallBack;
  25103. private static _FresnelAndMiscDirtyCallBack;
  25104. private static _TextureAndMiscDirtyCallBack;
  25105. private static readonly _DirtyCallbackArray;
  25106. private static readonly _RunDirtyCallBacks;
  25107. /**
  25108. * Marks a define in the material to indicate that it needs to be re-computed
  25109. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25110. */
  25111. markAsDirty(flag: number): void;
  25112. /**
  25113. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25114. * @param func defines a function which checks material defines against the submeshes
  25115. */
  25116. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25117. /**
  25118. * Indicates that the scene should check if the rendering now needs a prepass
  25119. */
  25120. protected _markScenePrePassDirty(): void;
  25121. /**
  25122. * Indicates that we need to re-calculated for all submeshes
  25123. */
  25124. protected _markAllSubMeshesAsAllDirty(): void;
  25125. /**
  25126. * Indicates that image processing needs to be re-calculated for all submeshes
  25127. */
  25128. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25129. /**
  25130. * Indicates that textures need to be re-calculated for all submeshes
  25131. */
  25132. protected _markAllSubMeshesAsTexturesDirty(): void;
  25133. /**
  25134. * Indicates that fresnel needs to be re-calculated for all submeshes
  25135. */
  25136. protected _markAllSubMeshesAsFresnelDirty(): void;
  25137. /**
  25138. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25139. */
  25140. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25141. /**
  25142. * Indicates that lights need to be re-calculated for all submeshes
  25143. */
  25144. protected _markAllSubMeshesAsLightsDirty(): void;
  25145. /**
  25146. * Indicates that attributes need to be re-calculated for all submeshes
  25147. */
  25148. protected _markAllSubMeshesAsAttributesDirty(): void;
  25149. /**
  25150. * Indicates that misc needs to be re-calculated for all submeshes
  25151. */
  25152. protected _markAllSubMeshesAsMiscDirty(): void;
  25153. /**
  25154. * Indicates that textures and misc need to be re-calculated for all submeshes
  25155. */
  25156. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25157. /**
  25158. * Sets the required values to the prepass renderer.
  25159. * @param prePassRenderer defines the prepass renderer to setup.
  25160. * @returns true if the pre pass is needed.
  25161. */
  25162. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  25163. /**
  25164. * Disposes the material
  25165. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25166. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25167. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25168. */
  25169. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25170. /** @hidden */
  25171. private releaseVertexArrayObject;
  25172. /**
  25173. * Serializes this material
  25174. * @returns the serialized material object
  25175. */
  25176. serialize(): any;
  25177. /**
  25178. * Creates a material from parsed material data
  25179. * @param parsedMaterial defines parsed material data
  25180. * @param scene defines the hosting scene
  25181. * @param rootUrl defines the root URL to use to load textures
  25182. * @returns a new material
  25183. */
  25184. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25185. }
  25186. }
  25187. declare module BABYLON {
  25188. /**
  25189. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25190. * separate meshes. This can be use to improve performances.
  25191. * @see https://doc.babylonjs.com/how_to/multi_materials
  25192. */
  25193. export class MultiMaterial extends Material {
  25194. private _subMaterials;
  25195. /**
  25196. * Gets or Sets the list of Materials used within the multi material.
  25197. * They need to be ordered according to the submeshes order in the associated mesh
  25198. */
  25199. get subMaterials(): Nullable<Material>[];
  25200. set subMaterials(value: Nullable<Material>[]);
  25201. /**
  25202. * Function used to align with Node.getChildren()
  25203. * @returns the list of Materials used within the multi material
  25204. */
  25205. getChildren(): Nullable<Material>[];
  25206. /**
  25207. * Instantiates a new Multi Material
  25208. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25209. * separate meshes. This can be use to improve performances.
  25210. * @see https://doc.babylonjs.com/how_to/multi_materials
  25211. * @param name Define the name in the scene
  25212. * @param scene Define the scene the material belongs to
  25213. */
  25214. constructor(name: string, scene: Scene);
  25215. private _hookArray;
  25216. /**
  25217. * Get one of the submaterial by its index in the submaterials array
  25218. * @param index The index to look the sub material at
  25219. * @returns The Material if the index has been defined
  25220. */
  25221. getSubMaterial(index: number): Nullable<Material>;
  25222. /**
  25223. * Get the list of active textures for the whole sub materials list.
  25224. * @returns All the textures that will be used during the rendering
  25225. */
  25226. getActiveTextures(): BaseTexture[];
  25227. /**
  25228. * Gets the current class name of the material e.g. "MultiMaterial"
  25229. * Mainly use in serialization.
  25230. * @returns the class name
  25231. */
  25232. getClassName(): string;
  25233. /**
  25234. * Checks if the material is ready to render the requested sub mesh
  25235. * @param mesh Define the mesh the submesh belongs to
  25236. * @param subMesh Define the sub mesh to look readyness for
  25237. * @param useInstances Define whether or not the material is used with instances
  25238. * @returns true if ready, otherwise false
  25239. */
  25240. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25241. /**
  25242. * Clones the current material and its related sub materials
  25243. * @param name Define the name of the newly cloned material
  25244. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25245. * @returns the cloned material
  25246. */
  25247. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25248. /**
  25249. * Serializes the materials into a JSON representation.
  25250. * @returns the JSON representation
  25251. */
  25252. serialize(): any;
  25253. /**
  25254. * Dispose the material and release its associated resources
  25255. * @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)
  25256. * @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)
  25257. * @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)
  25258. */
  25259. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25260. /**
  25261. * Creates a MultiMaterial from parsed MultiMaterial data.
  25262. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25263. * @param scene defines the hosting scene
  25264. * @returns a new MultiMaterial
  25265. */
  25266. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25267. }
  25268. }
  25269. declare module BABYLON {
  25270. /**
  25271. * Defines a subdivision inside a mesh
  25272. */
  25273. export class SubMesh implements ICullable {
  25274. /** the material index to use */
  25275. materialIndex: number;
  25276. /** vertex index start */
  25277. verticesStart: number;
  25278. /** vertices count */
  25279. verticesCount: number;
  25280. /** index start */
  25281. indexStart: number;
  25282. /** indices count */
  25283. indexCount: number;
  25284. /** @hidden */
  25285. _materialDefines: Nullable<MaterialDefines>;
  25286. /** @hidden */
  25287. _materialEffect: Nullable<Effect>;
  25288. /** @hidden */
  25289. _effectOverride: Nullable<Effect>;
  25290. /**
  25291. * Gets material defines used by the effect associated to the sub mesh
  25292. */
  25293. get materialDefines(): Nullable<MaterialDefines>;
  25294. /**
  25295. * Sets material defines used by the effect associated to the sub mesh
  25296. */
  25297. set materialDefines(defines: Nullable<MaterialDefines>);
  25298. /**
  25299. * Gets associated effect
  25300. */
  25301. get effect(): Nullable<Effect>;
  25302. /**
  25303. * Sets associated effect (effect used to render this submesh)
  25304. * @param effect defines the effect to associate with
  25305. * @param defines defines the set of defines used to compile this effect
  25306. */
  25307. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25308. /** @hidden */
  25309. _linesIndexCount: number;
  25310. private _mesh;
  25311. private _renderingMesh;
  25312. private _boundingInfo;
  25313. private _linesIndexBuffer;
  25314. /** @hidden */
  25315. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25316. /** @hidden */
  25317. _trianglePlanes: Plane[];
  25318. /** @hidden */
  25319. _lastColliderTransformMatrix: Nullable<Matrix>;
  25320. /** @hidden */
  25321. _renderId: number;
  25322. /** @hidden */
  25323. _alphaIndex: number;
  25324. /** @hidden */
  25325. _distanceToCamera: number;
  25326. /** @hidden */
  25327. _id: number;
  25328. private _currentMaterial;
  25329. /**
  25330. * Add a new submesh to a mesh
  25331. * @param materialIndex defines the material index to use
  25332. * @param verticesStart defines vertex index start
  25333. * @param verticesCount defines vertices count
  25334. * @param indexStart defines index start
  25335. * @param indexCount defines indices count
  25336. * @param mesh defines the parent mesh
  25337. * @param renderingMesh defines an optional rendering mesh
  25338. * @param createBoundingBox defines if bounding box should be created for this submesh
  25339. * @returns the new submesh
  25340. */
  25341. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25342. /**
  25343. * Creates a new submesh
  25344. * @param materialIndex defines the material index to use
  25345. * @param verticesStart defines vertex index start
  25346. * @param verticesCount defines vertices count
  25347. * @param indexStart defines index start
  25348. * @param indexCount defines indices count
  25349. * @param mesh defines the parent mesh
  25350. * @param renderingMesh defines an optional rendering mesh
  25351. * @param createBoundingBox defines if bounding box should be created for this submesh
  25352. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  25353. */
  25354. constructor(
  25355. /** the material index to use */
  25356. materialIndex: number,
  25357. /** vertex index start */
  25358. verticesStart: number,
  25359. /** vertices count */
  25360. verticesCount: number,
  25361. /** index start */
  25362. indexStart: number,
  25363. /** indices count */
  25364. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  25365. /**
  25366. * Returns true if this submesh covers the entire parent mesh
  25367. * @ignorenaming
  25368. */
  25369. get IsGlobal(): boolean;
  25370. /**
  25371. * Returns the submesh BoudingInfo object
  25372. * @returns current bounding info (or mesh's one if the submesh is global)
  25373. */
  25374. getBoundingInfo(): BoundingInfo;
  25375. /**
  25376. * Sets the submesh BoundingInfo
  25377. * @param boundingInfo defines the new bounding info to use
  25378. * @returns the SubMesh
  25379. */
  25380. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25381. /**
  25382. * Returns the mesh of the current submesh
  25383. * @return the parent mesh
  25384. */
  25385. getMesh(): AbstractMesh;
  25386. /**
  25387. * Returns the rendering mesh of the submesh
  25388. * @returns the rendering mesh (could be different from parent mesh)
  25389. */
  25390. getRenderingMesh(): Mesh;
  25391. /**
  25392. * Returns the replacement mesh of the submesh
  25393. * @returns the replacement mesh (could be different from parent mesh)
  25394. */
  25395. getReplacementMesh(): Nullable<AbstractMesh>;
  25396. /**
  25397. * Returns the effective mesh of the submesh
  25398. * @returns the effective mesh (could be different from parent mesh)
  25399. */
  25400. getEffectiveMesh(): AbstractMesh;
  25401. /**
  25402. * Returns the submesh material
  25403. * @returns null or the current material
  25404. */
  25405. getMaterial(): Nullable<Material>;
  25406. private _IsMultiMaterial;
  25407. /**
  25408. * Sets a new updated BoundingInfo object to the submesh
  25409. * @param data defines an optional position array to use to determine the bounding info
  25410. * @returns the SubMesh
  25411. */
  25412. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25413. /** @hidden */
  25414. _checkCollision(collider: Collider): boolean;
  25415. /**
  25416. * Updates the submesh BoundingInfo
  25417. * @param world defines the world matrix to use to update the bounding info
  25418. * @returns the submesh
  25419. */
  25420. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25421. /**
  25422. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25423. * @param frustumPlanes defines the frustum planes
  25424. * @returns true if the submesh is intersecting with the frustum
  25425. */
  25426. isInFrustum(frustumPlanes: Plane[]): boolean;
  25427. /**
  25428. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25429. * @param frustumPlanes defines the frustum planes
  25430. * @returns true if the submesh is inside the frustum
  25431. */
  25432. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25433. /**
  25434. * Renders the submesh
  25435. * @param enableAlphaMode defines if alpha needs to be used
  25436. * @returns the submesh
  25437. */
  25438. render(enableAlphaMode: boolean): SubMesh;
  25439. /**
  25440. * @hidden
  25441. */
  25442. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25443. /**
  25444. * Checks if the submesh intersects with a ray
  25445. * @param ray defines the ray to test
  25446. * @returns true is the passed ray intersects the submesh bounding box
  25447. */
  25448. canIntersects(ray: Ray): boolean;
  25449. /**
  25450. * Intersects current submesh with a ray
  25451. * @param ray defines the ray to test
  25452. * @param positions defines mesh's positions array
  25453. * @param indices defines mesh's indices array
  25454. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25455. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25456. * @returns intersection info or null if no intersection
  25457. */
  25458. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25459. /** @hidden */
  25460. private _intersectLines;
  25461. /** @hidden */
  25462. private _intersectUnIndexedLines;
  25463. /** @hidden */
  25464. private _intersectTriangles;
  25465. /** @hidden */
  25466. private _intersectUnIndexedTriangles;
  25467. /** @hidden */
  25468. _rebuild(): void;
  25469. /**
  25470. * Creates a new submesh from the passed mesh
  25471. * @param newMesh defines the new hosting mesh
  25472. * @param newRenderingMesh defines an optional rendering mesh
  25473. * @returns the new submesh
  25474. */
  25475. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25476. /**
  25477. * Release associated resources
  25478. */
  25479. dispose(): void;
  25480. /**
  25481. * Gets the class name
  25482. * @returns the string "SubMesh".
  25483. */
  25484. getClassName(): string;
  25485. /**
  25486. * Creates a new submesh from indices data
  25487. * @param materialIndex the index of the main mesh material
  25488. * @param startIndex the index where to start the copy in the mesh indices array
  25489. * @param indexCount the number of indices to copy then from the startIndex
  25490. * @param mesh the main mesh to create the submesh from
  25491. * @param renderingMesh the optional rendering mesh
  25492. * @returns a new submesh
  25493. */
  25494. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25495. }
  25496. }
  25497. declare module BABYLON {
  25498. /**
  25499. * Class used to represent data loading progression
  25500. */
  25501. export class SceneLoaderFlags {
  25502. private static _ForceFullSceneLoadingForIncremental;
  25503. private static _ShowLoadingScreen;
  25504. private static _CleanBoneMatrixWeights;
  25505. private static _loggingLevel;
  25506. /**
  25507. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25508. */
  25509. static get ForceFullSceneLoadingForIncremental(): boolean;
  25510. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25511. /**
  25512. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25513. */
  25514. static get ShowLoadingScreen(): boolean;
  25515. static set ShowLoadingScreen(value: boolean);
  25516. /**
  25517. * Defines the current logging level (while loading the scene)
  25518. * @ignorenaming
  25519. */
  25520. static get loggingLevel(): number;
  25521. static set loggingLevel(value: number);
  25522. /**
  25523. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25524. */
  25525. static get CleanBoneMatrixWeights(): boolean;
  25526. static set CleanBoneMatrixWeights(value: boolean);
  25527. }
  25528. }
  25529. declare module BABYLON {
  25530. /**
  25531. * Class used to store geometry data (vertex buffers + index buffer)
  25532. */
  25533. export class Geometry implements IGetSetVerticesData {
  25534. /**
  25535. * Gets or sets the ID of the geometry
  25536. */
  25537. id: string;
  25538. /**
  25539. * Gets or sets the unique ID of the geometry
  25540. */
  25541. uniqueId: number;
  25542. /**
  25543. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25544. */
  25545. delayLoadState: number;
  25546. /**
  25547. * Gets the file containing the data to load when running in delay load state
  25548. */
  25549. delayLoadingFile: Nullable<string>;
  25550. /**
  25551. * Callback called when the geometry is updated
  25552. */
  25553. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25554. private _scene;
  25555. private _engine;
  25556. private _meshes;
  25557. private _totalVertices;
  25558. /** @hidden */
  25559. _indices: IndicesArray;
  25560. /** @hidden */
  25561. _vertexBuffers: {
  25562. [key: string]: VertexBuffer;
  25563. };
  25564. private _isDisposed;
  25565. private _extend;
  25566. private _boundingBias;
  25567. /** @hidden */
  25568. _delayInfo: Array<string>;
  25569. private _indexBuffer;
  25570. private _indexBufferIsUpdatable;
  25571. /** @hidden */
  25572. _boundingInfo: Nullable<BoundingInfo>;
  25573. /** @hidden */
  25574. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25575. /** @hidden */
  25576. _softwareSkinningFrameId: number;
  25577. private _vertexArrayObjects;
  25578. private _updatable;
  25579. /** @hidden */
  25580. _positions: Nullable<Vector3[]>;
  25581. /**
  25582. * 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
  25583. */
  25584. get boundingBias(): Vector2;
  25585. /**
  25586. * 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
  25587. */
  25588. set boundingBias(value: Vector2);
  25589. /**
  25590. * Static function used to attach a new empty geometry to a mesh
  25591. * @param mesh defines the mesh to attach the geometry to
  25592. * @returns the new Geometry
  25593. */
  25594. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25595. /** Get the list of meshes using this geometry */
  25596. get meshes(): Mesh[];
  25597. /**
  25598. * 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
  25599. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  25600. */
  25601. useBoundingInfoFromGeometry: boolean;
  25602. /**
  25603. * Creates a new geometry
  25604. * @param id defines the unique ID
  25605. * @param scene defines the hosting scene
  25606. * @param vertexData defines the VertexData used to get geometry data
  25607. * @param updatable defines if geometry must be updatable (false by default)
  25608. * @param mesh defines the mesh that will be associated with the geometry
  25609. */
  25610. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25611. /**
  25612. * Gets the current extend of the geometry
  25613. */
  25614. get extend(): {
  25615. minimum: Vector3;
  25616. maximum: Vector3;
  25617. };
  25618. /**
  25619. * Gets the hosting scene
  25620. * @returns the hosting Scene
  25621. */
  25622. getScene(): Scene;
  25623. /**
  25624. * Gets the hosting engine
  25625. * @returns the hosting Engine
  25626. */
  25627. getEngine(): Engine;
  25628. /**
  25629. * Defines if the geometry is ready to use
  25630. * @returns true if the geometry is ready to be used
  25631. */
  25632. isReady(): boolean;
  25633. /**
  25634. * Gets a value indicating that the geometry should not be serialized
  25635. */
  25636. get doNotSerialize(): boolean;
  25637. /** @hidden */
  25638. _rebuild(): void;
  25639. /**
  25640. * Affects all geometry data in one call
  25641. * @param vertexData defines the geometry data
  25642. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25643. */
  25644. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25645. /**
  25646. * Set specific vertex data
  25647. * @param kind defines the data kind (Position, normal, etc...)
  25648. * @param data defines the vertex data to use
  25649. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25650. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25651. */
  25652. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25653. /**
  25654. * Removes a specific vertex data
  25655. * @param kind defines the data kind (Position, normal, etc...)
  25656. */
  25657. removeVerticesData(kind: string): void;
  25658. /**
  25659. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25660. * @param buffer defines the vertex buffer to use
  25661. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25662. */
  25663. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25664. /**
  25665. * Update a specific vertex buffer
  25666. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25667. * It will do nothing if the buffer is not updatable
  25668. * @param kind defines the data kind (Position, normal, etc...)
  25669. * @param data defines the data to use
  25670. * @param offset defines the offset in the target buffer where to store the data
  25671. * @param useBytes set to true if the offset is in bytes
  25672. */
  25673. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25674. /**
  25675. * Update a specific vertex buffer
  25676. * This function will create a new buffer if the current one is not updatable
  25677. * @param kind defines the data kind (Position, normal, etc...)
  25678. * @param data defines the data to use
  25679. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25680. */
  25681. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25682. private _updateBoundingInfo;
  25683. /** @hidden */
  25684. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25685. /**
  25686. * Gets total number of vertices
  25687. * @returns the total number of vertices
  25688. */
  25689. getTotalVertices(): number;
  25690. /**
  25691. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25692. * @param kind defines the data kind (Position, normal, etc...)
  25693. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25694. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25695. * @returns a float array containing vertex data
  25696. */
  25697. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25698. /**
  25699. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25700. * @param kind defines the data kind (Position, normal, etc...)
  25701. * @returns true if the vertex buffer with the specified kind is updatable
  25702. */
  25703. isVertexBufferUpdatable(kind: string): boolean;
  25704. /**
  25705. * Gets a specific vertex buffer
  25706. * @param kind defines the data kind (Position, normal, etc...)
  25707. * @returns a VertexBuffer
  25708. */
  25709. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25710. /**
  25711. * Returns all vertex buffers
  25712. * @return an object holding all vertex buffers indexed by kind
  25713. */
  25714. getVertexBuffers(): Nullable<{
  25715. [key: string]: VertexBuffer;
  25716. }>;
  25717. /**
  25718. * Gets a boolean indicating if specific vertex buffer is present
  25719. * @param kind defines the data kind (Position, normal, etc...)
  25720. * @returns true if data is present
  25721. */
  25722. isVerticesDataPresent(kind: string): boolean;
  25723. /**
  25724. * Gets a list of all attached data kinds (Position, normal, etc...)
  25725. * @returns a list of string containing all kinds
  25726. */
  25727. getVerticesDataKinds(): string[];
  25728. /**
  25729. * Update index buffer
  25730. * @param indices defines the indices to store in the index buffer
  25731. * @param offset defines the offset in the target buffer where to store the data
  25732. * @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)
  25733. */
  25734. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25735. /**
  25736. * Creates a new index buffer
  25737. * @param indices defines the indices to store in the index buffer
  25738. * @param totalVertices defines the total number of vertices (could be null)
  25739. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25740. */
  25741. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25742. /**
  25743. * Return the total number of indices
  25744. * @returns the total number of indices
  25745. */
  25746. getTotalIndices(): number;
  25747. /**
  25748. * Gets the index buffer array
  25749. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25750. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25751. * @returns the index buffer array
  25752. */
  25753. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25754. /**
  25755. * Gets the index buffer
  25756. * @return the index buffer
  25757. */
  25758. getIndexBuffer(): Nullable<DataBuffer>;
  25759. /** @hidden */
  25760. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25761. /**
  25762. * Release the associated resources for a specific mesh
  25763. * @param mesh defines the source mesh
  25764. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25765. */
  25766. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25767. /**
  25768. * Apply current geometry to a given mesh
  25769. * @param mesh defines the mesh to apply geometry to
  25770. */
  25771. applyToMesh(mesh: Mesh): void;
  25772. private _updateExtend;
  25773. private _applyToMesh;
  25774. private notifyUpdate;
  25775. /**
  25776. * Load the geometry if it was flagged as delay loaded
  25777. * @param scene defines the hosting scene
  25778. * @param onLoaded defines a callback called when the geometry is loaded
  25779. */
  25780. load(scene: Scene, onLoaded?: () => void): void;
  25781. private _queueLoad;
  25782. /**
  25783. * Invert the geometry to move from a right handed system to a left handed one.
  25784. */
  25785. toLeftHanded(): void;
  25786. /** @hidden */
  25787. _resetPointsArrayCache(): void;
  25788. /** @hidden */
  25789. _generatePointsArray(): boolean;
  25790. /**
  25791. * Gets a value indicating if the geometry is disposed
  25792. * @returns true if the geometry was disposed
  25793. */
  25794. isDisposed(): boolean;
  25795. private _disposeVertexArrayObjects;
  25796. /**
  25797. * Free all associated resources
  25798. */
  25799. dispose(): void;
  25800. /**
  25801. * Clone the current geometry into a new geometry
  25802. * @param id defines the unique ID of the new geometry
  25803. * @returns a new geometry object
  25804. */
  25805. copy(id: string): Geometry;
  25806. /**
  25807. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25808. * @return a JSON representation of the current geometry data (without the vertices data)
  25809. */
  25810. serialize(): any;
  25811. private toNumberArray;
  25812. /**
  25813. * Serialize all vertices data into a JSON oject
  25814. * @returns a JSON representation of the current geometry data
  25815. */
  25816. serializeVerticeData(): any;
  25817. /**
  25818. * Extracts a clone of a mesh geometry
  25819. * @param mesh defines the source mesh
  25820. * @param id defines the unique ID of the new geometry object
  25821. * @returns the new geometry object
  25822. */
  25823. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25824. /**
  25825. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25826. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25827. * Be aware Math.random() could cause collisions, but:
  25828. * "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"
  25829. * @returns a string containing a new GUID
  25830. */
  25831. static RandomId(): string;
  25832. /** @hidden */
  25833. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25834. private static _CleanMatricesWeights;
  25835. /**
  25836. * Create a new geometry from persisted data (Using .babylon file format)
  25837. * @param parsedVertexData defines the persisted data
  25838. * @param scene defines the hosting scene
  25839. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25840. * @returns the new geometry object
  25841. */
  25842. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25843. }
  25844. }
  25845. declare module BABYLON {
  25846. /**
  25847. * Define an interface for all classes that will get and set the data on vertices
  25848. */
  25849. export interface IGetSetVerticesData {
  25850. /**
  25851. * Gets a boolean indicating if specific vertex data is present
  25852. * @param kind defines the vertex data kind to use
  25853. * @returns true is data kind is present
  25854. */
  25855. isVerticesDataPresent(kind: string): boolean;
  25856. /**
  25857. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25858. * @param kind defines the data kind (Position, normal, etc...)
  25859. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25860. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25861. * @returns a float array containing vertex data
  25862. */
  25863. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25864. /**
  25865. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25866. * @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.
  25867. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25868. * @returns the indices array or an empty array if the mesh has no geometry
  25869. */
  25870. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25871. /**
  25872. * Set specific vertex data
  25873. * @param kind defines the data kind (Position, normal, etc...)
  25874. * @param data defines the vertex data to use
  25875. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25876. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25877. */
  25878. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25879. /**
  25880. * Update a specific associated vertex buffer
  25881. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25882. * - VertexBuffer.PositionKind
  25883. * - VertexBuffer.UVKind
  25884. * - VertexBuffer.UV2Kind
  25885. * - VertexBuffer.UV3Kind
  25886. * - VertexBuffer.UV4Kind
  25887. * - VertexBuffer.UV5Kind
  25888. * - VertexBuffer.UV6Kind
  25889. * - VertexBuffer.ColorKind
  25890. * - VertexBuffer.MatricesIndicesKind
  25891. * - VertexBuffer.MatricesIndicesExtraKind
  25892. * - VertexBuffer.MatricesWeightsKind
  25893. * - VertexBuffer.MatricesWeightsExtraKind
  25894. * @param data defines the data source
  25895. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25896. * @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)
  25897. */
  25898. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25899. /**
  25900. * Creates a new index buffer
  25901. * @param indices defines the indices to store in the index buffer
  25902. * @param totalVertices defines the total number of vertices (could be null)
  25903. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25904. */
  25905. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25906. }
  25907. /**
  25908. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25909. */
  25910. export class VertexData {
  25911. /**
  25912. * Mesh side orientation : usually the external or front surface
  25913. */
  25914. static readonly FRONTSIDE: number;
  25915. /**
  25916. * Mesh side orientation : usually the internal or back surface
  25917. */
  25918. static readonly BACKSIDE: number;
  25919. /**
  25920. * Mesh side orientation : both internal and external or front and back surfaces
  25921. */
  25922. static readonly DOUBLESIDE: number;
  25923. /**
  25924. * Mesh side orientation : by default, `FRONTSIDE`
  25925. */
  25926. static readonly DEFAULTSIDE: number;
  25927. /**
  25928. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25929. */
  25930. positions: Nullable<FloatArray>;
  25931. /**
  25932. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25933. */
  25934. normals: Nullable<FloatArray>;
  25935. /**
  25936. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25937. */
  25938. tangents: Nullable<FloatArray>;
  25939. /**
  25940. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25941. */
  25942. uvs: Nullable<FloatArray>;
  25943. /**
  25944. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25945. */
  25946. uvs2: Nullable<FloatArray>;
  25947. /**
  25948. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25949. */
  25950. uvs3: Nullable<FloatArray>;
  25951. /**
  25952. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25953. */
  25954. uvs4: Nullable<FloatArray>;
  25955. /**
  25956. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25957. */
  25958. uvs5: Nullable<FloatArray>;
  25959. /**
  25960. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25961. */
  25962. uvs6: Nullable<FloatArray>;
  25963. /**
  25964. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25965. */
  25966. colors: Nullable<FloatArray>;
  25967. /**
  25968. * 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).
  25969. */
  25970. matricesIndices: Nullable<FloatArray>;
  25971. /**
  25972. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25973. */
  25974. matricesWeights: Nullable<FloatArray>;
  25975. /**
  25976. * An array extending the number of possible indices
  25977. */
  25978. matricesIndicesExtra: Nullable<FloatArray>;
  25979. /**
  25980. * An array extending the number of possible weights when the number of indices is extended
  25981. */
  25982. matricesWeightsExtra: Nullable<FloatArray>;
  25983. /**
  25984. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25985. */
  25986. indices: Nullable<IndicesArray>;
  25987. /**
  25988. * Uses the passed data array to set the set the values for the specified kind of data
  25989. * @param data a linear array of floating numbers
  25990. * @param kind the type of data that is being set, eg positions, colors etc
  25991. */
  25992. set(data: FloatArray, kind: string): void;
  25993. /**
  25994. * Associates the vertexData to the passed Mesh.
  25995. * Sets it as updatable or not (default `false`)
  25996. * @param mesh the mesh the vertexData is applied to
  25997. * @param updatable when used and having the value true allows new data to update the vertexData
  25998. * @returns the VertexData
  25999. */
  26000. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26001. /**
  26002. * Associates the vertexData to the passed Geometry.
  26003. * Sets it as updatable or not (default `false`)
  26004. * @param geometry the geometry the vertexData is applied to
  26005. * @param updatable when used and having the value true allows new data to update the vertexData
  26006. * @returns VertexData
  26007. */
  26008. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26009. /**
  26010. * Updates the associated mesh
  26011. * @param mesh the mesh to be updated
  26012. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26013. * @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
  26014. * @returns VertexData
  26015. */
  26016. updateMesh(mesh: Mesh): VertexData;
  26017. /**
  26018. * Updates the associated geometry
  26019. * @param geometry the geometry to be updated
  26020. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26021. * @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
  26022. * @returns VertexData.
  26023. */
  26024. updateGeometry(geometry: Geometry): VertexData;
  26025. private _applyTo;
  26026. private _update;
  26027. /**
  26028. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26029. * @param matrix the transforming matrix
  26030. * @returns the VertexData
  26031. */
  26032. transform(matrix: Matrix): VertexData;
  26033. /**
  26034. * Merges the passed VertexData into the current one
  26035. * @param other the VertexData to be merged into the current one
  26036. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26037. * @returns the modified VertexData
  26038. */
  26039. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26040. private _mergeElement;
  26041. private _validate;
  26042. /**
  26043. * Serializes the VertexData
  26044. * @returns a serialized object
  26045. */
  26046. serialize(): any;
  26047. /**
  26048. * Extracts the vertexData from a mesh
  26049. * @param mesh the mesh from which to extract the VertexData
  26050. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26051. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26052. * @returns the object VertexData associated to the passed mesh
  26053. */
  26054. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26055. /**
  26056. * Extracts the vertexData from the geometry
  26057. * @param geometry the geometry from which to extract the VertexData
  26058. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26059. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26060. * @returns the object VertexData associated to the passed mesh
  26061. */
  26062. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26063. private static _ExtractFrom;
  26064. /**
  26065. * Creates the VertexData for a Ribbon
  26066. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26067. * * pathArray array of paths, each of which an array of successive Vector3
  26068. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26069. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26070. * * 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
  26071. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26072. * * 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)
  26073. * * 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)
  26074. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26075. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26076. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26077. * @returns the VertexData of the ribbon
  26078. */
  26079. static CreateRibbon(options: {
  26080. pathArray: Vector3[][];
  26081. closeArray?: boolean;
  26082. closePath?: boolean;
  26083. offset?: number;
  26084. sideOrientation?: number;
  26085. frontUVs?: Vector4;
  26086. backUVs?: Vector4;
  26087. invertUV?: boolean;
  26088. uvs?: Vector2[];
  26089. colors?: Color4[];
  26090. }): VertexData;
  26091. /**
  26092. * Creates the VertexData for a box
  26093. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26094. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26095. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26096. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26097. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26098. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26099. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26100. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26101. * * 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)
  26102. * * 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)
  26103. * @returns the VertexData of the box
  26104. */
  26105. static CreateBox(options: {
  26106. size?: number;
  26107. width?: number;
  26108. height?: number;
  26109. depth?: number;
  26110. faceUV?: Vector4[];
  26111. faceColors?: Color4[];
  26112. sideOrientation?: number;
  26113. frontUVs?: Vector4;
  26114. backUVs?: Vector4;
  26115. }): VertexData;
  26116. /**
  26117. * Creates the VertexData for a tiled box
  26118. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26119. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26120. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26121. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26122. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26123. * @returns the VertexData of the box
  26124. */
  26125. static CreateTiledBox(options: {
  26126. pattern?: number;
  26127. width?: number;
  26128. height?: number;
  26129. depth?: number;
  26130. tileSize?: number;
  26131. tileWidth?: number;
  26132. tileHeight?: number;
  26133. alignHorizontal?: number;
  26134. alignVertical?: number;
  26135. faceUV?: Vector4[];
  26136. faceColors?: Color4[];
  26137. sideOrientation?: number;
  26138. }): VertexData;
  26139. /**
  26140. * Creates the VertexData for a tiled plane
  26141. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26142. * * pattern a limited pattern arrangement depending on the number
  26143. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26144. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26145. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26146. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26147. * * 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)
  26148. * * 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)
  26149. * @returns the VertexData of the tiled plane
  26150. */
  26151. static CreateTiledPlane(options: {
  26152. pattern?: number;
  26153. tileSize?: number;
  26154. tileWidth?: number;
  26155. tileHeight?: number;
  26156. size?: number;
  26157. width?: number;
  26158. height?: number;
  26159. alignHorizontal?: number;
  26160. alignVertical?: number;
  26161. sideOrientation?: number;
  26162. frontUVs?: Vector4;
  26163. backUVs?: Vector4;
  26164. }): VertexData;
  26165. /**
  26166. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26167. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26168. * * segments sets the number of horizontal strips optional, default 32
  26169. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26170. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26171. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26172. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26173. * * 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
  26174. * * 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
  26175. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26176. * * 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)
  26177. * * 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)
  26178. * @returns the VertexData of the ellipsoid
  26179. */
  26180. static CreateSphere(options: {
  26181. segments?: number;
  26182. diameter?: number;
  26183. diameterX?: number;
  26184. diameterY?: number;
  26185. diameterZ?: number;
  26186. arc?: number;
  26187. slice?: number;
  26188. sideOrientation?: number;
  26189. frontUVs?: Vector4;
  26190. backUVs?: Vector4;
  26191. }): VertexData;
  26192. /**
  26193. * Creates the VertexData for a cylinder, cone or prism
  26194. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26195. * * height sets the height (y direction) of the cylinder, optional, default 2
  26196. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26197. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26198. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26199. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26200. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26201. * * 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
  26202. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26203. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26204. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26205. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26206. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26207. * * 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)
  26208. * * 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)
  26209. * @returns the VertexData of the cylinder, cone or prism
  26210. */
  26211. static CreateCylinder(options: {
  26212. height?: number;
  26213. diameterTop?: number;
  26214. diameterBottom?: number;
  26215. diameter?: number;
  26216. tessellation?: number;
  26217. subdivisions?: number;
  26218. arc?: number;
  26219. faceColors?: Color4[];
  26220. faceUV?: Vector4[];
  26221. hasRings?: boolean;
  26222. enclose?: boolean;
  26223. sideOrientation?: number;
  26224. frontUVs?: Vector4;
  26225. backUVs?: Vector4;
  26226. }): VertexData;
  26227. /**
  26228. * Creates the VertexData for a torus
  26229. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26230. * * diameter the diameter of the torus, optional default 1
  26231. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26232. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26233. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26234. * * 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)
  26235. * * 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)
  26236. * @returns the VertexData of the torus
  26237. */
  26238. static CreateTorus(options: {
  26239. diameter?: number;
  26240. thickness?: number;
  26241. tessellation?: number;
  26242. sideOrientation?: number;
  26243. frontUVs?: Vector4;
  26244. backUVs?: Vector4;
  26245. }): VertexData;
  26246. /**
  26247. * Creates the VertexData of the LineSystem
  26248. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26249. * - lines an array of lines, each line being an array of successive Vector3
  26250. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26251. * @returns the VertexData of the LineSystem
  26252. */
  26253. static CreateLineSystem(options: {
  26254. lines: Vector3[][];
  26255. colors?: Nullable<Color4[][]>;
  26256. }): VertexData;
  26257. /**
  26258. * Create the VertexData for a DashedLines
  26259. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26260. * - points an array successive Vector3
  26261. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26262. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26263. * - dashNb the intended total number of dashes, optional, default 200
  26264. * @returns the VertexData for the DashedLines
  26265. */
  26266. static CreateDashedLines(options: {
  26267. points: Vector3[];
  26268. dashSize?: number;
  26269. gapSize?: number;
  26270. dashNb?: number;
  26271. }): VertexData;
  26272. /**
  26273. * Creates the VertexData for a Ground
  26274. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26275. * - width the width (x direction) of the ground, optional, default 1
  26276. * - height the height (z direction) of the ground, optional, default 1
  26277. * - subdivisions the number of subdivisions per side, optional, default 1
  26278. * @returns the VertexData of the Ground
  26279. */
  26280. static CreateGround(options: {
  26281. width?: number;
  26282. height?: number;
  26283. subdivisions?: number;
  26284. subdivisionsX?: number;
  26285. subdivisionsY?: number;
  26286. }): VertexData;
  26287. /**
  26288. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26289. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26290. * * xmin the ground minimum X coordinate, optional, default -1
  26291. * * zmin the ground minimum Z coordinate, optional, default -1
  26292. * * xmax the ground maximum X coordinate, optional, default 1
  26293. * * zmax the ground maximum Z coordinate, optional, default 1
  26294. * * 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}
  26295. * * 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}
  26296. * @returns the VertexData of the TiledGround
  26297. */
  26298. static CreateTiledGround(options: {
  26299. xmin: number;
  26300. zmin: number;
  26301. xmax: number;
  26302. zmax: number;
  26303. subdivisions?: {
  26304. w: number;
  26305. h: number;
  26306. };
  26307. precision?: {
  26308. w: number;
  26309. h: number;
  26310. };
  26311. }): VertexData;
  26312. /**
  26313. * Creates the VertexData of the Ground designed from a heightmap
  26314. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26315. * * width the width (x direction) of the ground
  26316. * * height the height (z direction) of the ground
  26317. * * subdivisions the number of subdivisions per side
  26318. * * minHeight the minimum altitude on the ground, optional, default 0
  26319. * * maxHeight the maximum altitude on the ground, optional default 1
  26320. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26321. * * buffer the array holding the image color data
  26322. * * bufferWidth the width of image
  26323. * * bufferHeight the height of image
  26324. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26325. * @returns the VertexData of the Ground designed from a heightmap
  26326. */
  26327. static CreateGroundFromHeightMap(options: {
  26328. width: number;
  26329. height: number;
  26330. subdivisions: number;
  26331. minHeight: number;
  26332. maxHeight: number;
  26333. colorFilter: Color3;
  26334. buffer: Uint8Array;
  26335. bufferWidth: number;
  26336. bufferHeight: number;
  26337. alphaFilter: number;
  26338. }): VertexData;
  26339. /**
  26340. * Creates the VertexData for a Plane
  26341. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26342. * * size sets the width and height of the plane to the value of size, optional default 1
  26343. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26344. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26345. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26346. * * 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)
  26347. * * 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)
  26348. * @returns the VertexData of the box
  26349. */
  26350. static CreatePlane(options: {
  26351. size?: number;
  26352. width?: number;
  26353. height?: number;
  26354. sideOrientation?: number;
  26355. frontUVs?: Vector4;
  26356. backUVs?: Vector4;
  26357. }): VertexData;
  26358. /**
  26359. * Creates the VertexData of the Disc or regular Polygon
  26360. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26361. * * radius the radius of the disc, optional default 0.5
  26362. * * tessellation the number of polygon sides, optional, default 64
  26363. * * 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
  26364. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26365. * * 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)
  26366. * * 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)
  26367. * @returns the VertexData of the box
  26368. */
  26369. static CreateDisc(options: {
  26370. radius?: number;
  26371. tessellation?: number;
  26372. arc?: number;
  26373. sideOrientation?: number;
  26374. frontUVs?: Vector4;
  26375. backUVs?: Vector4;
  26376. }): VertexData;
  26377. /**
  26378. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26379. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26380. * @param polygon a mesh built from polygonTriangulation.build()
  26381. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26382. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26383. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26384. * @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)
  26385. * @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)
  26386. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26387. * @returns the VertexData of the Polygon
  26388. */
  26389. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26390. /**
  26391. * Creates the VertexData of the IcoSphere
  26392. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26393. * * radius the radius of the IcoSphere, optional default 1
  26394. * * radiusX allows stretching in the x direction, optional, default radius
  26395. * * radiusY allows stretching in the y direction, optional, default radius
  26396. * * radiusZ allows stretching in the z direction, optional, default radius
  26397. * * flat when true creates a flat shaded mesh, optional, default true
  26398. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26399. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26400. * * 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)
  26401. * * 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)
  26402. * @returns the VertexData of the IcoSphere
  26403. */
  26404. static CreateIcoSphere(options: {
  26405. radius?: number;
  26406. radiusX?: number;
  26407. radiusY?: number;
  26408. radiusZ?: number;
  26409. flat?: boolean;
  26410. subdivisions?: number;
  26411. sideOrientation?: number;
  26412. frontUVs?: Vector4;
  26413. backUVs?: Vector4;
  26414. }): VertexData;
  26415. /**
  26416. * Creates the VertexData for a Polyhedron
  26417. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26418. * * type provided types are:
  26419. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26420. * * 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)
  26421. * * size the size of the IcoSphere, optional default 1
  26422. * * sizeX allows stretching in the x direction, optional, default size
  26423. * * sizeY allows stretching in the y direction, optional, default size
  26424. * * sizeZ allows stretching in the z direction, optional, default size
  26425. * * 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
  26426. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26427. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26428. * * flat when true creates a flat shaded mesh, optional, default true
  26429. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26430. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26431. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  26432. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  26433. * @returns the VertexData of the Polyhedron
  26434. */
  26435. static CreatePolyhedron(options: {
  26436. type?: number;
  26437. size?: number;
  26438. sizeX?: number;
  26439. sizeY?: number;
  26440. sizeZ?: number;
  26441. custom?: any;
  26442. faceUV?: Vector4[];
  26443. faceColors?: Color4[];
  26444. flat?: boolean;
  26445. sideOrientation?: number;
  26446. frontUVs?: Vector4;
  26447. backUVs?: Vector4;
  26448. }): VertexData;
  26449. /**
  26450. * Creates the VertexData for a TorusKnot
  26451. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26452. * * radius the radius of the torus knot, optional, default 2
  26453. * * tube the thickness of the tube, optional, default 0.5
  26454. * * radialSegments the number of sides on each tube segments, optional, default 32
  26455. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26456. * * p the number of windings around the z axis, optional, default 2
  26457. * * q the number of windings around the x axis, optional, default 3
  26458. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26459. * * 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)
  26460. * * 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)
  26461. * @returns the VertexData of the Torus Knot
  26462. */
  26463. static CreateTorusKnot(options: {
  26464. radius?: number;
  26465. tube?: number;
  26466. radialSegments?: number;
  26467. tubularSegments?: number;
  26468. p?: number;
  26469. q?: number;
  26470. sideOrientation?: number;
  26471. frontUVs?: Vector4;
  26472. backUVs?: Vector4;
  26473. }): VertexData;
  26474. /**
  26475. * Compute normals for given positions and indices
  26476. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26477. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26478. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26479. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26480. * * facetNormals : optional array of facet normals (vector3)
  26481. * * facetPositions : optional array of facet positions (vector3)
  26482. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26483. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26484. * * bInfo : optional bounding info, required for facetPartitioning computation
  26485. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26486. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26487. * * useRightHandedSystem: optional boolean to for right handed system computation
  26488. * * depthSort : optional boolean to enable the facet depth sort computation
  26489. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26490. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26491. */
  26492. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26493. facetNormals?: any;
  26494. facetPositions?: any;
  26495. facetPartitioning?: any;
  26496. ratio?: number;
  26497. bInfo?: any;
  26498. bbSize?: Vector3;
  26499. subDiv?: any;
  26500. useRightHandedSystem?: boolean;
  26501. depthSort?: boolean;
  26502. distanceTo?: Vector3;
  26503. depthSortedFacets?: any;
  26504. }): void;
  26505. /** @hidden */
  26506. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26507. /**
  26508. * Applies VertexData created from the imported parameters to the geometry
  26509. * @param parsedVertexData the parsed data from an imported file
  26510. * @param geometry the geometry to apply the VertexData to
  26511. */
  26512. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26513. }
  26514. }
  26515. declare module BABYLON {
  26516. /**
  26517. * Defines a target to use with MorphTargetManager
  26518. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26519. */
  26520. export class MorphTarget implements IAnimatable {
  26521. /** defines the name of the target */
  26522. name: string;
  26523. /**
  26524. * Gets or sets the list of animations
  26525. */
  26526. animations: Animation[];
  26527. private _scene;
  26528. private _positions;
  26529. private _normals;
  26530. private _tangents;
  26531. private _uvs;
  26532. private _influence;
  26533. private _uniqueId;
  26534. /**
  26535. * Observable raised when the influence changes
  26536. */
  26537. onInfluenceChanged: Observable<boolean>;
  26538. /** @hidden */
  26539. _onDataLayoutChanged: Observable<void>;
  26540. /**
  26541. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26542. */
  26543. get influence(): number;
  26544. set influence(influence: number);
  26545. /**
  26546. * Gets or sets the id of the morph Target
  26547. */
  26548. id: string;
  26549. private _animationPropertiesOverride;
  26550. /**
  26551. * Gets or sets the animation properties override
  26552. */
  26553. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26554. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26555. /**
  26556. * Creates a new MorphTarget
  26557. * @param name defines the name of the target
  26558. * @param influence defines the influence to use
  26559. * @param scene defines the scene the morphtarget belongs to
  26560. */
  26561. constructor(
  26562. /** defines the name of the target */
  26563. name: string, influence?: number, scene?: Nullable<Scene>);
  26564. /**
  26565. * Gets the unique ID of this manager
  26566. */
  26567. get uniqueId(): number;
  26568. /**
  26569. * Gets a boolean defining if the target contains position data
  26570. */
  26571. get hasPositions(): boolean;
  26572. /**
  26573. * Gets a boolean defining if the target contains normal data
  26574. */
  26575. get hasNormals(): boolean;
  26576. /**
  26577. * Gets a boolean defining if the target contains tangent data
  26578. */
  26579. get hasTangents(): boolean;
  26580. /**
  26581. * Gets a boolean defining if the target contains texture coordinates data
  26582. */
  26583. get hasUVs(): boolean;
  26584. /**
  26585. * Affects position data to this target
  26586. * @param data defines the position data to use
  26587. */
  26588. setPositions(data: Nullable<FloatArray>): void;
  26589. /**
  26590. * Gets the position data stored in this target
  26591. * @returns a FloatArray containing the position data (or null if not present)
  26592. */
  26593. getPositions(): Nullable<FloatArray>;
  26594. /**
  26595. * Affects normal data to this target
  26596. * @param data defines the normal data to use
  26597. */
  26598. setNormals(data: Nullable<FloatArray>): void;
  26599. /**
  26600. * Gets the normal data stored in this target
  26601. * @returns a FloatArray containing the normal data (or null if not present)
  26602. */
  26603. getNormals(): Nullable<FloatArray>;
  26604. /**
  26605. * Affects tangent data to this target
  26606. * @param data defines the tangent data to use
  26607. */
  26608. setTangents(data: Nullable<FloatArray>): void;
  26609. /**
  26610. * Gets the tangent data stored in this target
  26611. * @returns a FloatArray containing the tangent data (or null if not present)
  26612. */
  26613. getTangents(): Nullable<FloatArray>;
  26614. /**
  26615. * Affects texture coordinates data to this target
  26616. * @param data defines the texture coordinates data to use
  26617. */
  26618. setUVs(data: Nullable<FloatArray>): void;
  26619. /**
  26620. * Gets the texture coordinates data stored in this target
  26621. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26622. */
  26623. getUVs(): Nullable<FloatArray>;
  26624. /**
  26625. * Clone the current target
  26626. * @returns a new MorphTarget
  26627. */
  26628. clone(): MorphTarget;
  26629. /**
  26630. * Serializes the current target into a Serialization object
  26631. * @returns the serialized object
  26632. */
  26633. serialize(): any;
  26634. /**
  26635. * Returns the string "MorphTarget"
  26636. * @returns "MorphTarget"
  26637. */
  26638. getClassName(): string;
  26639. /**
  26640. * Creates a new target from serialized data
  26641. * @param serializationObject defines the serialized data to use
  26642. * @returns a new MorphTarget
  26643. */
  26644. static Parse(serializationObject: any): MorphTarget;
  26645. /**
  26646. * Creates a MorphTarget from mesh data
  26647. * @param mesh defines the source mesh
  26648. * @param name defines the name to use for the new target
  26649. * @param influence defines the influence to attach to the target
  26650. * @returns a new MorphTarget
  26651. */
  26652. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26653. }
  26654. }
  26655. declare module BABYLON {
  26656. /**
  26657. * This class is used to deform meshes using morphing between different targets
  26658. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26659. */
  26660. export class MorphTargetManager {
  26661. private _targets;
  26662. private _targetInfluenceChangedObservers;
  26663. private _targetDataLayoutChangedObservers;
  26664. private _activeTargets;
  26665. private _scene;
  26666. private _influences;
  26667. private _supportsNormals;
  26668. private _supportsTangents;
  26669. private _supportsUVs;
  26670. private _vertexCount;
  26671. private _uniqueId;
  26672. private _tempInfluences;
  26673. /**
  26674. * Gets or sets a boolean indicating if normals must be morphed
  26675. */
  26676. enableNormalMorphing: boolean;
  26677. /**
  26678. * Gets or sets a boolean indicating if tangents must be morphed
  26679. */
  26680. enableTangentMorphing: boolean;
  26681. /**
  26682. * Gets or sets a boolean indicating if UV must be morphed
  26683. */
  26684. enableUVMorphing: boolean;
  26685. /**
  26686. * Creates a new MorphTargetManager
  26687. * @param scene defines the current scene
  26688. */
  26689. constructor(scene?: Nullable<Scene>);
  26690. /**
  26691. * Gets the unique ID of this manager
  26692. */
  26693. get uniqueId(): number;
  26694. /**
  26695. * Gets the number of vertices handled by this manager
  26696. */
  26697. get vertexCount(): number;
  26698. /**
  26699. * Gets a boolean indicating if this manager supports morphing of normals
  26700. */
  26701. get supportsNormals(): boolean;
  26702. /**
  26703. * Gets a boolean indicating if this manager supports morphing of tangents
  26704. */
  26705. get supportsTangents(): boolean;
  26706. /**
  26707. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26708. */
  26709. get supportsUVs(): boolean;
  26710. /**
  26711. * Gets the number of targets stored in this manager
  26712. */
  26713. get numTargets(): number;
  26714. /**
  26715. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26716. */
  26717. get numInfluencers(): number;
  26718. /**
  26719. * Gets the list of influences (one per target)
  26720. */
  26721. get influences(): Float32Array;
  26722. /**
  26723. * Gets the active target at specified index. An active target is a target with an influence > 0
  26724. * @param index defines the index to check
  26725. * @returns the requested target
  26726. */
  26727. getActiveTarget(index: number): MorphTarget;
  26728. /**
  26729. * Gets the target at specified index
  26730. * @param index defines the index to check
  26731. * @returns the requested target
  26732. */
  26733. getTarget(index: number): MorphTarget;
  26734. /**
  26735. * Add a new target to this manager
  26736. * @param target defines the target to add
  26737. */
  26738. addTarget(target: MorphTarget): void;
  26739. /**
  26740. * Removes a target from the manager
  26741. * @param target defines the target to remove
  26742. */
  26743. removeTarget(target: MorphTarget): void;
  26744. /**
  26745. * Clone the current manager
  26746. * @returns a new MorphTargetManager
  26747. */
  26748. clone(): MorphTargetManager;
  26749. /**
  26750. * Serializes the current manager into a Serialization object
  26751. * @returns the serialized object
  26752. */
  26753. serialize(): any;
  26754. private _syncActiveTargets;
  26755. /**
  26756. * Syncrhonize the targets with all the meshes using this morph target manager
  26757. */
  26758. synchronize(): void;
  26759. /**
  26760. * Creates a new MorphTargetManager from serialized data
  26761. * @param serializationObject defines the serialized data
  26762. * @param scene defines the hosting scene
  26763. * @returns the new MorphTargetManager
  26764. */
  26765. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26766. }
  26767. }
  26768. declare module BABYLON {
  26769. /**
  26770. * Class used to represent a specific level of detail of a mesh
  26771. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26772. */
  26773. export class MeshLODLevel {
  26774. /** Defines the distance where this level should start being displayed */
  26775. distance: number;
  26776. /** Defines the mesh to use to render this level */
  26777. mesh: Nullable<Mesh>;
  26778. /**
  26779. * Creates a new LOD level
  26780. * @param distance defines the distance where this level should star being displayed
  26781. * @param mesh defines the mesh to use to render this level
  26782. */
  26783. constructor(
  26784. /** Defines the distance where this level should start being displayed */
  26785. distance: number,
  26786. /** Defines the mesh to use to render this level */
  26787. mesh: Nullable<Mesh>);
  26788. }
  26789. }
  26790. declare module BABYLON {
  26791. /**
  26792. * Helper class used to generate a canvas to manipulate images
  26793. */
  26794. export class CanvasGenerator {
  26795. /**
  26796. * Create a new canvas (or offscreen canvas depending on the context)
  26797. * @param width defines the expected width
  26798. * @param height defines the expected height
  26799. * @return a new canvas or offscreen canvas
  26800. */
  26801. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  26802. }
  26803. }
  26804. declare module BABYLON {
  26805. /**
  26806. * Mesh representing the gorund
  26807. */
  26808. export class GroundMesh extends Mesh {
  26809. /** If octree should be generated */
  26810. generateOctree: boolean;
  26811. private _heightQuads;
  26812. /** @hidden */
  26813. _subdivisionsX: number;
  26814. /** @hidden */
  26815. _subdivisionsY: number;
  26816. /** @hidden */
  26817. _width: number;
  26818. /** @hidden */
  26819. _height: number;
  26820. /** @hidden */
  26821. _minX: number;
  26822. /** @hidden */
  26823. _maxX: number;
  26824. /** @hidden */
  26825. _minZ: number;
  26826. /** @hidden */
  26827. _maxZ: number;
  26828. constructor(name: string, scene: Scene);
  26829. /**
  26830. * "GroundMesh"
  26831. * @returns "GroundMesh"
  26832. */
  26833. getClassName(): string;
  26834. /**
  26835. * The minimum of x and y subdivisions
  26836. */
  26837. get subdivisions(): number;
  26838. /**
  26839. * X subdivisions
  26840. */
  26841. get subdivisionsX(): number;
  26842. /**
  26843. * Y subdivisions
  26844. */
  26845. get subdivisionsY(): number;
  26846. /**
  26847. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26848. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26849. * @param chunksCount the number of subdivisions for x and y
  26850. * @param octreeBlocksSize (Default: 32)
  26851. */
  26852. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26853. /**
  26854. * Returns a height (y) value in the Worl system :
  26855. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26856. * @param x x coordinate
  26857. * @param z z coordinate
  26858. * @returns the ground y position if (x, z) are outside the ground surface.
  26859. */
  26860. getHeightAtCoordinates(x: number, z: number): number;
  26861. /**
  26862. * Returns a normalized vector (Vector3) orthogonal to the ground
  26863. * at the ground coordinates (x, z) expressed in the World system.
  26864. * @param x x coordinate
  26865. * @param z z coordinate
  26866. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26867. */
  26868. getNormalAtCoordinates(x: number, z: number): Vector3;
  26869. /**
  26870. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26871. * at the ground coordinates (x, z) expressed in the World system.
  26872. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26873. * @param x x coordinate
  26874. * @param z z coordinate
  26875. * @param ref vector to store the result
  26876. * @returns the GroundMesh.
  26877. */
  26878. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26879. /**
  26880. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26881. * if the ground has been updated.
  26882. * This can be used in the render loop.
  26883. * @returns the GroundMesh.
  26884. */
  26885. updateCoordinateHeights(): GroundMesh;
  26886. private _getFacetAt;
  26887. private _initHeightQuads;
  26888. private _computeHeightQuads;
  26889. /**
  26890. * Serializes this ground mesh
  26891. * @param serializationObject object to write serialization to
  26892. */
  26893. serialize(serializationObject: any): void;
  26894. /**
  26895. * Parses a serialized ground mesh
  26896. * @param parsedMesh the serialized mesh
  26897. * @param scene the scene to create the ground mesh in
  26898. * @returns the created ground mesh
  26899. */
  26900. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26901. }
  26902. }
  26903. declare module BABYLON {
  26904. /**
  26905. * Interface for Physics-Joint data
  26906. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26907. */
  26908. export interface PhysicsJointData {
  26909. /**
  26910. * The main pivot of the joint
  26911. */
  26912. mainPivot?: Vector3;
  26913. /**
  26914. * The connected pivot of the joint
  26915. */
  26916. connectedPivot?: Vector3;
  26917. /**
  26918. * The main axis of the joint
  26919. */
  26920. mainAxis?: Vector3;
  26921. /**
  26922. * The connected axis of the joint
  26923. */
  26924. connectedAxis?: Vector3;
  26925. /**
  26926. * The collision of the joint
  26927. */
  26928. collision?: boolean;
  26929. /**
  26930. * Native Oimo/Cannon/Energy data
  26931. */
  26932. nativeParams?: any;
  26933. }
  26934. /**
  26935. * This is a holder class for the physics joint created by the physics plugin
  26936. * It holds a set of functions to control the underlying joint
  26937. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26938. */
  26939. export class PhysicsJoint {
  26940. /**
  26941. * The type of the physics joint
  26942. */
  26943. type: number;
  26944. /**
  26945. * The data for the physics joint
  26946. */
  26947. jointData: PhysicsJointData;
  26948. private _physicsJoint;
  26949. protected _physicsPlugin: IPhysicsEnginePlugin;
  26950. /**
  26951. * Initializes the physics joint
  26952. * @param type The type of the physics joint
  26953. * @param jointData The data for the physics joint
  26954. */
  26955. constructor(
  26956. /**
  26957. * The type of the physics joint
  26958. */
  26959. type: number,
  26960. /**
  26961. * The data for the physics joint
  26962. */
  26963. jointData: PhysicsJointData);
  26964. /**
  26965. * Gets the physics joint
  26966. */
  26967. get physicsJoint(): any;
  26968. /**
  26969. * Sets the physics joint
  26970. */
  26971. set physicsJoint(newJoint: any);
  26972. /**
  26973. * Sets the physics plugin
  26974. */
  26975. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26976. /**
  26977. * Execute a function that is physics-plugin specific.
  26978. * @param {Function} func the function that will be executed.
  26979. * It accepts two parameters: the physics world and the physics joint
  26980. */
  26981. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26982. /**
  26983. * Distance-Joint type
  26984. */
  26985. static DistanceJoint: number;
  26986. /**
  26987. * Hinge-Joint type
  26988. */
  26989. static HingeJoint: number;
  26990. /**
  26991. * Ball-and-Socket joint type
  26992. */
  26993. static BallAndSocketJoint: number;
  26994. /**
  26995. * Wheel-Joint type
  26996. */
  26997. static WheelJoint: number;
  26998. /**
  26999. * Slider-Joint type
  27000. */
  27001. static SliderJoint: number;
  27002. /**
  27003. * Prismatic-Joint type
  27004. */
  27005. static PrismaticJoint: number;
  27006. /**
  27007. * Universal-Joint type
  27008. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27009. */
  27010. static UniversalJoint: number;
  27011. /**
  27012. * Hinge-Joint 2 type
  27013. */
  27014. static Hinge2Joint: number;
  27015. /**
  27016. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27017. */
  27018. static PointToPointJoint: number;
  27019. /**
  27020. * Spring-Joint type
  27021. */
  27022. static SpringJoint: number;
  27023. /**
  27024. * Lock-Joint type
  27025. */
  27026. static LockJoint: number;
  27027. }
  27028. /**
  27029. * A class representing a physics distance joint
  27030. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27031. */
  27032. export class DistanceJoint extends PhysicsJoint {
  27033. /**
  27034. *
  27035. * @param jointData The data for the Distance-Joint
  27036. */
  27037. constructor(jointData: DistanceJointData);
  27038. /**
  27039. * Update the predefined distance.
  27040. * @param maxDistance The maximum preferred distance
  27041. * @param minDistance The minimum preferred distance
  27042. */
  27043. updateDistance(maxDistance: number, minDistance?: number): void;
  27044. }
  27045. /**
  27046. * Represents a Motor-Enabled Joint
  27047. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27048. */
  27049. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27050. /**
  27051. * Initializes the Motor-Enabled Joint
  27052. * @param type The type of the joint
  27053. * @param jointData The physica joint data for the joint
  27054. */
  27055. constructor(type: number, jointData: PhysicsJointData);
  27056. /**
  27057. * Set the motor values.
  27058. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27059. * @param force the force to apply
  27060. * @param maxForce max force for this motor.
  27061. */
  27062. setMotor(force?: number, maxForce?: number): void;
  27063. /**
  27064. * Set the motor's limits.
  27065. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27066. * @param upperLimit The upper limit of the motor
  27067. * @param lowerLimit The lower limit of the motor
  27068. */
  27069. setLimit(upperLimit: number, lowerLimit?: number): void;
  27070. }
  27071. /**
  27072. * This class represents a single physics Hinge-Joint
  27073. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27074. */
  27075. export class HingeJoint extends MotorEnabledJoint {
  27076. /**
  27077. * Initializes the Hinge-Joint
  27078. * @param jointData The joint data for the Hinge-Joint
  27079. */
  27080. constructor(jointData: PhysicsJointData);
  27081. /**
  27082. * Set the motor values.
  27083. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27084. * @param {number} force the force to apply
  27085. * @param {number} maxForce max force for this motor.
  27086. */
  27087. setMotor(force?: number, maxForce?: number): void;
  27088. /**
  27089. * Set the motor's limits.
  27090. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27091. * @param upperLimit The upper limit of the motor
  27092. * @param lowerLimit The lower limit of the motor
  27093. */
  27094. setLimit(upperLimit: number, lowerLimit?: number): void;
  27095. }
  27096. /**
  27097. * This class represents a dual hinge physics joint (same as wheel joint)
  27098. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27099. */
  27100. export class Hinge2Joint extends MotorEnabledJoint {
  27101. /**
  27102. * Initializes the Hinge2-Joint
  27103. * @param jointData The joint data for the Hinge2-Joint
  27104. */
  27105. constructor(jointData: PhysicsJointData);
  27106. /**
  27107. * Set the motor values.
  27108. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27109. * @param {number} targetSpeed the speed the motor is to reach
  27110. * @param {number} maxForce max force for this motor.
  27111. * @param {motorIndex} the motor's index, 0 or 1.
  27112. */
  27113. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27114. /**
  27115. * Set the motor limits.
  27116. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27117. * @param {number} upperLimit the upper limit
  27118. * @param {number} lowerLimit lower limit
  27119. * @param {motorIndex} the motor's index, 0 or 1.
  27120. */
  27121. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27122. }
  27123. /**
  27124. * Interface for a motor enabled joint
  27125. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27126. */
  27127. export interface IMotorEnabledJoint {
  27128. /**
  27129. * Physics joint
  27130. */
  27131. physicsJoint: any;
  27132. /**
  27133. * Sets the motor of the motor-enabled joint
  27134. * @param force The force of the motor
  27135. * @param maxForce The maximum force of the motor
  27136. * @param motorIndex The index of the motor
  27137. */
  27138. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27139. /**
  27140. * Sets the limit of the motor
  27141. * @param upperLimit The upper limit of the motor
  27142. * @param lowerLimit The lower limit of the motor
  27143. * @param motorIndex The index of the motor
  27144. */
  27145. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27146. }
  27147. /**
  27148. * Joint data for a Distance-Joint
  27149. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27150. */
  27151. export interface DistanceJointData extends PhysicsJointData {
  27152. /**
  27153. * Max distance the 2 joint objects can be apart
  27154. */
  27155. maxDistance: number;
  27156. }
  27157. /**
  27158. * Joint data from a spring joint
  27159. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27160. */
  27161. export interface SpringJointData extends PhysicsJointData {
  27162. /**
  27163. * Length of the spring
  27164. */
  27165. length: number;
  27166. /**
  27167. * Stiffness of the spring
  27168. */
  27169. stiffness: number;
  27170. /**
  27171. * Damping of the spring
  27172. */
  27173. damping: number;
  27174. /** this callback will be called when applying the force to the impostors. */
  27175. forceApplicationCallback: () => void;
  27176. }
  27177. }
  27178. declare module BABYLON {
  27179. /**
  27180. * Holds the data for the raycast result
  27181. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27182. */
  27183. export class PhysicsRaycastResult {
  27184. private _hasHit;
  27185. private _hitDistance;
  27186. private _hitNormalWorld;
  27187. private _hitPointWorld;
  27188. private _rayFromWorld;
  27189. private _rayToWorld;
  27190. /**
  27191. * Gets if there was a hit
  27192. */
  27193. get hasHit(): boolean;
  27194. /**
  27195. * Gets the distance from the hit
  27196. */
  27197. get hitDistance(): number;
  27198. /**
  27199. * Gets the hit normal/direction in the world
  27200. */
  27201. get hitNormalWorld(): Vector3;
  27202. /**
  27203. * Gets the hit point in the world
  27204. */
  27205. get hitPointWorld(): Vector3;
  27206. /**
  27207. * Gets the ray "start point" of the ray in the world
  27208. */
  27209. get rayFromWorld(): Vector3;
  27210. /**
  27211. * Gets the ray "end point" of the ray in the world
  27212. */
  27213. get rayToWorld(): Vector3;
  27214. /**
  27215. * Sets the hit data (normal & point in world space)
  27216. * @param hitNormalWorld defines the normal in world space
  27217. * @param hitPointWorld defines the point in world space
  27218. */
  27219. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27220. /**
  27221. * Sets the distance from the start point to the hit point
  27222. * @param distance
  27223. */
  27224. setHitDistance(distance: number): void;
  27225. /**
  27226. * Calculates the distance manually
  27227. */
  27228. calculateHitDistance(): void;
  27229. /**
  27230. * Resets all the values to default
  27231. * @param from The from point on world space
  27232. * @param to The to point on world space
  27233. */
  27234. reset(from?: Vector3, to?: Vector3): void;
  27235. }
  27236. /**
  27237. * Interface for the size containing width and height
  27238. */
  27239. interface IXYZ {
  27240. /**
  27241. * X
  27242. */
  27243. x: number;
  27244. /**
  27245. * Y
  27246. */
  27247. y: number;
  27248. /**
  27249. * Z
  27250. */
  27251. z: number;
  27252. }
  27253. }
  27254. declare module BABYLON {
  27255. /**
  27256. * Interface used to describe a physics joint
  27257. */
  27258. export interface PhysicsImpostorJoint {
  27259. /** Defines the main impostor to which the joint is linked */
  27260. mainImpostor: PhysicsImpostor;
  27261. /** Defines the impostor that is connected to the main impostor using this joint */
  27262. connectedImpostor: PhysicsImpostor;
  27263. /** Defines the joint itself */
  27264. joint: PhysicsJoint;
  27265. }
  27266. /** @hidden */
  27267. export interface IPhysicsEnginePlugin {
  27268. world: any;
  27269. name: string;
  27270. setGravity(gravity: Vector3): void;
  27271. setTimeStep(timeStep: number): void;
  27272. getTimeStep(): number;
  27273. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27274. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27275. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27276. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27277. removePhysicsBody(impostor: PhysicsImpostor): void;
  27278. generateJoint(joint: PhysicsImpostorJoint): void;
  27279. removeJoint(joint: PhysicsImpostorJoint): void;
  27280. isSupported(): boolean;
  27281. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27282. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27283. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27284. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27285. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27286. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27287. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27288. getBodyMass(impostor: PhysicsImpostor): number;
  27289. getBodyFriction(impostor: PhysicsImpostor): number;
  27290. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27291. getBodyRestitution(impostor: PhysicsImpostor): number;
  27292. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27293. getBodyPressure?(impostor: PhysicsImpostor): number;
  27294. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27295. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27296. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27297. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27298. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27299. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27300. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27301. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27302. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27303. sleepBody(impostor: PhysicsImpostor): void;
  27304. wakeUpBody(impostor: PhysicsImpostor): void;
  27305. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27306. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27307. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27308. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27309. getRadius(impostor: PhysicsImpostor): number;
  27310. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27311. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27312. dispose(): void;
  27313. }
  27314. /**
  27315. * Interface used to define a physics engine
  27316. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27317. */
  27318. export interface IPhysicsEngine {
  27319. /**
  27320. * Gets the gravity vector used by the simulation
  27321. */
  27322. gravity: Vector3;
  27323. /**
  27324. * Sets the gravity vector used by the simulation
  27325. * @param gravity defines the gravity vector to use
  27326. */
  27327. setGravity(gravity: Vector3): void;
  27328. /**
  27329. * Set the time step of the physics engine.
  27330. * Default is 1/60.
  27331. * To slow it down, enter 1/600 for example.
  27332. * To speed it up, 1/30
  27333. * @param newTimeStep the new timestep to apply to this world.
  27334. */
  27335. setTimeStep(newTimeStep: number): void;
  27336. /**
  27337. * Get the time step of the physics engine.
  27338. * @returns the current time step
  27339. */
  27340. getTimeStep(): number;
  27341. /**
  27342. * Set the sub time step of the physics engine.
  27343. * Default is 0 meaning there is no sub steps
  27344. * To increase physics resolution precision, set a small value (like 1 ms)
  27345. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27346. */
  27347. setSubTimeStep(subTimeStep: number): void;
  27348. /**
  27349. * Get the sub time step of the physics engine.
  27350. * @returns the current sub time step
  27351. */
  27352. getSubTimeStep(): number;
  27353. /**
  27354. * Release all resources
  27355. */
  27356. dispose(): void;
  27357. /**
  27358. * Gets the name of the current physics plugin
  27359. * @returns the name of the plugin
  27360. */
  27361. getPhysicsPluginName(): string;
  27362. /**
  27363. * Adding a new impostor for the impostor tracking.
  27364. * This will be done by the impostor itself.
  27365. * @param impostor the impostor to add
  27366. */
  27367. addImpostor(impostor: PhysicsImpostor): void;
  27368. /**
  27369. * Remove an impostor from the engine.
  27370. * This impostor and its mesh will not longer be updated by the physics engine.
  27371. * @param impostor the impostor to remove
  27372. */
  27373. removeImpostor(impostor: PhysicsImpostor): void;
  27374. /**
  27375. * Add a joint to the physics engine
  27376. * @param mainImpostor defines the main impostor to which the joint is added.
  27377. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27378. * @param joint defines the joint that will connect both impostors.
  27379. */
  27380. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27381. /**
  27382. * Removes a joint from the simulation
  27383. * @param mainImpostor defines the impostor used with the joint
  27384. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27385. * @param joint defines the joint to remove
  27386. */
  27387. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27388. /**
  27389. * Gets the current plugin used to run the simulation
  27390. * @returns current plugin
  27391. */
  27392. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27393. /**
  27394. * Gets the list of physic impostors
  27395. * @returns an array of PhysicsImpostor
  27396. */
  27397. getImpostors(): Array<PhysicsImpostor>;
  27398. /**
  27399. * Gets the impostor for a physics enabled object
  27400. * @param object defines the object impersonated by the impostor
  27401. * @returns the PhysicsImpostor or null if not found
  27402. */
  27403. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27404. /**
  27405. * Gets the impostor for a physics body object
  27406. * @param body defines physics body used by the impostor
  27407. * @returns the PhysicsImpostor or null if not found
  27408. */
  27409. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27410. /**
  27411. * Does a raycast in the physics world
  27412. * @param from when should the ray start?
  27413. * @param to when should the ray end?
  27414. * @returns PhysicsRaycastResult
  27415. */
  27416. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27417. /**
  27418. * Called by the scene. No need to call it.
  27419. * @param delta defines the timespam between frames
  27420. */
  27421. _step(delta: number): void;
  27422. }
  27423. }
  27424. declare module BABYLON {
  27425. /**
  27426. * The interface for the physics imposter parameters
  27427. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27428. */
  27429. export interface PhysicsImpostorParameters {
  27430. /**
  27431. * The mass of the physics imposter
  27432. */
  27433. mass: number;
  27434. /**
  27435. * The friction of the physics imposter
  27436. */
  27437. friction?: number;
  27438. /**
  27439. * The coefficient of restitution of the physics imposter
  27440. */
  27441. restitution?: number;
  27442. /**
  27443. * The native options of the physics imposter
  27444. */
  27445. nativeOptions?: any;
  27446. /**
  27447. * Specifies if the parent should be ignored
  27448. */
  27449. ignoreParent?: boolean;
  27450. /**
  27451. * Specifies if bi-directional transformations should be disabled
  27452. */
  27453. disableBidirectionalTransformation?: boolean;
  27454. /**
  27455. * The pressure inside the physics imposter, soft object only
  27456. */
  27457. pressure?: number;
  27458. /**
  27459. * The stiffness the physics imposter, soft object only
  27460. */
  27461. stiffness?: number;
  27462. /**
  27463. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27464. */
  27465. velocityIterations?: number;
  27466. /**
  27467. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27468. */
  27469. positionIterations?: number;
  27470. /**
  27471. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27472. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27473. * Add to fix multiple points
  27474. */
  27475. fixedPoints?: number;
  27476. /**
  27477. * The collision margin around a soft object
  27478. */
  27479. margin?: number;
  27480. /**
  27481. * The collision margin around a soft object
  27482. */
  27483. damping?: number;
  27484. /**
  27485. * The path for a rope based on an extrusion
  27486. */
  27487. path?: any;
  27488. /**
  27489. * The shape of an extrusion used for a rope based on an extrusion
  27490. */
  27491. shape?: any;
  27492. }
  27493. /**
  27494. * Interface for a physics-enabled object
  27495. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27496. */
  27497. export interface IPhysicsEnabledObject {
  27498. /**
  27499. * The position of the physics-enabled object
  27500. */
  27501. position: Vector3;
  27502. /**
  27503. * The rotation of the physics-enabled object
  27504. */
  27505. rotationQuaternion: Nullable<Quaternion>;
  27506. /**
  27507. * The scale of the physics-enabled object
  27508. */
  27509. scaling: Vector3;
  27510. /**
  27511. * The rotation of the physics-enabled object
  27512. */
  27513. rotation?: Vector3;
  27514. /**
  27515. * The parent of the physics-enabled object
  27516. */
  27517. parent?: any;
  27518. /**
  27519. * The bounding info of the physics-enabled object
  27520. * @returns The bounding info of the physics-enabled object
  27521. */
  27522. getBoundingInfo(): BoundingInfo;
  27523. /**
  27524. * Computes the world matrix
  27525. * @param force Specifies if the world matrix should be computed by force
  27526. * @returns A world matrix
  27527. */
  27528. computeWorldMatrix(force: boolean): Matrix;
  27529. /**
  27530. * Gets the world matrix
  27531. * @returns A world matrix
  27532. */
  27533. getWorldMatrix?(): Matrix;
  27534. /**
  27535. * Gets the child meshes
  27536. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27537. * @returns An array of abstract meshes
  27538. */
  27539. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27540. /**
  27541. * Gets the vertex data
  27542. * @param kind The type of vertex data
  27543. * @returns A nullable array of numbers, or a float32 array
  27544. */
  27545. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27546. /**
  27547. * Gets the indices from the mesh
  27548. * @returns A nullable array of index arrays
  27549. */
  27550. getIndices?(): Nullable<IndicesArray>;
  27551. /**
  27552. * Gets the scene from the mesh
  27553. * @returns the indices array or null
  27554. */
  27555. getScene?(): Scene;
  27556. /**
  27557. * Gets the absolute position from the mesh
  27558. * @returns the absolute position
  27559. */
  27560. getAbsolutePosition(): Vector3;
  27561. /**
  27562. * Gets the absolute pivot point from the mesh
  27563. * @returns the absolute pivot point
  27564. */
  27565. getAbsolutePivotPoint(): Vector3;
  27566. /**
  27567. * Rotates the mesh
  27568. * @param axis The axis of rotation
  27569. * @param amount The amount of rotation
  27570. * @param space The space of the rotation
  27571. * @returns The rotation transform node
  27572. */
  27573. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27574. /**
  27575. * Translates the mesh
  27576. * @param axis The axis of translation
  27577. * @param distance The distance of translation
  27578. * @param space The space of the translation
  27579. * @returns The transform node
  27580. */
  27581. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27582. /**
  27583. * Sets the absolute position of the mesh
  27584. * @param absolutePosition The absolute position of the mesh
  27585. * @returns The transform node
  27586. */
  27587. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27588. /**
  27589. * Gets the class name of the mesh
  27590. * @returns The class name
  27591. */
  27592. getClassName(): string;
  27593. }
  27594. /**
  27595. * Represents a physics imposter
  27596. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27597. */
  27598. export class PhysicsImpostor {
  27599. /**
  27600. * The physics-enabled object used as the physics imposter
  27601. */
  27602. object: IPhysicsEnabledObject;
  27603. /**
  27604. * The type of the physics imposter
  27605. */
  27606. type: number;
  27607. private _options;
  27608. private _scene?;
  27609. /**
  27610. * The default object size of the imposter
  27611. */
  27612. static DEFAULT_OBJECT_SIZE: Vector3;
  27613. /**
  27614. * The identity quaternion of the imposter
  27615. */
  27616. static IDENTITY_QUATERNION: Quaternion;
  27617. /** @hidden */
  27618. _pluginData: any;
  27619. private _physicsEngine;
  27620. private _physicsBody;
  27621. private _bodyUpdateRequired;
  27622. private _onBeforePhysicsStepCallbacks;
  27623. private _onAfterPhysicsStepCallbacks;
  27624. /** @hidden */
  27625. _onPhysicsCollideCallbacks: Array<{
  27626. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27627. otherImpostors: Array<PhysicsImpostor>;
  27628. }>;
  27629. private _deltaPosition;
  27630. private _deltaRotation;
  27631. private _deltaRotationConjugated;
  27632. /** @hidden */
  27633. _isFromLine: boolean;
  27634. private _parent;
  27635. private _isDisposed;
  27636. private static _tmpVecs;
  27637. private static _tmpQuat;
  27638. /**
  27639. * Specifies if the physics imposter is disposed
  27640. */
  27641. get isDisposed(): boolean;
  27642. /**
  27643. * Gets the mass of the physics imposter
  27644. */
  27645. get mass(): number;
  27646. set mass(value: number);
  27647. /**
  27648. * Gets the coefficient of friction
  27649. */
  27650. get friction(): number;
  27651. /**
  27652. * Sets the coefficient of friction
  27653. */
  27654. set friction(value: number);
  27655. /**
  27656. * Gets the coefficient of restitution
  27657. */
  27658. get restitution(): number;
  27659. /**
  27660. * Sets the coefficient of restitution
  27661. */
  27662. set restitution(value: number);
  27663. /**
  27664. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27665. */
  27666. get pressure(): number;
  27667. /**
  27668. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27669. */
  27670. set pressure(value: number);
  27671. /**
  27672. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27673. */
  27674. get stiffness(): number;
  27675. /**
  27676. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27677. */
  27678. set stiffness(value: number);
  27679. /**
  27680. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27681. */
  27682. get velocityIterations(): number;
  27683. /**
  27684. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27685. */
  27686. set velocityIterations(value: number);
  27687. /**
  27688. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27689. */
  27690. get positionIterations(): number;
  27691. /**
  27692. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27693. */
  27694. set positionIterations(value: number);
  27695. /**
  27696. * The unique id of the physics imposter
  27697. * set by the physics engine when adding this impostor to the array
  27698. */
  27699. uniqueId: number;
  27700. /**
  27701. * @hidden
  27702. */
  27703. soft: boolean;
  27704. /**
  27705. * @hidden
  27706. */
  27707. segments: number;
  27708. private _joints;
  27709. /**
  27710. * Initializes the physics imposter
  27711. * @param object The physics-enabled object used as the physics imposter
  27712. * @param type The type of the physics imposter
  27713. * @param _options The options for the physics imposter
  27714. * @param _scene The Babylon scene
  27715. */
  27716. constructor(
  27717. /**
  27718. * The physics-enabled object used as the physics imposter
  27719. */
  27720. object: IPhysicsEnabledObject,
  27721. /**
  27722. * The type of the physics imposter
  27723. */
  27724. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27725. /**
  27726. * This function will completly initialize this impostor.
  27727. * It will create a new body - but only if this mesh has no parent.
  27728. * If it has, this impostor will not be used other than to define the impostor
  27729. * of the child mesh.
  27730. * @hidden
  27731. */
  27732. _init(): void;
  27733. private _getPhysicsParent;
  27734. /**
  27735. * Should a new body be generated.
  27736. * @returns boolean specifying if body initialization is required
  27737. */
  27738. isBodyInitRequired(): boolean;
  27739. /**
  27740. * Sets the updated scaling
  27741. * @param updated Specifies if the scaling is updated
  27742. */
  27743. setScalingUpdated(): void;
  27744. /**
  27745. * Force a regeneration of this or the parent's impostor's body.
  27746. * Use under cautious - This will remove all joints already implemented.
  27747. */
  27748. forceUpdate(): void;
  27749. /**
  27750. * Gets the body that holds this impostor. Either its own, or its parent.
  27751. */
  27752. get physicsBody(): any;
  27753. /**
  27754. * Get the parent of the physics imposter
  27755. * @returns Physics imposter or null
  27756. */
  27757. get parent(): Nullable<PhysicsImpostor>;
  27758. /**
  27759. * Sets the parent of the physics imposter
  27760. */
  27761. set parent(value: Nullable<PhysicsImpostor>);
  27762. /**
  27763. * Set the physics body. Used mainly by the physics engine/plugin
  27764. */
  27765. set physicsBody(physicsBody: any);
  27766. /**
  27767. * Resets the update flags
  27768. */
  27769. resetUpdateFlags(): void;
  27770. /**
  27771. * Gets the object extend size
  27772. * @returns the object extend size
  27773. */
  27774. getObjectExtendSize(): Vector3;
  27775. /**
  27776. * Gets the object center
  27777. * @returns The object center
  27778. */
  27779. getObjectCenter(): Vector3;
  27780. /**
  27781. * Get a specific parameter from the options parameters
  27782. * @param paramName The object parameter name
  27783. * @returns The object parameter
  27784. */
  27785. getParam(paramName: string): any;
  27786. /**
  27787. * Sets a specific parameter in the options given to the physics plugin
  27788. * @param paramName The parameter name
  27789. * @param value The value of the parameter
  27790. */
  27791. setParam(paramName: string, value: number): void;
  27792. /**
  27793. * Specifically change the body's mass option. Won't recreate the physics body object
  27794. * @param mass The mass of the physics imposter
  27795. */
  27796. setMass(mass: number): void;
  27797. /**
  27798. * Gets the linear velocity
  27799. * @returns linear velocity or null
  27800. */
  27801. getLinearVelocity(): Nullable<Vector3>;
  27802. /**
  27803. * Sets the linear velocity
  27804. * @param velocity linear velocity or null
  27805. */
  27806. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27807. /**
  27808. * Gets the angular velocity
  27809. * @returns angular velocity or null
  27810. */
  27811. getAngularVelocity(): Nullable<Vector3>;
  27812. /**
  27813. * Sets the angular velocity
  27814. * @param velocity The velocity or null
  27815. */
  27816. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27817. /**
  27818. * Execute a function with the physics plugin native code
  27819. * Provide a function the will have two variables - the world object and the physics body object
  27820. * @param func The function to execute with the physics plugin native code
  27821. */
  27822. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27823. /**
  27824. * Register a function that will be executed before the physics world is stepping forward
  27825. * @param func The function to execute before the physics world is stepped forward
  27826. */
  27827. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27828. /**
  27829. * Unregister a function that will be executed before the physics world is stepping forward
  27830. * @param func The function to execute before the physics world is stepped forward
  27831. */
  27832. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27833. /**
  27834. * Register a function that will be executed after the physics step
  27835. * @param func The function to execute after physics step
  27836. */
  27837. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27838. /**
  27839. * Unregisters a function that will be executed after the physics step
  27840. * @param func The function to execute after physics step
  27841. */
  27842. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27843. /**
  27844. * register a function that will be executed when this impostor collides against a different body
  27845. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27846. * @param func Callback that is executed on collision
  27847. */
  27848. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27849. /**
  27850. * Unregisters the physics imposter on contact
  27851. * @param collideAgainst The physics object to collide against
  27852. * @param func Callback to execute on collision
  27853. */
  27854. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27855. private _tmpQuat;
  27856. private _tmpQuat2;
  27857. /**
  27858. * Get the parent rotation
  27859. * @returns The parent rotation
  27860. */
  27861. getParentsRotation(): Quaternion;
  27862. /**
  27863. * this function is executed by the physics engine.
  27864. */
  27865. beforeStep: () => void;
  27866. /**
  27867. * this function is executed by the physics engine
  27868. */
  27869. afterStep: () => void;
  27870. /**
  27871. * Legacy collision detection event support
  27872. */
  27873. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27874. /**
  27875. * event and body object due to cannon's event-based architecture.
  27876. */
  27877. onCollide: (e: {
  27878. body: any;
  27879. }) => void;
  27880. /**
  27881. * Apply a force
  27882. * @param force The force to apply
  27883. * @param contactPoint The contact point for the force
  27884. * @returns The physics imposter
  27885. */
  27886. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27887. /**
  27888. * Apply an impulse
  27889. * @param force The impulse force
  27890. * @param contactPoint The contact point for the impulse force
  27891. * @returns The physics imposter
  27892. */
  27893. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27894. /**
  27895. * A help function to create a joint
  27896. * @param otherImpostor A physics imposter used to create a joint
  27897. * @param jointType The type of joint
  27898. * @param jointData The data for the joint
  27899. * @returns The physics imposter
  27900. */
  27901. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27902. /**
  27903. * Add a joint to this impostor with a different impostor
  27904. * @param otherImpostor A physics imposter used to add a joint
  27905. * @param joint The joint to add
  27906. * @returns The physics imposter
  27907. */
  27908. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27909. /**
  27910. * Add an anchor to a cloth impostor
  27911. * @param otherImpostor rigid impostor to anchor to
  27912. * @param width ratio across width from 0 to 1
  27913. * @param height ratio up height from 0 to 1
  27914. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27915. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27916. * @returns impostor the soft imposter
  27917. */
  27918. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27919. /**
  27920. * Add a hook to a rope impostor
  27921. * @param otherImpostor rigid impostor to anchor to
  27922. * @param length ratio across rope from 0 to 1
  27923. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27924. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27925. * @returns impostor the rope imposter
  27926. */
  27927. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27928. /**
  27929. * Will keep this body still, in a sleep mode.
  27930. * @returns the physics imposter
  27931. */
  27932. sleep(): PhysicsImpostor;
  27933. /**
  27934. * Wake the body up.
  27935. * @returns The physics imposter
  27936. */
  27937. wakeUp(): PhysicsImpostor;
  27938. /**
  27939. * Clones the physics imposter
  27940. * @param newObject The physics imposter clones to this physics-enabled object
  27941. * @returns A nullable physics imposter
  27942. */
  27943. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27944. /**
  27945. * Disposes the physics imposter
  27946. */
  27947. dispose(): void;
  27948. /**
  27949. * Sets the delta position
  27950. * @param position The delta position amount
  27951. */
  27952. setDeltaPosition(position: Vector3): void;
  27953. /**
  27954. * Sets the delta rotation
  27955. * @param rotation The delta rotation amount
  27956. */
  27957. setDeltaRotation(rotation: Quaternion): void;
  27958. /**
  27959. * Gets the box size of the physics imposter and stores the result in the input parameter
  27960. * @param result Stores the box size
  27961. * @returns The physics imposter
  27962. */
  27963. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27964. /**
  27965. * Gets the radius of the physics imposter
  27966. * @returns Radius of the physics imposter
  27967. */
  27968. getRadius(): number;
  27969. /**
  27970. * Sync a bone with this impostor
  27971. * @param bone The bone to sync to the impostor.
  27972. * @param boneMesh The mesh that the bone is influencing.
  27973. * @param jointPivot The pivot of the joint / bone in local space.
  27974. * @param distToJoint Optional distance from the impostor to the joint.
  27975. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27976. */
  27977. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27978. /**
  27979. * Sync impostor to a bone
  27980. * @param bone The bone that the impostor will be synced to.
  27981. * @param boneMesh The mesh that the bone is influencing.
  27982. * @param jointPivot The pivot of the joint / bone in local space.
  27983. * @param distToJoint Optional distance from the impostor to the joint.
  27984. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27985. * @param boneAxis Optional vector3 axis the bone is aligned with
  27986. */
  27987. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27988. /**
  27989. * No-Imposter type
  27990. */
  27991. static NoImpostor: number;
  27992. /**
  27993. * Sphere-Imposter type
  27994. */
  27995. static SphereImpostor: number;
  27996. /**
  27997. * Box-Imposter type
  27998. */
  27999. static BoxImpostor: number;
  28000. /**
  28001. * Plane-Imposter type
  28002. */
  28003. static PlaneImpostor: number;
  28004. /**
  28005. * Mesh-imposter type
  28006. */
  28007. static MeshImpostor: number;
  28008. /**
  28009. * Capsule-Impostor type (Ammo.js plugin only)
  28010. */
  28011. static CapsuleImpostor: number;
  28012. /**
  28013. * Cylinder-Imposter type
  28014. */
  28015. static CylinderImpostor: number;
  28016. /**
  28017. * Particle-Imposter type
  28018. */
  28019. static ParticleImpostor: number;
  28020. /**
  28021. * Heightmap-Imposter type
  28022. */
  28023. static HeightmapImpostor: number;
  28024. /**
  28025. * ConvexHull-Impostor type (Ammo.js plugin only)
  28026. */
  28027. static ConvexHullImpostor: number;
  28028. /**
  28029. * Custom-Imposter type (Ammo.js plugin only)
  28030. */
  28031. static CustomImpostor: number;
  28032. /**
  28033. * Rope-Imposter type
  28034. */
  28035. static RopeImpostor: number;
  28036. /**
  28037. * Cloth-Imposter type
  28038. */
  28039. static ClothImpostor: number;
  28040. /**
  28041. * Softbody-Imposter type
  28042. */
  28043. static SoftbodyImpostor: number;
  28044. }
  28045. }
  28046. declare module BABYLON {
  28047. /**
  28048. * @hidden
  28049. **/
  28050. export class _CreationDataStorage {
  28051. closePath?: boolean;
  28052. closeArray?: boolean;
  28053. idx: number[];
  28054. dashSize: number;
  28055. gapSize: number;
  28056. path3D: Path3D;
  28057. pathArray: Vector3[][];
  28058. arc: number;
  28059. radius: number;
  28060. cap: number;
  28061. tessellation: number;
  28062. }
  28063. /**
  28064. * @hidden
  28065. **/
  28066. class _InstanceDataStorage {
  28067. visibleInstances: any;
  28068. batchCache: _InstancesBatch;
  28069. instancesBufferSize: number;
  28070. instancesBuffer: Nullable<Buffer>;
  28071. instancesData: Float32Array;
  28072. overridenInstanceCount: number;
  28073. isFrozen: boolean;
  28074. previousBatch: Nullable<_InstancesBatch>;
  28075. hardwareInstancedRendering: boolean;
  28076. sideOrientation: number;
  28077. manualUpdate: boolean;
  28078. }
  28079. /**
  28080. * @hidden
  28081. **/
  28082. export class _InstancesBatch {
  28083. mustReturn: boolean;
  28084. visibleInstances: Nullable<InstancedMesh[]>[];
  28085. renderSelf: boolean[];
  28086. hardwareInstancedRendering: boolean[];
  28087. }
  28088. /**
  28089. * @hidden
  28090. **/
  28091. class _ThinInstanceDataStorage {
  28092. instancesCount: number;
  28093. matrixBuffer: Nullable<Buffer>;
  28094. matrixBufferSize: number;
  28095. matrixData: Nullable<Float32Array>;
  28096. boundingVectors: Array<Vector3>;
  28097. worldMatrices: Nullable<Matrix[]>;
  28098. }
  28099. /**
  28100. * Class used to represent renderable models
  28101. */
  28102. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28103. /**
  28104. * Mesh side orientation : usually the external or front surface
  28105. */
  28106. static readonly FRONTSIDE: number;
  28107. /**
  28108. * Mesh side orientation : usually the internal or back surface
  28109. */
  28110. static readonly BACKSIDE: number;
  28111. /**
  28112. * Mesh side orientation : both internal and external or front and back surfaces
  28113. */
  28114. static readonly DOUBLESIDE: number;
  28115. /**
  28116. * Mesh side orientation : by default, `FRONTSIDE`
  28117. */
  28118. static readonly DEFAULTSIDE: number;
  28119. /**
  28120. * Mesh cap setting : no cap
  28121. */
  28122. static readonly NO_CAP: number;
  28123. /**
  28124. * Mesh cap setting : one cap at the beginning of the mesh
  28125. */
  28126. static readonly CAP_START: number;
  28127. /**
  28128. * Mesh cap setting : one cap at the end of the mesh
  28129. */
  28130. static readonly CAP_END: number;
  28131. /**
  28132. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28133. */
  28134. static readonly CAP_ALL: number;
  28135. /**
  28136. * Mesh pattern setting : no flip or rotate
  28137. */
  28138. static readonly NO_FLIP: number;
  28139. /**
  28140. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28141. */
  28142. static readonly FLIP_TILE: number;
  28143. /**
  28144. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28145. */
  28146. static readonly ROTATE_TILE: number;
  28147. /**
  28148. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28149. */
  28150. static readonly FLIP_ROW: number;
  28151. /**
  28152. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28153. */
  28154. static readonly ROTATE_ROW: number;
  28155. /**
  28156. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28157. */
  28158. static readonly FLIP_N_ROTATE_TILE: number;
  28159. /**
  28160. * Mesh pattern setting : rotate pattern and rotate
  28161. */
  28162. static readonly FLIP_N_ROTATE_ROW: number;
  28163. /**
  28164. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28165. */
  28166. static readonly CENTER: number;
  28167. /**
  28168. * Mesh tile positioning : part tiles on left
  28169. */
  28170. static readonly LEFT: number;
  28171. /**
  28172. * Mesh tile positioning : part tiles on right
  28173. */
  28174. static readonly RIGHT: number;
  28175. /**
  28176. * Mesh tile positioning : part tiles on top
  28177. */
  28178. static readonly TOP: number;
  28179. /**
  28180. * Mesh tile positioning : part tiles on bottom
  28181. */
  28182. static readonly BOTTOM: number;
  28183. /**
  28184. * Gets the default side orientation.
  28185. * @param orientation the orientation to value to attempt to get
  28186. * @returns the default orientation
  28187. * @hidden
  28188. */
  28189. static _GetDefaultSideOrientation(orientation?: number): number;
  28190. private _internalMeshDataInfo;
  28191. get computeBonesUsingShaders(): boolean;
  28192. set computeBonesUsingShaders(value: boolean);
  28193. /**
  28194. * An event triggered before rendering the mesh
  28195. */
  28196. get onBeforeRenderObservable(): Observable<Mesh>;
  28197. /**
  28198. * An event triggered before binding the mesh
  28199. */
  28200. get onBeforeBindObservable(): Observable<Mesh>;
  28201. /**
  28202. * An event triggered after rendering the mesh
  28203. */
  28204. get onAfterRenderObservable(): Observable<Mesh>;
  28205. /**
  28206. * An event triggered before drawing the mesh
  28207. */
  28208. get onBeforeDrawObservable(): Observable<Mesh>;
  28209. private _onBeforeDrawObserver;
  28210. /**
  28211. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28212. */
  28213. set onBeforeDraw(callback: () => void);
  28214. get hasInstances(): boolean;
  28215. get hasThinInstances(): boolean;
  28216. /**
  28217. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28218. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28219. */
  28220. delayLoadState: number;
  28221. /**
  28222. * Gets the list of instances created from this mesh
  28223. * it is not supposed to be modified manually.
  28224. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28225. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28226. */
  28227. instances: InstancedMesh[];
  28228. /**
  28229. * Gets the file containing delay loading data for this mesh
  28230. */
  28231. delayLoadingFile: string;
  28232. /** @hidden */
  28233. _binaryInfo: any;
  28234. /**
  28235. * User defined function used to change how LOD level selection is done
  28236. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28237. */
  28238. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28239. /**
  28240. * Gets or sets the morph target manager
  28241. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28242. */
  28243. get morphTargetManager(): Nullable<MorphTargetManager>;
  28244. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28245. /** @hidden */
  28246. _creationDataStorage: Nullable<_CreationDataStorage>;
  28247. /** @hidden */
  28248. _geometry: Nullable<Geometry>;
  28249. /** @hidden */
  28250. _delayInfo: Array<string>;
  28251. /** @hidden */
  28252. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28253. /** @hidden */
  28254. _instanceDataStorage: _InstanceDataStorage;
  28255. /** @hidden */
  28256. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28257. private _effectiveMaterial;
  28258. /** @hidden */
  28259. _shouldGenerateFlatShading: boolean;
  28260. /** @hidden */
  28261. _originalBuilderSideOrientation: number;
  28262. /**
  28263. * Use this property to change the original side orientation defined at construction time
  28264. */
  28265. overrideMaterialSideOrientation: Nullable<number>;
  28266. /**
  28267. * Gets the source mesh (the one used to clone this one from)
  28268. */
  28269. get source(): Nullable<Mesh>;
  28270. /**
  28271. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28272. */
  28273. get isUnIndexed(): boolean;
  28274. set isUnIndexed(value: boolean);
  28275. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28276. get worldMatrixInstancedBuffer(): Float32Array;
  28277. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28278. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28279. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28280. /**
  28281. * @constructor
  28282. * @param name The value used by scene.getMeshByName() to do a lookup.
  28283. * @param scene The scene to add this mesh to.
  28284. * @param parent The parent of this mesh, if it has one
  28285. * @param source An optional Mesh from which geometry is shared, cloned.
  28286. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28287. * When false, achieved by calling a clone(), also passing False.
  28288. * This will make creation of children, recursive.
  28289. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28290. */
  28291. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28292. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28293. doNotInstantiate: boolean;
  28294. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28295. /**
  28296. * Gets the class name
  28297. * @returns the string "Mesh".
  28298. */
  28299. getClassName(): string;
  28300. /** @hidden */
  28301. get _isMesh(): boolean;
  28302. /**
  28303. * Returns a description of this mesh
  28304. * @param fullDetails define if full details about this mesh must be used
  28305. * @returns a descriptive string representing this mesh
  28306. */
  28307. toString(fullDetails?: boolean): string;
  28308. /** @hidden */
  28309. _unBindEffect(): void;
  28310. /**
  28311. * Gets a boolean indicating if this mesh has LOD
  28312. */
  28313. get hasLODLevels(): boolean;
  28314. /**
  28315. * Gets the list of MeshLODLevel associated with the current mesh
  28316. * @returns an array of MeshLODLevel
  28317. */
  28318. getLODLevels(): MeshLODLevel[];
  28319. private _sortLODLevels;
  28320. /**
  28321. * Add a mesh as LOD level triggered at the given distance.
  28322. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28323. * @param distance The distance from the center of the object to show this level
  28324. * @param mesh The mesh to be added as LOD level (can be null)
  28325. * @return This mesh (for chaining)
  28326. */
  28327. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28328. /**
  28329. * Returns the LOD level mesh at the passed distance or null if not found.
  28330. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28331. * @param distance The distance from the center of the object to show this level
  28332. * @returns a Mesh or `null`
  28333. */
  28334. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28335. /**
  28336. * Remove a mesh from the LOD array
  28337. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28338. * @param mesh defines the mesh to be removed
  28339. * @return This mesh (for chaining)
  28340. */
  28341. removeLODLevel(mesh: Mesh): Mesh;
  28342. /**
  28343. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28344. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28345. * @param camera defines the camera to use to compute distance
  28346. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28347. * @return This mesh (for chaining)
  28348. */
  28349. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28350. /**
  28351. * Gets the mesh internal Geometry object
  28352. */
  28353. get geometry(): Nullable<Geometry>;
  28354. /**
  28355. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28356. * @returns the total number of vertices
  28357. */
  28358. getTotalVertices(): number;
  28359. /**
  28360. * Returns the content of an associated vertex buffer
  28361. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28362. * - VertexBuffer.PositionKind
  28363. * - VertexBuffer.UVKind
  28364. * - VertexBuffer.UV2Kind
  28365. * - VertexBuffer.UV3Kind
  28366. * - VertexBuffer.UV4Kind
  28367. * - VertexBuffer.UV5Kind
  28368. * - VertexBuffer.UV6Kind
  28369. * - VertexBuffer.ColorKind
  28370. * - VertexBuffer.MatricesIndicesKind
  28371. * - VertexBuffer.MatricesIndicesExtraKind
  28372. * - VertexBuffer.MatricesWeightsKind
  28373. * - VertexBuffer.MatricesWeightsExtraKind
  28374. * @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
  28375. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28376. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28377. */
  28378. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28379. /**
  28380. * Returns the mesh VertexBuffer object from the requested `kind`
  28381. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28382. * - VertexBuffer.PositionKind
  28383. * - VertexBuffer.NormalKind
  28384. * - VertexBuffer.UVKind
  28385. * - VertexBuffer.UV2Kind
  28386. * - VertexBuffer.UV3Kind
  28387. * - VertexBuffer.UV4Kind
  28388. * - VertexBuffer.UV5Kind
  28389. * - VertexBuffer.UV6Kind
  28390. * - VertexBuffer.ColorKind
  28391. * - VertexBuffer.MatricesIndicesKind
  28392. * - VertexBuffer.MatricesIndicesExtraKind
  28393. * - VertexBuffer.MatricesWeightsKind
  28394. * - VertexBuffer.MatricesWeightsExtraKind
  28395. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28396. */
  28397. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28398. /**
  28399. * Tests if a specific vertex buffer is associated with this mesh
  28400. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28401. * - VertexBuffer.PositionKind
  28402. * - VertexBuffer.NormalKind
  28403. * - VertexBuffer.UVKind
  28404. * - VertexBuffer.UV2Kind
  28405. * - VertexBuffer.UV3Kind
  28406. * - VertexBuffer.UV4Kind
  28407. * - VertexBuffer.UV5Kind
  28408. * - VertexBuffer.UV6Kind
  28409. * - VertexBuffer.ColorKind
  28410. * - VertexBuffer.MatricesIndicesKind
  28411. * - VertexBuffer.MatricesIndicesExtraKind
  28412. * - VertexBuffer.MatricesWeightsKind
  28413. * - VertexBuffer.MatricesWeightsExtraKind
  28414. * @returns a boolean
  28415. */
  28416. isVerticesDataPresent(kind: string): boolean;
  28417. /**
  28418. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28419. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28420. * - VertexBuffer.PositionKind
  28421. * - VertexBuffer.UVKind
  28422. * - VertexBuffer.UV2Kind
  28423. * - VertexBuffer.UV3Kind
  28424. * - VertexBuffer.UV4Kind
  28425. * - VertexBuffer.UV5Kind
  28426. * - VertexBuffer.UV6Kind
  28427. * - VertexBuffer.ColorKind
  28428. * - VertexBuffer.MatricesIndicesKind
  28429. * - VertexBuffer.MatricesIndicesExtraKind
  28430. * - VertexBuffer.MatricesWeightsKind
  28431. * - VertexBuffer.MatricesWeightsExtraKind
  28432. * @returns a boolean
  28433. */
  28434. isVertexBufferUpdatable(kind: string): boolean;
  28435. /**
  28436. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28437. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28438. * - VertexBuffer.PositionKind
  28439. * - VertexBuffer.NormalKind
  28440. * - VertexBuffer.UVKind
  28441. * - VertexBuffer.UV2Kind
  28442. * - VertexBuffer.UV3Kind
  28443. * - VertexBuffer.UV4Kind
  28444. * - VertexBuffer.UV5Kind
  28445. * - VertexBuffer.UV6Kind
  28446. * - VertexBuffer.ColorKind
  28447. * - VertexBuffer.MatricesIndicesKind
  28448. * - VertexBuffer.MatricesIndicesExtraKind
  28449. * - VertexBuffer.MatricesWeightsKind
  28450. * - VertexBuffer.MatricesWeightsExtraKind
  28451. * @returns an array of strings
  28452. */
  28453. getVerticesDataKinds(): string[];
  28454. /**
  28455. * Returns a positive integer : the total number of indices in this mesh geometry.
  28456. * @returns the numner of indices or zero if the mesh has no geometry.
  28457. */
  28458. getTotalIndices(): number;
  28459. /**
  28460. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28461. * @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.
  28462. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28463. * @returns the indices array or an empty array if the mesh has no geometry
  28464. */
  28465. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28466. get isBlocked(): boolean;
  28467. /**
  28468. * Determine if the current mesh is ready to be rendered
  28469. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28470. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28471. * @returns true if all associated assets are ready (material, textures, shaders)
  28472. */
  28473. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28474. /**
  28475. * 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.
  28476. */
  28477. get areNormalsFrozen(): boolean;
  28478. /**
  28479. * 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.
  28480. * @returns the current mesh
  28481. */
  28482. freezeNormals(): Mesh;
  28483. /**
  28484. * 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
  28485. * @returns the current mesh
  28486. */
  28487. unfreezeNormals(): Mesh;
  28488. /**
  28489. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28490. */
  28491. set overridenInstanceCount(count: number);
  28492. /** @hidden */
  28493. _preActivate(): Mesh;
  28494. /** @hidden */
  28495. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28496. /** @hidden */
  28497. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28498. protected _afterComputeWorldMatrix(): void;
  28499. /** @hidden */
  28500. _postActivate(): void;
  28501. /**
  28502. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28503. * This means the mesh underlying bounding box and sphere are recomputed.
  28504. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28505. * @returns the current mesh
  28506. */
  28507. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28508. /** @hidden */
  28509. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28510. /**
  28511. * This function will subdivide the mesh into multiple submeshes
  28512. * @param count defines the expected number of submeshes
  28513. */
  28514. subdivide(count: number): void;
  28515. /**
  28516. * Copy a FloatArray into a specific associated vertex buffer
  28517. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28518. * - VertexBuffer.PositionKind
  28519. * - VertexBuffer.UVKind
  28520. * - VertexBuffer.UV2Kind
  28521. * - VertexBuffer.UV3Kind
  28522. * - VertexBuffer.UV4Kind
  28523. * - VertexBuffer.UV5Kind
  28524. * - VertexBuffer.UV6Kind
  28525. * - VertexBuffer.ColorKind
  28526. * - VertexBuffer.MatricesIndicesKind
  28527. * - VertexBuffer.MatricesIndicesExtraKind
  28528. * - VertexBuffer.MatricesWeightsKind
  28529. * - VertexBuffer.MatricesWeightsExtraKind
  28530. * @param data defines the data source
  28531. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28532. * @param stride defines the data stride size (can be null)
  28533. * @returns the current mesh
  28534. */
  28535. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28536. /**
  28537. * Delete a vertex buffer associated with this mesh
  28538. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28539. * - VertexBuffer.PositionKind
  28540. * - VertexBuffer.UVKind
  28541. * - VertexBuffer.UV2Kind
  28542. * - VertexBuffer.UV3Kind
  28543. * - VertexBuffer.UV4Kind
  28544. * - VertexBuffer.UV5Kind
  28545. * - VertexBuffer.UV6Kind
  28546. * - VertexBuffer.ColorKind
  28547. * - VertexBuffer.MatricesIndicesKind
  28548. * - VertexBuffer.MatricesIndicesExtraKind
  28549. * - VertexBuffer.MatricesWeightsKind
  28550. * - VertexBuffer.MatricesWeightsExtraKind
  28551. */
  28552. removeVerticesData(kind: string): void;
  28553. /**
  28554. * Flags an associated vertex buffer as updatable
  28555. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28556. * - VertexBuffer.PositionKind
  28557. * - VertexBuffer.UVKind
  28558. * - VertexBuffer.UV2Kind
  28559. * - VertexBuffer.UV3Kind
  28560. * - VertexBuffer.UV4Kind
  28561. * - VertexBuffer.UV5Kind
  28562. * - VertexBuffer.UV6Kind
  28563. * - VertexBuffer.ColorKind
  28564. * - VertexBuffer.MatricesIndicesKind
  28565. * - VertexBuffer.MatricesIndicesExtraKind
  28566. * - VertexBuffer.MatricesWeightsKind
  28567. * - VertexBuffer.MatricesWeightsExtraKind
  28568. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28569. */
  28570. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28571. /**
  28572. * Sets the mesh global Vertex Buffer
  28573. * @param buffer defines the buffer to use
  28574. * @returns the current mesh
  28575. */
  28576. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28577. /**
  28578. * Update a specific associated vertex buffer
  28579. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28580. * - VertexBuffer.PositionKind
  28581. * - VertexBuffer.UVKind
  28582. * - VertexBuffer.UV2Kind
  28583. * - VertexBuffer.UV3Kind
  28584. * - VertexBuffer.UV4Kind
  28585. * - VertexBuffer.UV5Kind
  28586. * - VertexBuffer.UV6Kind
  28587. * - VertexBuffer.ColorKind
  28588. * - VertexBuffer.MatricesIndicesKind
  28589. * - VertexBuffer.MatricesIndicesExtraKind
  28590. * - VertexBuffer.MatricesWeightsKind
  28591. * - VertexBuffer.MatricesWeightsExtraKind
  28592. * @param data defines the data source
  28593. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28594. * @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)
  28595. * @returns the current mesh
  28596. */
  28597. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28598. /**
  28599. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28600. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28601. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28602. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28603. * @returns the current mesh
  28604. */
  28605. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28606. /**
  28607. * Creates a un-shared specific occurence of the geometry for the mesh.
  28608. * @returns the current mesh
  28609. */
  28610. makeGeometryUnique(): Mesh;
  28611. /**
  28612. * Set the index buffer of this mesh
  28613. * @param indices defines the source data
  28614. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28615. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28616. * @returns the current mesh
  28617. */
  28618. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28619. /**
  28620. * Update the current index buffer
  28621. * @param indices defines the source data
  28622. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28623. * @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)
  28624. * @returns the current mesh
  28625. */
  28626. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28627. /**
  28628. * Invert the geometry to move from a right handed system to a left handed one.
  28629. * @returns the current mesh
  28630. */
  28631. toLeftHanded(): Mesh;
  28632. /** @hidden */
  28633. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28634. /** @hidden */
  28635. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28636. /**
  28637. * Registers for this mesh a javascript function called just before the rendering process
  28638. * @param func defines the function to call before rendering this mesh
  28639. * @returns the current mesh
  28640. */
  28641. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28642. /**
  28643. * Disposes a previously registered javascript function called before the rendering
  28644. * @param func defines the function to remove
  28645. * @returns the current mesh
  28646. */
  28647. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28648. /**
  28649. * Registers for this mesh a javascript function called just after the rendering is complete
  28650. * @param func defines the function to call after rendering this mesh
  28651. * @returns the current mesh
  28652. */
  28653. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28654. /**
  28655. * Disposes a previously registered javascript function called after the rendering.
  28656. * @param func defines the function to remove
  28657. * @returns the current mesh
  28658. */
  28659. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28660. /** @hidden */
  28661. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28662. /** @hidden */
  28663. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28664. /** @hidden */
  28665. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28666. /** @hidden */
  28667. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28668. /** @hidden */
  28669. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28670. /** @hidden */
  28671. _rebuild(): void;
  28672. /** @hidden */
  28673. _freeze(): void;
  28674. /** @hidden */
  28675. _unFreeze(): void;
  28676. /**
  28677. * 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
  28678. * @param subMesh defines the subMesh to render
  28679. * @param enableAlphaMode defines if alpha mode can be changed
  28680. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28681. * @returns the current mesh
  28682. */
  28683. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28684. private _onBeforeDraw;
  28685. /**
  28686. * Renormalize the mesh and patch it up if there are no weights
  28687. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28688. * However in the case of zero weights then we set just a single influence to 1.
  28689. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28690. */
  28691. cleanMatrixWeights(): void;
  28692. private normalizeSkinFourWeights;
  28693. private normalizeSkinWeightsAndExtra;
  28694. /**
  28695. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28696. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28697. * the user know there was an issue with importing the mesh
  28698. * @returns a validation object with skinned, valid and report string
  28699. */
  28700. validateSkinning(): {
  28701. skinned: boolean;
  28702. valid: boolean;
  28703. report: string;
  28704. };
  28705. /** @hidden */
  28706. _checkDelayState(): Mesh;
  28707. private _queueLoad;
  28708. /**
  28709. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28710. * A mesh is in the frustum if its bounding box intersects the frustum
  28711. * @param frustumPlanes defines the frustum to test
  28712. * @returns true if the mesh is in the frustum planes
  28713. */
  28714. isInFrustum(frustumPlanes: Plane[]): boolean;
  28715. /**
  28716. * Sets the mesh material by the material or multiMaterial `id` property
  28717. * @param id is a string identifying the material or the multiMaterial
  28718. * @returns the current mesh
  28719. */
  28720. setMaterialByID(id: string): Mesh;
  28721. /**
  28722. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28723. * @returns an array of IAnimatable
  28724. */
  28725. getAnimatables(): IAnimatable[];
  28726. /**
  28727. * Modifies the mesh geometry according to the passed transformation matrix.
  28728. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28729. * The mesh normals are modified using the same transformation.
  28730. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28731. * @param transform defines the transform matrix to use
  28732. * @see https://doc.babylonjs.com/resources/baking_transformations
  28733. * @returns the current mesh
  28734. */
  28735. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28736. /**
  28737. * Modifies the mesh geometry according to its own current World Matrix.
  28738. * The mesh World Matrix is then reset.
  28739. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28740. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28741. * @see https://doc.babylonjs.com/resources/baking_transformations
  28742. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28743. * @returns the current mesh
  28744. */
  28745. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28746. /** @hidden */
  28747. get _positions(): Nullable<Vector3[]>;
  28748. /** @hidden */
  28749. _resetPointsArrayCache(): Mesh;
  28750. /** @hidden */
  28751. _generatePointsArray(): boolean;
  28752. /**
  28753. * Returns a new Mesh object generated from the current mesh properties.
  28754. * This method must not get confused with createInstance()
  28755. * @param name is a string, the name given to the new mesh
  28756. * @param newParent can be any Node object (default `null`)
  28757. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28758. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28759. * @returns a new mesh
  28760. */
  28761. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28762. /**
  28763. * Releases resources associated with this mesh.
  28764. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28765. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28766. */
  28767. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28768. /** @hidden */
  28769. _disposeInstanceSpecificData(): void;
  28770. /** @hidden */
  28771. _disposeThinInstanceSpecificData(): void;
  28772. /**
  28773. * Modifies the mesh geometry according to a displacement map.
  28774. * 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.
  28775. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28776. * @param url is a string, the URL from the image file is to be downloaded.
  28777. * @param minHeight is the lower limit of the displacement.
  28778. * @param maxHeight is the upper limit of the displacement.
  28779. * @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.
  28780. * @param uvOffset is an optional vector2 used to offset UV.
  28781. * @param uvScale is an optional vector2 used to scale UV.
  28782. * @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.
  28783. * @returns the Mesh.
  28784. */
  28785. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28786. /**
  28787. * Modifies the mesh geometry according to a displacementMap buffer.
  28788. * 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.
  28789. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28790. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28791. * @param heightMapWidth is the width of the buffer image.
  28792. * @param heightMapHeight is the height of the buffer image.
  28793. * @param minHeight is the lower limit of the displacement.
  28794. * @param maxHeight is the upper limit of the displacement.
  28795. * @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.
  28796. * @param uvOffset is an optional vector2 used to offset UV.
  28797. * @param uvScale is an optional vector2 used to scale UV.
  28798. * @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.
  28799. * @returns the Mesh.
  28800. */
  28801. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28802. /**
  28803. * Modify the mesh to get a flat shading rendering.
  28804. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28805. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28806. * @returns current mesh
  28807. */
  28808. convertToFlatShadedMesh(): Mesh;
  28809. /**
  28810. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28811. * In other words, more vertices, no more indices and a single bigger VBO.
  28812. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28813. * @returns current mesh
  28814. */
  28815. convertToUnIndexedMesh(): Mesh;
  28816. /**
  28817. * Inverses facet orientations.
  28818. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28819. * @param flipNormals will also inverts the normals
  28820. * @returns current mesh
  28821. */
  28822. flipFaces(flipNormals?: boolean): Mesh;
  28823. /**
  28824. * Increase the number of facets and hence vertices in a mesh
  28825. * Vertex normals are interpolated from existing vertex normals
  28826. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28827. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28828. */
  28829. increaseVertices(numberPerEdge: number): void;
  28830. /**
  28831. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28832. * This will undo any application of covertToFlatShadedMesh
  28833. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28834. */
  28835. forceSharedVertices(): void;
  28836. /** @hidden */
  28837. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28838. /** @hidden */
  28839. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28840. /**
  28841. * Creates a new InstancedMesh object from the mesh model.
  28842. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28843. * @param name defines the name of the new instance
  28844. * @returns a new InstancedMesh
  28845. */
  28846. createInstance(name: string): InstancedMesh;
  28847. /**
  28848. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28849. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28850. * @returns the current mesh
  28851. */
  28852. synchronizeInstances(): Mesh;
  28853. /**
  28854. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28855. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28856. * This should be used together with the simplification to avoid disappearing triangles.
  28857. * @param successCallback an optional success callback to be called after the optimization finished.
  28858. * @returns the current mesh
  28859. */
  28860. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28861. /**
  28862. * Serialize current mesh
  28863. * @param serializationObject defines the object which will receive the serialization data
  28864. */
  28865. serialize(serializationObject: any): void;
  28866. /** @hidden */
  28867. _syncGeometryWithMorphTargetManager(): void;
  28868. /** @hidden */
  28869. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28870. /**
  28871. * Returns a new Mesh object parsed from the source provided.
  28872. * @param parsedMesh is the source
  28873. * @param scene defines the hosting scene
  28874. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28875. * @returns a new Mesh
  28876. */
  28877. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28878. /**
  28879. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28880. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28881. * @param name defines the name of the mesh to create
  28882. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28883. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28884. * @param closePath creates a seam between the first and the last points of each path of the path array
  28885. * @param offset is taken in account only if the `pathArray` is containing a single path
  28886. * @param scene defines the hosting scene
  28887. * @param updatable defines if the mesh must be flagged as updatable
  28888. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28889. * @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)
  28890. * @returns a new Mesh
  28891. */
  28892. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28893. /**
  28894. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28895. * @param name defines the name of the mesh to create
  28896. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28897. * @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
  28898. * @param scene defines the hosting scene
  28899. * @param updatable defines if the mesh must be flagged as updatable
  28900. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28901. * @returns a new Mesh
  28902. */
  28903. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28904. /**
  28905. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28906. * @param name defines the name of the mesh to create
  28907. * @param size sets the size (float) of each box side (default 1)
  28908. * @param scene defines the hosting scene
  28909. * @param updatable defines if the mesh must be flagged as updatable
  28910. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28911. * @returns a new Mesh
  28912. */
  28913. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28914. /**
  28915. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28916. * @param name defines the name of the mesh to create
  28917. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28918. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28919. * @param scene defines the hosting scene
  28920. * @param updatable defines if the mesh must be flagged as updatable
  28921. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28922. * @returns a new Mesh
  28923. */
  28924. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28925. /**
  28926. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28927. * @param name defines the name of the mesh to create
  28928. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28929. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28930. * @param scene defines the hosting scene
  28931. * @returns a new Mesh
  28932. */
  28933. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28934. /**
  28935. * Creates a cylinder or a cone 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 height sets the height size (float) of the cylinder/cone (float, default 2)
  28938. * @param diameterTop set the top cap diameter (floats, default 1)
  28939. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28940. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28941. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28942. * @param scene defines the hosting scene
  28943. * @param updatable defines if the mesh must be flagged as updatable
  28944. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28945. * @returns a new Mesh
  28946. */
  28947. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28948. /**
  28949. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28950. * @param name defines the name of the mesh to create
  28951. * @param diameter sets the diameter size (float) of the torus (default 1)
  28952. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28953. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28954. * @param scene defines the hosting scene
  28955. * @param updatable defines if the mesh must be flagged as updatable
  28956. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28957. * @returns a new Mesh
  28958. */
  28959. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28960. /**
  28961. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28962. * @param name defines the name of the mesh to create
  28963. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28964. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28965. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28966. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28967. * @param p the number of windings on X axis (positive integers, default 2)
  28968. * @param q the number of windings on Y axis (positive integers, default 3)
  28969. * @param scene defines the hosting scene
  28970. * @param updatable defines if the mesh must be flagged as updatable
  28971. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28972. * @returns a new Mesh
  28973. */
  28974. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28975. /**
  28976. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28977. * @param name defines the name of the mesh to create
  28978. * @param points is an array successive Vector3
  28979. * @param scene defines the hosting scene
  28980. * @param updatable defines if the mesh must be flagged as updatable
  28981. * @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).
  28982. * @returns a new Mesh
  28983. */
  28984. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28985. /**
  28986. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28987. * @param name defines the name of the mesh to create
  28988. * @param points is an array successive Vector3
  28989. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28990. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28991. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  28992. * @param scene defines the hosting scene
  28993. * @param updatable defines if the mesh must be flagged as updatable
  28994. * @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)
  28995. * @returns a new Mesh
  28996. */
  28997. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  28998. /**
  28999. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29000. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29001. * 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.
  29002. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29003. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29004. * Remember you can only change the shape positions, not their number when updating a polygon.
  29005. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29006. * @param name defines the name of the mesh to create
  29007. * @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
  29008. * @param scene defines the hosting scene
  29009. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29010. * @param updatable defines if the mesh must be flagged as updatable
  29011. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29012. * @param earcutInjection can be used to inject your own earcut reference
  29013. * @returns a new Mesh
  29014. */
  29015. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29016. /**
  29017. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29018. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29019. * @param name defines the name of the mesh to create
  29020. * @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
  29021. * @param depth defines the height of extrusion
  29022. * @param scene defines the hosting scene
  29023. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29024. * @param updatable defines if the mesh must be flagged as updatable
  29025. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29026. * @param earcutInjection can be used to inject your own earcut reference
  29027. * @returns a new Mesh
  29028. */
  29029. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29030. /**
  29031. * Creates an extruded shape mesh.
  29032. * 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
  29033. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29034. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29035. * @param name defines the name of the mesh to create
  29036. * @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
  29037. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29038. * @param scale is the value to scale the shape
  29039. * @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
  29040. * @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
  29041. * @param scene defines the hosting scene
  29042. * @param updatable defines if the mesh must be flagged as updatable
  29043. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29044. * @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)
  29045. * @returns a new Mesh
  29046. */
  29047. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29048. /**
  29049. * Creates an custom extruded shape mesh.
  29050. * The custom extrusion is a parametric shape.
  29051. * It has no predefined shape. Its final shape will depend on the input parameters.
  29052. * Please consider using the same method from the MeshBuilder class instead
  29053. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29054. * @param name defines the name of the mesh to create
  29055. * @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
  29056. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29057. * @param scaleFunction is a custom Javascript function called on each path point
  29058. * @param rotationFunction is a custom Javascript function called on each path point
  29059. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29060. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29061. * @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
  29062. * @param scene defines the hosting scene
  29063. * @param updatable defines if the mesh must be flagged as updatable
  29064. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29065. * @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)
  29066. * @returns a new Mesh
  29067. */
  29068. 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;
  29069. /**
  29070. * Creates lathe mesh.
  29071. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29072. * Please consider using the same method from the MeshBuilder class instead
  29073. * @param name defines the name of the mesh to create
  29074. * @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
  29075. * @param radius is the radius value of the lathe
  29076. * @param tessellation is the side number of the lathe.
  29077. * @param scene defines the hosting scene
  29078. * @param updatable defines if the mesh must be flagged as updatable
  29079. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29080. * @returns a new Mesh
  29081. */
  29082. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29083. /**
  29084. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29085. * @param name defines the name of the mesh to create
  29086. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29087. * @param scene defines the hosting scene
  29088. * @param updatable defines if the mesh must be flagged as updatable
  29089. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29090. * @returns a new Mesh
  29091. */
  29092. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29093. /**
  29094. * Creates a ground mesh.
  29095. * Please consider using the same method from the MeshBuilder class instead
  29096. * @param name defines the name of the mesh to create
  29097. * @param width set the width of the ground
  29098. * @param height set the height of the ground
  29099. * @param subdivisions sets the number of subdivisions per side
  29100. * @param scene defines the hosting scene
  29101. * @param updatable defines if the mesh must be flagged as updatable
  29102. * @returns a new Mesh
  29103. */
  29104. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29105. /**
  29106. * Creates a tiled ground mesh.
  29107. * Please consider using the same method from the MeshBuilder class instead
  29108. * @param name defines the name of the mesh to create
  29109. * @param xmin set the ground minimum X coordinate
  29110. * @param zmin set the ground minimum Y coordinate
  29111. * @param xmax set the ground maximum X coordinate
  29112. * @param zmax set the ground maximum Z coordinate
  29113. * @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
  29114. * @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
  29115. * @param scene defines the hosting scene
  29116. * @param updatable defines if the mesh must be flagged as updatable
  29117. * @returns a new Mesh
  29118. */
  29119. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29120. w: number;
  29121. h: number;
  29122. }, precision: {
  29123. w: number;
  29124. h: number;
  29125. }, scene: Scene, updatable?: boolean): Mesh;
  29126. /**
  29127. * Creates a ground mesh from a height map.
  29128. * Please consider using the same method from the MeshBuilder class instead
  29129. * @see https://doc.babylonjs.com/babylon101/height_map
  29130. * @param name defines the name of the mesh to create
  29131. * @param url sets the URL of the height map image resource
  29132. * @param width set the ground width size
  29133. * @param height set the ground height size
  29134. * @param subdivisions sets the number of subdivision per side
  29135. * @param minHeight is the minimum altitude on the ground
  29136. * @param maxHeight is the maximum altitude on the ground
  29137. * @param scene defines the hosting scene
  29138. * @param updatable defines if the mesh must be flagged as updatable
  29139. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29140. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29141. * @returns a new Mesh
  29142. */
  29143. 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;
  29144. /**
  29145. * Creates a tube mesh.
  29146. * The tube is a parametric shape.
  29147. * It has no predefined shape. Its final shape will depend on the input parameters.
  29148. * Please consider using the same method from the MeshBuilder class instead
  29149. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29150. * @param name defines the name of the mesh to create
  29151. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29152. * @param radius sets the tube radius size
  29153. * @param tessellation is the number of sides on the tubular surface
  29154. * @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
  29155. * @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
  29156. * @param scene defines the hosting scene
  29157. * @param updatable defines if the mesh must be flagged as updatable
  29158. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29159. * @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)
  29160. * @returns a new Mesh
  29161. */
  29162. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29163. (i: number, distance: number): number;
  29164. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29165. /**
  29166. * Creates a polyhedron mesh.
  29167. * Please consider using the same method from the MeshBuilder class instead.
  29168. * * 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
  29169. * * The parameter `size` (positive float, default 1) sets the polygon size
  29170. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29171. * * 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`
  29172. * * 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
  29173. * * 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)`)
  29174. * * 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
  29175. * * 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
  29176. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29177. * * 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
  29178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29179. * @param name defines the name of the mesh to create
  29180. * @param options defines the options used to create the mesh
  29181. * @param scene defines the hosting scene
  29182. * @returns a new Mesh
  29183. */
  29184. static CreatePolyhedron(name: string, options: {
  29185. type?: number;
  29186. size?: number;
  29187. sizeX?: number;
  29188. sizeY?: number;
  29189. sizeZ?: number;
  29190. custom?: any;
  29191. faceUV?: Vector4[];
  29192. faceColors?: Color4[];
  29193. updatable?: boolean;
  29194. sideOrientation?: number;
  29195. }, scene: Scene): Mesh;
  29196. /**
  29197. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29198. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29199. * * 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`)
  29200. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29201. * * 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
  29202. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29203. * * 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
  29204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29205. * @param name defines the name of the mesh
  29206. * @param options defines the options used to create the mesh
  29207. * @param scene defines the hosting scene
  29208. * @returns a new Mesh
  29209. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29210. */
  29211. static CreateIcoSphere(name: string, options: {
  29212. radius?: number;
  29213. flat?: boolean;
  29214. subdivisions?: number;
  29215. sideOrientation?: number;
  29216. updatable?: boolean;
  29217. }, scene: Scene): Mesh;
  29218. /**
  29219. * Creates a decal mesh.
  29220. * Please consider using the same method from the MeshBuilder class instead.
  29221. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29222. * @param name defines the name of the mesh
  29223. * @param sourceMesh defines the mesh receiving the decal
  29224. * @param position sets the position of the decal in world coordinates
  29225. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29226. * @param size sets the decal scaling
  29227. * @param angle sets the angle to rotate the decal
  29228. * @returns a new Mesh
  29229. */
  29230. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29231. /**
  29232. * Prepare internal position array for software CPU skinning
  29233. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29234. */
  29235. setPositionsForCPUSkinning(): Float32Array;
  29236. /**
  29237. * Prepare internal normal array for software CPU skinning
  29238. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29239. */
  29240. setNormalsForCPUSkinning(): Float32Array;
  29241. /**
  29242. * Updates the vertex buffer by applying transformation from the bones
  29243. * @param skeleton defines the skeleton to apply to current mesh
  29244. * @returns the current mesh
  29245. */
  29246. applySkeleton(skeleton: Skeleton): Mesh;
  29247. /**
  29248. * 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
  29249. * @param meshes defines the list of meshes to scan
  29250. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29251. */
  29252. static MinMax(meshes: AbstractMesh[]): {
  29253. min: Vector3;
  29254. max: Vector3;
  29255. };
  29256. /**
  29257. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29258. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29259. * @returns a vector3
  29260. */
  29261. static Center(meshesOrMinMaxVector: {
  29262. min: Vector3;
  29263. max: Vector3;
  29264. } | AbstractMesh[]): Vector3;
  29265. /**
  29266. * Merge the array of meshes into a single mesh for performance reasons.
  29267. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29268. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29269. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29270. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29271. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29272. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29273. * @returns a new mesh
  29274. */
  29275. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29276. /** @hidden */
  29277. addInstance(instance: InstancedMesh): void;
  29278. /** @hidden */
  29279. removeInstance(instance: InstancedMesh): void;
  29280. }
  29281. }
  29282. declare module BABYLON {
  29283. /**
  29284. * This is the base class of all the camera used in the application.
  29285. * @see https://doc.babylonjs.com/features/cameras
  29286. */
  29287. export class Camera extends Node {
  29288. /** @hidden */
  29289. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29290. /**
  29291. * This is the default projection mode used by the cameras.
  29292. * It helps recreating a feeling of perspective and better appreciate depth.
  29293. * This is the best way to simulate real life cameras.
  29294. */
  29295. static readonly PERSPECTIVE_CAMERA: number;
  29296. /**
  29297. * This helps creating camera with an orthographic mode.
  29298. * 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.
  29299. */
  29300. static readonly ORTHOGRAPHIC_CAMERA: number;
  29301. /**
  29302. * This is the default FOV mode for perspective cameras.
  29303. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29304. */
  29305. static readonly FOVMODE_VERTICAL_FIXED: number;
  29306. /**
  29307. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29308. */
  29309. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29310. /**
  29311. * This specifies ther is no need for a camera rig.
  29312. * Basically only one eye is rendered corresponding to the camera.
  29313. */
  29314. static readonly RIG_MODE_NONE: number;
  29315. /**
  29316. * Simulates a camera Rig with one blue eye and one red eye.
  29317. * This can be use with 3d blue and red glasses.
  29318. */
  29319. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29320. /**
  29321. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29322. */
  29323. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29324. /**
  29325. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29326. */
  29327. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29328. /**
  29329. * Defines that both eyes of the camera will be rendered over under each other.
  29330. */
  29331. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29332. /**
  29333. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29334. */
  29335. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29336. /**
  29337. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29338. */
  29339. static readonly RIG_MODE_VR: number;
  29340. /**
  29341. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29342. */
  29343. static readonly RIG_MODE_WEBVR: number;
  29344. /**
  29345. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29346. */
  29347. static readonly RIG_MODE_CUSTOM: number;
  29348. /**
  29349. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29350. */
  29351. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29352. /**
  29353. * Define the input manager associated with the camera.
  29354. */
  29355. inputs: CameraInputsManager<Camera>;
  29356. /** @hidden */
  29357. _position: Vector3;
  29358. /**
  29359. * Define the current local position of the camera in the scene
  29360. */
  29361. get position(): Vector3;
  29362. set position(newPosition: Vector3);
  29363. /**
  29364. * The vector the camera should consider as up.
  29365. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29366. */
  29367. upVector: Vector3;
  29368. /**
  29369. * Define the current limit on the left side for an orthographic camera
  29370. * In scene unit
  29371. */
  29372. orthoLeft: Nullable<number>;
  29373. /**
  29374. * Define the current limit on the right side for an orthographic camera
  29375. * In scene unit
  29376. */
  29377. orthoRight: Nullable<number>;
  29378. /**
  29379. * Define the current limit on the bottom side for an orthographic camera
  29380. * In scene unit
  29381. */
  29382. orthoBottom: Nullable<number>;
  29383. /**
  29384. * Define the current limit on the top side for an orthographic camera
  29385. * In scene unit
  29386. */
  29387. orthoTop: Nullable<number>;
  29388. /**
  29389. * Field Of View is set in Radians. (default is 0.8)
  29390. */
  29391. fov: number;
  29392. /**
  29393. * Define the minimum distance the camera can see from.
  29394. * This is important to note that the depth buffer are not infinite and the closer it starts
  29395. * the more your scene might encounter depth fighting issue.
  29396. */
  29397. minZ: number;
  29398. /**
  29399. * Define the maximum distance the camera can see to.
  29400. * This is important to note that the depth buffer are not infinite and the further it end
  29401. * the more your scene might encounter depth fighting issue.
  29402. */
  29403. maxZ: number;
  29404. /**
  29405. * Define the default inertia of the camera.
  29406. * This helps giving a smooth feeling to the camera movement.
  29407. */
  29408. inertia: number;
  29409. /**
  29410. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29411. */
  29412. mode: number;
  29413. /**
  29414. * Define whether the camera is intermediate.
  29415. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29416. */
  29417. isIntermediate: boolean;
  29418. /**
  29419. * Define the viewport of the camera.
  29420. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29421. */
  29422. viewport: Viewport;
  29423. /**
  29424. * Restricts the camera to viewing objects with the same layerMask.
  29425. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29426. */
  29427. layerMask: number;
  29428. /**
  29429. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29430. */
  29431. fovMode: number;
  29432. /**
  29433. * Rig mode of the camera.
  29434. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29435. * This is normally controlled byt the camera themselves as internal use.
  29436. */
  29437. cameraRigMode: number;
  29438. /**
  29439. * Defines the distance between both "eyes" in case of a RIG
  29440. */
  29441. interaxialDistance: number;
  29442. /**
  29443. * Defines if stereoscopic rendering is done side by side or over under.
  29444. */
  29445. isStereoscopicSideBySide: boolean;
  29446. /**
  29447. * 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
  29448. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29449. * else in the scene. (Eg. security camera)
  29450. *
  29451. * 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)
  29452. */
  29453. customRenderTargets: RenderTargetTexture[];
  29454. /**
  29455. * When set, the camera will render to this render target instead of the default canvas
  29456. *
  29457. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29458. */
  29459. outputRenderTarget: Nullable<RenderTargetTexture>;
  29460. /**
  29461. * Observable triggered when the camera view matrix has changed.
  29462. */
  29463. onViewMatrixChangedObservable: Observable<Camera>;
  29464. /**
  29465. * Observable triggered when the camera Projection matrix has changed.
  29466. */
  29467. onProjectionMatrixChangedObservable: Observable<Camera>;
  29468. /**
  29469. * Observable triggered when the inputs have been processed.
  29470. */
  29471. onAfterCheckInputsObservable: Observable<Camera>;
  29472. /**
  29473. * Observable triggered when reset has been called and applied to the camera.
  29474. */
  29475. onRestoreStateObservable: Observable<Camera>;
  29476. /**
  29477. * Is this camera a part of a rig system?
  29478. */
  29479. isRigCamera: boolean;
  29480. /**
  29481. * If isRigCamera set to true this will be set with the parent camera.
  29482. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29483. */
  29484. rigParent?: Camera;
  29485. /** @hidden */
  29486. _cameraRigParams: any;
  29487. /** @hidden */
  29488. _rigCameras: Camera[];
  29489. /** @hidden */
  29490. _rigPostProcess: Nullable<PostProcess>;
  29491. protected _webvrViewMatrix: Matrix;
  29492. /** @hidden */
  29493. _skipRendering: boolean;
  29494. /** @hidden */
  29495. _projectionMatrix: Matrix;
  29496. /** @hidden */
  29497. _postProcesses: Nullable<PostProcess>[];
  29498. /** @hidden */
  29499. _activeMeshes: SmartArray<AbstractMesh>;
  29500. protected _globalPosition: Vector3;
  29501. /** @hidden */
  29502. _computedViewMatrix: Matrix;
  29503. private _doNotComputeProjectionMatrix;
  29504. private _transformMatrix;
  29505. private _frustumPlanes;
  29506. private _refreshFrustumPlanes;
  29507. private _storedFov;
  29508. private _stateStored;
  29509. /**
  29510. * Instantiates a new camera object.
  29511. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29512. * @see https://doc.babylonjs.com/features/cameras
  29513. * @param name Defines the name of the camera in the scene
  29514. * @param position Defines the position of the camera
  29515. * @param scene Defines the scene the camera belongs too
  29516. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29517. */
  29518. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29519. /**
  29520. * Store current camera state (fov, position, etc..)
  29521. * @returns the camera
  29522. */
  29523. storeState(): Camera;
  29524. /**
  29525. * Restores the camera state values if it has been stored. You must call storeState() first
  29526. */
  29527. protected _restoreStateValues(): boolean;
  29528. /**
  29529. * Restored camera state. You must call storeState() first.
  29530. * @returns true if restored and false otherwise
  29531. */
  29532. restoreState(): boolean;
  29533. /**
  29534. * Gets the class name of the camera.
  29535. * @returns the class name
  29536. */
  29537. getClassName(): string;
  29538. /** @hidden */
  29539. readonly _isCamera: boolean;
  29540. /**
  29541. * Gets a string representation of the camera useful for debug purpose.
  29542. * @param fullDetails Defines that a more verboe level of logging is required
  29543. * @returns the string representation
  29544. */
  29545. toString(fullDetails?: boolean): string;
  29546. /**
  29547. * Gets the current world space position of the camera.
  29548. */
  29549. get globalPosition(): Vector3;
  29550. /**
  29551. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29552. * @returns the active meshe list
  29553. */
  29554. getActiveMeshes(): SmartArray<AbstractMesh>;
  29555. /**
  29556. * Check whether a mesh is part of the current active mesh list of the camera
  29557. * @param mesh Defines the mesh to check
  29558. * @returns true if active, false otherwise
  29559. */
  29560. isActiveMesh(mesh: Mesh): boolean;
  29561. /**
  29562. * Is this camera ready to be used/rendered
  29563. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29564. * @return true if the camera is ready
  29565. */
  29566. isReady(completeCheck?: boolean): boolean;
  29567. /** @hidden */
  29568. _initCache(): void;
  29569. /** @hidden */
  29570. _updateCache(ignoreParentClass?: boolean): void;
  29571. /** @hidden */
  29572. _isSynchronized(): boolean;
  29573. /** @hidden */
  29574. _isSynchronizedViewMatrix(): boolean;
  29575. /** @hidden */
  29576. _isSynchronizedProjectionMatrix(): boolean;
  29577. /**
  29578. * Attach the input controls to a specific dom element to get the input from.
  29579. * @param element Defines the element the controls should be listened from
  29580. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29581. */
  29582. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29583. /**
  29584. * Detach the current controls from the specified dom element.
  29585. * @param element Defines the element to stop listening the inputs from
  29586. */
  29587. detachControl(element: HTMLElement): void;
  29588. /**
  29589. * Update the camera state according to the different inputs gathered during the frame.
  29590. */
  29591. update(): void;
  29592. /** @hidden */
  29593. _checkInputs(): void;
  29594. /** @hidden */
  29595. get rigCameras(): Camera[];
  29596. /**
  29597. * Gets the post process used by the rig cameras
  29598. */
  29599. get rigPostProcess(): Nullable<PostProcess>;
  29600. /**
  29601. * Internal, gets the first post proces.
  29602. * @returns the first post process to be run on this camera.
  29603. */
  29604. _getFirstPostProcess(): Nullable<PostProcess>;
  29605. private _cascadePostProcessesToRigCams;
  29606. /**
  29607. * Attach a post process to the camera.
  29608. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29609. * @param postProcess The post process to attach to the camera
  29610. * @param insertAt The position of the post process in case several of them are in use in the scene
  29611. * @returns the position the post process has been inserted at
  29612. */
  29613. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29614. /**
  29615. * Detach a post process to the camera.
  29616. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29617. * @param postProcess The post process to detach from the camera
  29618. */
  29619. detachPostProcess(postProcess: PostProcess): void;
  29620. /**
  29621. * Gets the current world matrix of the camera
  29622. */
  29623. getWorldMatrix(): Matrix;
  29624. /** @hidden */
  29625. _getViewMatrix(): Matrix;
  29626. /**
  29627. * Gets the current view matrix of the camera.
  29628. * @param force forces the camera to recompute the matrix without looking at the cached state
  29629. * @returns the view matrix
  29630. */
  29631. getViewMatrix(force?: boolean): Matrix;
  29632. /**
  29633. * Freeze the projection matrix.
  29634. * It will prevent the cache check of the camera projection compute and can speed up perf
  29635. * if no parameter of the camera are meant to change
  29636. * @param projection Defines manually a projection if necessary
  29637. */
  29638. freezeProjectionMatrix(projection?: Matrix): void;
  29639. /**
  29640. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29641. */
  29642. unfreezeProjectionMatrix(): void;
  29643. /**
  29644. * Gets the current projection matrix of the camera.
  29645. * @param force forces the camera to recompute the matrix without looking at the cached state
  29646. * @returns the projection matrix
  29647. */
  29648. getProjectionMatrix(force?: boolean): Matrix;
  29649. /**
  29650. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29651. * @returns a Matrix
  29652. */
  29653. getTransformationMatrix(): Matrix;
  29654. private _updateFrustumPlanes;
  29655. /**
  29656. * Checks if a cullable object (mesh...) is in the camera frustum
  29657. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29658. * @param target The object to check
  29659. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29660. * @returns true if the object is in frustum otherwise false
  29661. */
  29662. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29663. /**
  29664. * Checks if a cullable object (mesh...) is in the camera frustum
  29665. * Unlike isInFrustum this cheks the full bounding box
  29666. * @param target The object to check
  29667. * @returns true if the object is in frustum otherwise false
  29668. */
  29669. isCompletelyInFrustum(target: ICullable): boolean;
  29670. /**
  29671. * Gets a ray in the forward direction from the camera.
  29672. * @param length Defines the length of the ray to create
  29673. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29674. * @param origin Defines the start point of the ray which defaults to the camera position
  29675. * @returns the forward ray
  29676. */
  29677. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29678. /**
  29679. * Gets a ray in the forward direction from the camera.
  29680. * @param refRay the ray to (re)use when setting the values
  29681. * @param length Defines the length of the ray to create
  29682. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29683. * @param origin Defines the start point of the ray which defaults to the camera position
  29684. * @returns the forward ray
  29685. */
  29686. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29687. /**
  29688. * Releases resources associated with this node.
  29689. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29690. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29691. */
  29692. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29693. /** @hidden */
  29694. _isLeftCamera: boolean;
  29695. /**
  29696. * Gets the left camera of a rig setup in case of Rigged Camera
  29697. */
  29698. get isLeftCamera(): boolean;
  29699. /** @hidden */
  29700. _isRightCamera: boolean;
  29701. /**
  29702. * Gets the right camera of a rig setup in case of Rigged Camera
  29703. */
  29704. get isRightCamera(): boolean;
  29705. /**
  29706. * Gets the left camera of a rig setup in case of Rigged Camera
  29707. */
  29708. get leftCamera(): Nullable<FreeCamera>;
  29709. /**
  29710. * Gets the right camera of a rig setup in case of Rigged Camera
  29711. */
  29712. get rightCamera(): Nullable<FreeCamera>;
  29713. /**
  29714. * Gets the left camera target of a rig setup in case of Rigged Camera
  29715. * @returns the target position
  29716. */
  29717. getLeftTarget(): Nullable<Vector3>;
  29718. /**
  29719. * Gets the right camera target of a rig setup in case of Rigged Camera
  29720. * @returns the target position
  29721. */
  29722. getRightTarget(): Nullable<Vector3>;
  29723. /**
  29724. * @hidden
  29725. */
  29726. setCameraRigMode(mode: number, rigParams: any): void;
  29727. /** @hidden */
  29728. static _setStereoscopicRigMode(camera: Camera): void;
  29729. /** @hidden */
  29730. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29731. /** @hidden */
  29732. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29733. /** @hidden */
  29734. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29735. /** @hidden */
  29736. _getVRProjectionMatrix(): Matrix;
  29737. protected _updateCameraRotationMatrix(): void;
  29738. protected _updateWebVRCameraRotationMatrix(): void;
  29739. /**
  29740. * This function MUST be overwritten by the different WebVR cameras available.
  29741. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29742. * @hidden
  29743. */
  29744. _getWebVRProjectionMatrix(): Matrix;
  29745. /**
  29746. * This function MUST be overwritten by the different WebVR cameras available.
  29747. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29748. * @hidden
  29749. */
  29750. _getWebVRViewMatrix(): Matrix;
  29751. /** @hidden */
  29752. setCameraRigParameter(name: string, value: any): void;
  29753. /**
  29754. * needs to be overridden by children so sub has required properties to be copied
  29755. * @hidden
  29756. */
  29757. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29758. /**
  29759. * May need to be overridden by children
  29760. * @hidden
  29761. */
  29762. _updateRigCameras(): void;
  29763. /** @hidden */
  29764. _setupInputs(): void;
  29765. /**
  29766. * Serialiaze the camera setup to a json represention
  29767. * @returns the JSON representation
  29768. */
  29769. serialize(): any;
  29770. /**
  29771. * Clones the current camera.
  29772. * @param name The cloned camera name
  29773. * @returns the cloned camera
  29774. */
  29775. clone(name: string): Camera;
  29776. /**
  29777. * Gets the direction of the camera relative to a given local axis.
  29778. * @param localAxis Defines the reference axis to provide a relative direction.
  29779. * @return the direction
  29780. */
  29781. getDirection(localAxis: Vector3): Vector3;
  29782. /**
  29783. * Returns the current camera absolute rotation
  29784. */
  29785. get absoluteRotation(): Quaternion;
  29786. /**
  29787. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29788. * @param localAxis Defines the reference axis to provide a relative direction.
  29789. * @param result Defines the vector to store the result in
  29790. */
  29791. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29792. /**
  29793. * Gets a camera constructor for a given camera type
  29794. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29795. * @param name The name of the camera the result will be able to instantiate
  29796. * @param scene The scene the result will construct the camera in
  29797. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29798. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29799. * @returns a factory method to construc the camera
  29800. */
  29801. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29802. /**
  29803. * Compute the world matrix of the camera.
  29804. * @returns the camera world matrix
  29805. */
  29806. computeWorldMatrix(): Matrix;
  29807. /**
  29808. * Parse a JSON and creates the camera from the parsed information
  29809. * @param parsedCamera The JSON to parse
  29810. * @param scene The scene to instantiate the camera in
  29811. * @returns the newly constructed camera
  29812. */
  29813. static Parse(parsedCamera: any, scene: Scene): Camera;
  29814. }
  29815. }
  29816. declare module BABYLON {
  29817. /**
  29818. * Class containing static functions to help procedurally build meshes
  29819. */
  29820. export class DiscBuilder {
  29821. /**
  29822. * Creates a plane polygonal mesh. By default, this is a disc
  29823. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29824. * * 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
  29825. * * 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
  29826. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29827. * * 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
  29828. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29829. * @param name defines the name of the mesh
  29830. * @param options defines the options used to create the mesh
  29831. * @param scene defines the hosting scene
  29832. * @returns the plane polygonal mesh
  29833. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29834. */
  29835. static CreateDisc(name: string, options: {
  29836. radius?: number;
  29837. tessellation?: number;
  29838. arc?: number;
  29839. updatable?: boolean;
  29840. sideOrientation?: number;
  29841. frontUVs?: Vector4;
  29842. backUVs?: Vector4;
  29843. }, scene?: Nullable<Scene>): Mesh;
  29844. }
  29845. }
  29846. declare module BABYLON {
  29847. /**
  29848. * Options to be used when creating a FresnelParameters.
  29849. */
  29850. export type IFresnelParametersCreationOptions = {
  29851. /**
  29852. * Define the color used on edges (grazing angle)
  29853. */
  29854. leftColor?: Color3;
  29855. /**
  29856. * Define the color used on center
  29857. */
  29858. rightColor?: Color3;
  29859. /**
  29860. * Define bias applied to computed fresnel term
  29861. */
  29862. bias?: number;
  29863. /**
  29864. * Defined the power exponent applied to fresnel term
  29865. */
  29866. power?: number;
  29867. /**
  29868. * Define if the fresnel effect is enable or not.
  29869. */
  29870. isEnabled?: boolean;
  29871. };
  29872. /**
  29873. * Serialized format for FresnelParameters.
  29874. */
  29875. export type IFresnelParametersSerialized = {
  29876. /**
  29877. * Define the color used on edges (grazing angle) [as an array]
  29878. */
  29879. leftColor: number[];
  29880. /**
  29881. * Define the color used on center [as an array]
  29882. */
  29883. rightColor: number[];
  29884. /**
  29885. * Define bias applied to computed fresnel term
  29886. */
  29887. bias: number;
  29888. /**
  29889. * Defined the power exponent applied to fresnel term
  29890. */
  29891. power?: number;
  29892. /**
  29893. * Define if the fresnel effect is enable or not.
  29894. */
  29895. isEnabled: boolean;
  29896. };
  29897. /**
  29898. * This represents all the required information to add a fresnel effect on a material:
  29899. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29900. */
  29901. export class FresnelParameters {
  29902. private _isEnabled;
  29903. /**
  29904. * Define if the fresnel effect is enable or not.
  29905. */
  29906. get isEnabled(): boolean;
  29907. set isEnabled(value: boolean);
  29908. /**
  29909. * Define the color used on edges (grazing angle)
  29910. */
  29911. leftColor: Color3;
  29912. /**
  29913. * Define the color used on center
  29914. */
  29915. rightColor: Color3;
  29916. /**
  29917. * Define bias applied to computed fresnel term
  29918. */
  29919. bias: number;
  29920. /**
  29921. * Defined the power exponent applied to fresnel term
  29922. */
  29923. power: number;
  29924. /**
  29925. * Creates a new FresnelParameters object.
  29926. *
  29927. * @param options provide your own settings to optionally to override defaults
  29928. */
  29929. constructor(options?: IFresnelParametersCreationOptions);
  29930. /**
  29931. * Clones the current fresnel and its valuues
  29932. * @returns a clone fresnel configuration
  29933. */
  29934. clone(): FresnelParameters;
  29935. /**
  29936. * Determines equality between FresnelParameters objects
  29937. * @param otherFresnelParameters defines the second operand
  29938. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29939. */
  29940. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29941. /**
  29942. * Serializes the current fresnel parameters to a JSON representation.
  29943. * @return the JSON serialization
  29944. */
  29945. serialize(): IFresnelParametersSerialized;
  29946. /**
  29947. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29948. * @param parsedFresnelParameters Define the JSON representation
  29949. * @returns the parsed parameters
  29950. */
  29951. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29952. }
  29953. }
  29954. declare module BABYLON {
  29955. /**
  29956. * This groups all the flags used to control the materials channel.
  29957. */
  29958. export class MaterialFlags {
  29959. private static _DiffuseTextureEnabled;
  29960. /**
  29961. * Are diffuse textures enabled in the application.
  29962. */
  29963. static get DiffuseTextureEnabled(): boolean;
  29964. static set DiffuseTextureEnabled(value: boolean);
  29965. private static _DetailTextureEnabled;
  29966. /**
  29967. * Are detail textures enabled in the application.
  29968. */
  29969. static get DetailTextureEnabled(): boolean;
  29970. static set DetailTextureEnabled(value: boolean);
  29971. private static _AmbientTextureEnabled;
  29972. /**
  29973. * Are ambient textures enabled in the application.
  29974. */
  29975. static get AmbientTextureEnabled(): boolean;
  29976. static set AmbientTextureEnabled(value: boolean);
  29977. private static _OpacityTextureEnabled;
  29978. /**
  29979. * Are opacity textures enabled in the application.
  29980. */
  29981. static get OpacityTextureEnabled(): boolean;
  29982. static set OpacityTextureEnabled(value: boolean);
  29983. private static _ReflectionTextureEnabled;
  29984. /**
  29985. * Are reflection textures enabled in the application.
  29986. */
  29987. static get ReflectionTextureEnabled(): boolean;
  29988. static set ReflectionTextureEnabled(value: boolean);
  29989. private static _EmissiveTextureEnabled;
  29990. /**
  29991. * Are emissive textures enabled in the application.
  29992. */
  29993. static get EmissiveTextureEnabled(): boolean;
  29994. static set EmissiveTextureEnabled(value: boolean);
  29995. private static _SpecularTextureEnabled;
  29996. /**
  29997. * Are specular textures enabled in the application.
  29998. */
  29999. static get SpecularTextureEnabled(): boolean;
  30000. static set SpecularTextureEnabled(value: boolean);
  30001. private static _BumpTextureEnabled;
  30002. /**
  30003. * Are bump textures enabled in the application.
  30004. */
  30005. static get BumpTextureEnabled(): boolean;
  30006. static set BumpTextureEnabled(value: boolean);
  30007. private static _LightmapTextureEnabled;
  30008. /**
  30009. * Are lightmap textures enabled in the application.
  30010. */
  30011. static get LightmapTextureEnabled(): boolean;
  30012. static set LightmapTextureEnabled(value: boolean);
  30013. private static _RefractionTextureEnabled;
  30014. /**
  30015. * Are refraction textures enabled in the application.
  30016. */
  30017. static get RefractionTextureEnabled(): boolean;
  30018. static set RefractionTextureEnabled(value: boolean);
  30019. private static _ColorGradingTextureEnabled;
  30020. /**
  30021. * Are color grading textures enabled in the application.
  30022. */
  30023. static get ColorGradingTextureEnabled(): boolean;
  30024. static set ColorGradingTextureEnabled(value: boolean);
  30025. private static _FresnelEnabled;
  30026. /**
  30027. * Are fresnels enabled in the application.
  30028. */
  30029. static get FresnelEnabled(): boolean;
  30030. static set FresnelEnabled(value: boolean);
  30031. private static _ClearCoatTextureEnabled;
  30032. /**
  30033. * Are clear coat textures enabled in the application.
  30034. */
  30035. static get ClearCoatTextureEnabled(): boolean;
  30036. static set ClearCoatTextureEnabled(value: boolean);
  30037. private static _ClearCoatBumpTextureEnabled;
  30038. /**
  30039. * Are clear coat bump textures enabled in the application.
  30040. */
  30041. static get ClearCoatBumpTextureEnabled(): boolean;
  30042. static set ClearCoatBumpTextureEnabled(value: boolean);
  30043. private static _ClearCoatTintTextureEnabled;
  30044. /**
  30045. * Are clear coat tint textures enabled in the application.
  30046. */
  30047. static get ClearCoatTintTextureEnabled(): boolean;
  30048. static set ClearCoatTintTextureEnabled(value: boolean);
  30049. private static _SheenTextureEnabled;
  30050. /**
  30051. * Are sheen textures enabled in the application.
  30052. */
  30053. static get SheenTextureEnabled(): boolean;
  30054. static set SheenTextureEnabled(value: boolean);
  30055. private static _AnisotropicTextureEnabled;
  30056. /**
  30057. * Are anisotropic textures enabled in the application.
  30058. */
  30059. static get AnisotropicTextureEnabled(): boolean;
  30060. static set AnisotropicTextureEnabled(value: boolean);
  30061. private static _ThicknessTextureEnabled;
  30062. /**
  30063. * Are thickness textures enabled in the application.
  30064. */
  30065. static get ThicknessTextureEnabled(): boolean;
  30066. static set ThicknessTextureEnabled(value: boolean);
  30067. }
  30068. }
  30069. declare module BABYLON {
  30070. /** @hidden */
  30071. export var defaultFragmentDeclaration: {
  30072. name: string;
  30073. shader: string;
  30074. };
  30075. }
  30076. declare module BABYLON {
  30077. /** @hidden */
  30078. export var defaultUboDeclaration: {
  30079. name: string;
  30080. shader: string;
  30081. };
  30082. }
  30083. declare module BABYLON {
  30084. /** @hidden */
  30085. export var prePassDeclaration: {
  30086. name: string;
  30087. shader: string;
  30088. };
  30089. }
  30090. declare module BABYLON {
  30091. /** @hidden */
  30092. export var lightFragmentDeclaration: {
  30093. name: string;
  30094. shader: string;
  30095. };
  30096. }
  30097. declare module BABYLON {
  30098. /** @hidden */
  30099. export var lightUboDeclaration: {
  30100. name: string;
  30101. shader: string;
  30102. };
  30103. }
  30104. declare module BABYLON {
  30105. /** @hidden */
  30106. export var lightsFragmentFunctions: {
  30107. name: string;
  30108. shader: string;
  30109. };
  30110. }
  30111. declare module BABYLON {
  30112. /** @hidden */
  30113. export var shadowsFragmentFunctions: {
  30114. name: string;
  30115. shader: string;
  30116. };
  30117. }
  30118. declare module BABYLON {
  30119. /** @hidden */
  30120. export var fresnelFunction: {
  30121. name: string;
  30122. shader: string;
  30123. };
  30124. }
  30125. declare module BABYLON {
  30126. /** @hidden */
  30127. export var bumpFragmentMainFunctions: {
  30128. name: string;
  30129. shader: string;
  30130. };
  30131. }
  30132. declare module BABYLON {
  30133. /** @hidden */
  30134. export var bumpFragmentFunctions: {
  30135. name: string;
  30136. shader: string;
  30137. };
  30138. }
  30139. declare module BABYLON {
  30140. /** @hidden */
  30141. export var logDepthDeclaration: {
  30142. name: string;
  30143. shader: string;
  30144. };
  30145. }
  30146. declare module BABYLON {
  30147. /** @hidden */
  30148. export var bumpFragment: {
  30149. name: string;
  30150. shader: string;
  30151. };
  30152. }
  30153. declare module BABYLON {
  30154. /** @hidden */
  30155. export var depthPrePass: {
  30156. name: string;
  30157. shader: string;
  30158. };
  30159. }
  30160. declare module BABYLON {
  30161. /** @hidden */
  30162. export var lightFragment: {
  30163. name: string;
  30164. shader: string;
  30165. };
  30166. }
  30167. declare module BABYLON {
  30168. /** @hidden */
  30169. export var logDepthFragment: {
  30170. name: string;
  30171. shader: string;
  30172. };
  30173. }
  30174. declare module BABYLON {
  30175. /** @hidden */
  30176. export var defaultPixelShader: {
  30177. name: string;
  30178. shader: string;
  30179. };
  30180. }
  30181. declare module BABYLON {
  30182. /** @hidden */
  30183. export var defaultVertexDeclaration: {
  30184. name: string;
  30185. shader: string;
  30186. };
  30187. }
  30188. declare module BABYLON {
  30189. /** @hidden */
  30190. export var bumpVertexDeclaration: {
  30191. name: string;
  30192. shader: string;
  30193. };
  30194. }
  30195. declare module BABYLON {
  30196. /** @hidden */
  30197. export var bumpVertex: {
  30198. name: string;
  30199. shader: string;
  30200. };
  30201. }
  30202. declare module BABYLON {
  30203. /** @hidden */
  30204. export var fogVertex: {
  30205. name: string;
  30206. shader: string;
  30207. };
  30208. }
  30209. declare module BABYLON {
  30210. /** @hidden */
  30211. export var shadowsVertex: {
  30212. name: string;
  30213. shader: string;
  30214. };
  30215. }
  30216. declare module BABYLON {
  30217. /** @hidden */
  30218. export var pointCloudVertex: {
  30219. name: string;
  30220. shader: string;
  30221. };
  30222. }
  30223. declare module BABYLON {
  30224. /** @hidden */
  30225. export var logDepthVertex: {
  30226. name: string;
  30227. shader: string;
  30228. };
  30229. }
  30230. declare module BABYLON {
  30231. /** @hidden */
  30232. export var defaultVertexShader: {
  30233. name: string;
  30234. shader: string;
  30235. };
  30236. }
  30237. declare module BABYLON {
  30238. /**
  30239. * @hidden
  30240. */
  30241. export interface IMaterialDetailMapDefines {
  30242. DETAIL: boolean;
  30243. DETAILDIRECTUV: number;
  30244. DETAIL_NORMALBLENDMETHOD: number;
  30245. /** @hidden */
  30246. _areTexturesDirty: boolean;
  30247. }
  30248. /**
  30249. * Define the code related to the detail map parameters of a material
  30250. *
  30251. * Inspired from:
  30252. * 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
  30253. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30254. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30255. */
  30256. export class DetailMapConfiguration {
  30257. private _texture;
  30258. /**
  30259. * The detail texture of the material.
  30260. */
  30261. texture: Nullable<BaseTexture>;
  30262. /**
  30263. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30264. * Bigger values mean stronger blending
  30265. */
  30266. diffuseBlendLevel: number;
  30267. /**
  30268. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30269. * Bigger values mean stronger blending. Only used with PBR materials
  30270. */
  30271. roughnessBlendLevel: number;
  30272. /**
  30273. * Defines how strong the bump effect from the detail map is
  30274. * Bigger values mean stronger effect
  30275. */
  30276. bumpLevel: number;
  30277. private _normalBlendMethod;
  30278. /**
  30279. * The method used to blend the bump and detail normals together
  30280. */
  30281. normalBlendMethod: number;
  30282. private _isEnabled;
  30283. /**
  30284. * Enable or disable the detail map on this material
  30285. */
  30286. isEnabled: boolean;
  30287. /** @hidden */
  30288. private _internalMarkAllSubMeshesAsTexturesDirty;
  30289. /** @hidden */
  30290. _markAllSubMeshesAsTexturesDirty(): void;
  30291. /**
  30292. * Instantiate a new detail map
  30293. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30294. */
  30295. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30296. /**
  30297. * Gets whether the submesh is ready to be used or not.
  30298. * @param defines the list of "defines" to update.
  30299. * @param scene defines the scene the material belongs to.
  30300. * @returns - boolean indicating that the submesh is ready or not.
  30301. */
  30302. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30303. /**
  30304. * Update the defines for detail map usage
  30305. * @param defines the list of "defines" to update.
  30306. * @param scene defines the scene the material belongs to.
  30307. */
  30308. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30309. /**
  30310. * Binds the material data.
  30311. * @param uniformBuffer defines the Uniform buffer to fill in.
  30312. * @param scene defines the scene the material belongs to.
  30313. * @param isFrozen defines whether the material is frozen or not.
  30314. */
  30315. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30316. /**
  30317. * Checks to see if a texture is used in the material.
  30318. * @param texture - Base texture to use.
  30319. * @returns - Boolean specifying if a texture is used in the material.
  30320. */
  30321. hasTexture(texture: BaseTexture): boolean;
  30322. /**
  30323. * Returns an array of the actively used textures.
  30324. * @param activeTextures Array of BaseTextures
  30325. */
  30326. getActiveTextures(activeTextures: BaseTexture[]): void;
  30327. /**
  30328. * Returns the animatable textures.
  30329. * @param animatables Array of animatable textures.
  30330. */
  30331. getAnimatables(animatables: IAnimatable[]): void;
  30332. /**
  30333. * Disposes the resources of the material.
  30334. * @param forceDisposeTextures - Forces the disposal of all textures.
  30335. */
  30336. dispose(forceDisposeTextures?: boolean): void;
  30337. /**
  30338. * Get the current class name useful for serialization or dynamic coding.
  30339. * @returns "DetailMap"
  30340. */
  30341. getClassName(): string;
  30342. /**
  30343. * Add the required uniforms to the current list.
  30344. * @param uniforms defines the current uniform list.
  30345. */
  30346. static AddUniforms(uniforms: string[]): void;
  30347. /**
  30348. * Add the required samplers to the current list.
  30349. * @param samplers defines the current sampler list.
  30350. */
  30351. static AddSamplers(samplers: string[]): void;
  30352. /**
  30353. * Add the required uniforms to the current buffer.
  30354. * @param uniformBuffer defines the current uniform buffer.
  30355. */
  30356. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30357. /**
  30358. * Makes a duplicate of the current instance into another one.
  30359. * @param detailMap define the instance where to copy the info
  30360. */
  30361. copyTo(detailMap: DetailMapConfiguration): void;
  30362. /**
  30363. * Serializes this detail map instance
  30364. * @returns - An object with the serialized instance.
  30365. */
  30366. serialize(): any;
  30367. /**
  30368. * Parses a detail map setting from a serialized object.
  30369. * @param source - Serialized object.
  30370. * @param scene Defines the scene we are parsing for
  30371. * @param rootUrl Defines the rootUrl to load from
  30372. */
  30373. parse(source: any, scene: Scene, rootUrl: string): void;
  30374. }
  30375. }
  30376. declare module BABYLON {
  30377. /** @hidden */
  30378. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30379. MAINUV1: boolean;
  30380. MAINUV2: boolean;
  30381. DIFFUSE: boolean;
  30382. DIFFUSEDIRECTUV: number;
  30383. DETAIL: boolean;
  30384. DETAILDIRECTUV: number;
  30385. DETAIL_NORMALBLENDMETHOD: number;
  30386. AMBIENT: boolean;
  30387. AMBIENTDIRECTUV: number;
  30388. OPACITY: boolean;
  30389. OPACITYDIRECTUV: number;
  30390. OPACITYRGB: boolean;
  30391. REFLECTION: boolean;
  30392. EMISSIVE: boolean;
  30393. EMISSIVEDIRECTUV: number;
  30394. SPECULAR: boolean;
  30395. SPECULARDIRECTUV: number;
  30396. BUMP: boolean;
  30397. BUMPDIRECTUV: number;
  30398. PARALLAX: boolean;
  30399. PARALLAXOCCLUSION: boolean;
  30400. SPECULAROVERALPHA: boolean;
  30401. CLIPPLANE: boolean;
  30402. CLIPPLANE2: boolean;
  30403. CLIPPLANE3: boolean;
  30404. CLIPPLANE4: boolean;
  30405. CLIPPLANE5: boolean;
  30406. CLIPPLANE6: boolean;
  30407. ALPHATEST: boolean;
  30408. DEPTHPREPASS: boolean;
  30409. ALPHAFROMDIFFUSE: boolean;
  30410. POINTSIZE: boolean;
  30411. FOG: boolean;
  30412. SPECULARTERM: boolean;
  30413. DIFFUSEFRESNEL: boolean;
  30414. OPACITYFRESNEL: boolean;
  30415. REFLECTIONFRESNEL: boolean;
  30416. REFRACTIONFRESNEL: boolean;
  30417. EMISSIVEFRESNEL: boolean;
  30418. FRESNEL: boolean;
  30419. NORMAL: boolean;
  30420. UV1: boolean;
  30421. UV2: boolean;
  30422. VERTEXCOLOR: boolean;
  30423. VERTEXALPHA: boolean;
  30424. NUM_BONE_INFLUENCERS: number;
  30425. BonesPerMesh: number;
  30426. BONETEXTURE: boolean;
  30427. INSTANCES: boolean;
  30428. THIN_INSTANCES: boolean;
  30429. GLOSSINESS: boolean;
  30430. ROUGHNESS: boolean;
  30431. EMISSIVEASILLUMINATION: boolean;
  30432. LINKEMISSIVEWITHDIFFUSE: boolean;
  30433. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30434. LIGHTMAP: boolean;
  30435. LIGHTMAPDIRECTUV: number;
  30436. OBJECTSPACE_NORMALMAP: boolean;
  30437. USELIGHTMAPASSHADOWMAP: boolean;
  30438. REFLECTIONMAP_3D: boolean;
  30439. REFLECTIONMAP_SPHERICAL: boolean;
  30440. REFLECTIONMAP_PLANAR: boolean;
  30441. REFLECTIONMAP_CUBIC: boolean;
  30442. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30443. REFLECTIONMAP_PROJECTION: boolean;
  30444. REFLECTIONMAP_SKYBOX: boolean;
  30445. REFLECTIONMAP_EXPLICIT: boolean;
  30446. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30447. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30448. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30449. INVERTCUBICMAP: boolean;
  30450. LOGARITHMICDEPTH: boolean;
  30451. REFRACTION: boolean;
  30452. REFRACTIONMAP_3D: boolean;
  30453. REFLECTIONOVERALPHA: boolean;
  30454. TWOSIDEDLIGHTING: boolean;
  30455. SHADOWFLOAT: boolean;
  30456. MORPHTARGETS: boolean;
  30457. MORPHTARGETS_NORMAL: boolean;
  30458. MORPHTARGETS_TANGENT: boolean;
  30459. MORPHTARGETS_UV: boolean;
  30460. NUM_MORPH_INFLUENCERS: number;
  30461. NONUNIFORMSCALING: boolean;
  30462. PREMULTIPLYALPHA: boolean;
  30463. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30464. ALPHABLEND: boolean;
  30465. PREPASS: boolean;
  30466. SCENE_MRT_COUNT: number;
  30467. RGBDLIGHTMAP: boolean;
  30468. RGBDREFLECTION: boolean;
  30469. RGBDREFRACTION: boolean;
  30470. IMAGEPROCESSING: boolean;
  30471. VIGNETTE: boolean;
  30472. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30473. VIGNETTEBLENDMODEOPAQUE: boolean;
  30474. TONEMAPPING: boolean;
  30475. TONEMAPPING_ACES: boolean;
  30476. CONTRAST: boolean;
  30477. COLORCURVES: boolean;
  30478. COLORGRADING: boolean;
  30479. COLORGRADING3D: boolean;
  30480. SAMPLER3DGREENDEPTH: boolean;
  30481. SAMPLER3DBGRMAP: boolean;
  30482. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30483. MULTIVIEW: boolean;
  30484. /**
  30485. * If the reflection texture on this material is in linear color space
  30486. * @hidden
  30487. */
  30488. IS_REFLECTION_LINEAR: boolean;
  30489. /**
  30490. * If the refraction texture on this material is in linear color space
  30491. * @hidden
  30492. */
  30493. IS_REFRACTION_LINEAR: boolean;
  30494. EXPOSURE: boolean;
  30495. constructor();
  30496. setReflectionMode(modeToEnable: string): void;
  30497. }
  30498. /**
  30499. * This is the default material used in Babylon. It is the best trade off between quality
  30500. * and performances.
  30501. * @see https://doc.babylonjs.com/babylon101/materials
  30502. */
  30503. export class StandardMaterial extends PushMaterial {
  30504. private _diffuseTexture;
  30505. /**
  30506. * The basic texture of the material as viewed under a light.
  30507. */
  30508. diffuseTexture: Nullable<BaseTexture>;
  30509. private _ambientTexture;
  30510. /**
  30511. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30512. */
  30513. ambientTexture: Nullable<BaseTexture>;
  30514. private _opacityTexture;
  30515. /**
  30516. * Define the transparency of the material from a texture.
  30517. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30518. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30519. */
  30520. opacityTexture: Nullable<BaseTexture>;
  30521. private _reflectionTexture;
  30522. /**
  30523. * Define the texture used to display the reflection.
  30524. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30525. */
  30526. reflectionTexture: Nullable<BaseTexture>;
  30527. private _emissiveTexture;
  30528. /**
  30529. * Define texture of the material as if self lit.
  30530. * This will be mixed in the final result even in the absence of light.
  30531. */
  30532. emissiveTexture: Nullable<BaseTexture>;
  30533. private _specularTexture;
  30534. /**
  30535. * Define how the color and intensity of the highlight given by the light in the material.
  30536. */
  30537. specularTexture: Nullable<BaseTexture>;
  30538. private _bumpTexture;
  30539. /**
  30540. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30541. * 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.
  30542. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  30543. */
  30544. bumpTexture: Nullable<BaseTexture>;
  30545. private _lightmapTexture;
  30546. /**
  30547. * Complex lighting can be computationally expensive to compute at runtime.
  30548. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30549. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  30550. */
  30551. lightmapTexture: Nullable<BaseTexture>;
  30552. private _refractionTexture;
  30553. /**
  30554. * Define the texture used to display the refraction.
  30555. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30556. */
  30557. refractionTexture: Nullable<BaseTexture>;
  30558. /**
  30559. * The color of the material lit by the environmental background lighting.
  30560. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30561. */
  30562. ambientColor: Color3;
  30563. /**
  30564. * The basic color of the material as viewed under a light.
  30565. */
  30566. diffuseColor: Color3;
  30567. /**
  30568. * Define how the color and intensity of the highlight given by the light in the material.
  30569. */
  30570. specularColor: Color3;
  30571. /**
  30572. * Define the color of the material as if self lit.
  30573. * This will be mixed in the final result even in the absence of light.
  30574. */
  30575. emissiveColor: Color3;
  30576. /**
  30577. * Defines how sharp are the highlights in the material.
  30578. * The bigger the value the sharper giving a more glossy feeling to the result.
  30579. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30580. */
  30581. specularPower: number;
  30582. private _useAlphaFromDiffuseTexture;
  30583. /**
  30584. * Does the transparency come from the diffuse texture alpha channel.
  30585. */
  30586. useAlphaFromDiffuseTexture: boolean;
  30587. private _useEmissiveAsIllumination;
  30588. /**
  30589. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30590. */
  30591. useEmissiveAsIllumination: boolean;
  30592. private _linkEmissiveWithDiffuse;
  30593. /**
  30594. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30595. * the emissive level when the final color is close to one.
  30596. */
  30597. linkEmissiveWithDiffuse: boolean;
  30598. private _useSpecularOverAlpha;
  30599. /**
  30600. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30601. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30602. */
  30603. useSpecularOverAlpha: boolean;
  30604. private _useReflectionOverAlpha;
  30605. /**
  30606. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30607. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30608. */
  30609. useReflectionOverAlpha: boolean;
  30610. private _disableLighting;
  30611. /**
  30612. * Does lights from the scene impacts this material.
  30613. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30614. */
  30615. disableLighting: boolean;
  30616. private _useObjectSpaceNormalMap;
  30617. /**
  30618. * Allows using an object space normal map (instead of tangent space).
  30619. */
  30620. useObjectSpaceNormalMap: boolean;
  30621. private _useParallax;
  30622. /**
  30623. * Is parallax enabled or not.
  30624. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30625. */
  30626. useParallax: boolean;
  30627. private _useParallaxOcclusion;
  30628. /**
  30629. * Is parallax occlusion enabled or not.
  30630. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30631. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30632. */
  30633. useParallaxOcclusion: boolean;
  30634. /**
  30635. * 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.
  30636. */
  30637. parallaxScaleBias: number;
  30638. private _roughness;
  30639. /**
  30640. * Helps to define how blurry the reflections should appears in the material.
  30641. */
  30642. roughness: number;
  30643. /**
  30644. * In case of refraction, define the value of the index of refraction.
  30645. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30646. */
  30647. indexOfRefraction: number;
  30648. /**
  30649. * Invert the refraction texture alongside the y axis.
  30650. * It can be useful with procedural textures or probe for instance.
  30651. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30652. */
  30653. invertRefractionY: boolean;
  30654. /**
  30655. * Defines the alpha limits in alpha test mode.
  30656. */
  30657. alphaCutOff: number;
  30658. private _useLightmapAsShadowmap;
  30659. /**
  30660. * In case of light mapping, define whether the map contains light or shadow informations.
  30661. */
  30662. useLightmapAsShadowmap: boolean;
  30663. private _diffuseFresnelParameters;
  30664. /**
  30665. * Define the diffuse fresnel parameters of the material.
  30666. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30667. */
  30668. diffuseFresnelParameters: FresnelParameters;
  30669. private _opacityFresnelParameters;
  30670. /**
  30671. * Define the opacity fresnel parameters of the material.
  30672. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30673. */
  30674. opacityFresnelParameters: FresnelParameters;
  30675. private _reflectionFresnelParameters;
  30676. /**
  30677. * Define the reflection fresnel parameters of the material.
  30678. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30679. */
  30680. reflectionFresnelParameters: FresnelParameters;
  30681. private _refractionFresnelParameters;
  30682. /**
  30683. * Define the refraction fresnel parameters of the material.
  30684. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30685. */
  30686. refractionFresnelParameters: FresnelParameters;
  30687. private _emissiveFresnelParameters;
  30688. /**
  30689. * Define the emissive fresnel parameters of the material.
  30690. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30691. */
  30692. emissiveFresnelParameters: FresnelParameters;
  30693. private _useReflectionFresnelFromSpecular;
  30694. /**
  30695. * If true automatically deducts the fresnels values from the material specularity.
  30696. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30697. */
  30698. useReflectionFresnelFromSpecular: boolean;
  30699. private _useGlossinessFromSpecularMapAlpha;
  30700. /**
  30701. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30702. */
  30703. useGlossinessFromSpecularMapAlpha: boolean;
  30704. private _maxSimultaneousLights;
  30705. /**
  30706. * Defines the maximum number of lights that can be used in the material
  30707. */
  30708. maxSimultaneousLights: number;
  30709. private _invertNormalMapX;
  30710. /**
  30711. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30712. */
  30713. invertNormalMapX: boolean;
  30714. private _invertNormalMapY;
  30715. /**
  30716. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30717. */
  30718. invertNormalMapY: boolean;
  30719. private _twoSidedLighting;
  30720. /**
  30721. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30722. */
  30723. twoSidedLighting: boolean;
  30724. /**
  30725. * Default configuration related to image processing available in the standard Material.
  30726. */
  30727. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30728. /**
  30729. * Gets the image processing configuration used either in this material.
  30730. */
  30731. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30732. /**
  30733. * Sets the Default image processing configuration used either in the this material.
  30734. *
  30735. * If sets to null, the scene one is in use.
  30736. */
  30737. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30738. /**
  30739. * Keep track of the image processing observer to allow dispose and replace.
  30740. */
  30741. private _imageProcessingObserver;
  30742. /**
  30743. * Attaches a new image processing configuration to the Standard Material.
  30744. * @param configuration
  30745. */
  30746. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30747. /**
  30748. * Gets wether the color curves effect is enabled.
  30749. */
  30750. get cameraColorCurvesEnabled(): boolean;
  30751. /**
  30752. * Sets wether the color curves effect is enabled.
  30753. */
  30754. set cameraColorCurvesEnabled(value: boolean);
  30755. /**
  30756. * Gets wether the color grading effect is enabled.
  30757. */
  30758. get cameraColorGradingEnabled(): boolean;
  30759. /**
  30760. * Gets wether the color grading effect is enabled.
  30761. */
  30762. set cameraColorGradingEnabled(value: boolean);
  30763. /**
  30764. * Gets wether tonemapping is enabled or not.
  30765. */
  30766. get cameraToneMappingEnabled(): boolean;
  30767. /**
  30768. * Sets wether tonemapping is enabled or not
  30769. */
  30770. set cameraToneMappingEnabled(value: boolean);
  30771. /**
  30772. * The camera exposure used on this material.
  30773. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30774. * This corresponds to a photographic exposure.
  30775. */
  30776. get cameraExposure(): number;
  30777. /**
  30778. * The camera exposure used on this material.
  30779. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30780. * This corresponds to a photographic exposure.
  30781. */
  30782. set cameraExposure(value: number);
  30783. /**
  30784. * Gets The camera contrast used on this material.
  30785. */
  30786. get cameraContrast(): number;
  30787. /**
  30788. * Sets The camera contrast used on this material.
  30789. */
  30790. set cameraContrast(value: number);
  30791. /**
  30792. * Gets the Color Grading 2D Lookup Texture.
  30793. */
  30794. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30795. /**
  30796. * Sets the Color Grading 2D Lookup Texture.
  30797. */
  30798. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30799. /**
  30800. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30801. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30802. * 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;
  30803. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30804. */
  30805. get cameraColorCurves(): Nullable<ColorCurves>;
  30806. /**
  30807. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30808. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30809. * 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;
  30810. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30811. */
  30812. set cameraColorCurves(value: Nullable<ColorCurves>);
  30813. /**
  30814. * Can this material render to several textures at once
  30815. */
  30816. get canRenderToMRT(): boolean;
  30817. /**
  30818. * Defines the detail map parameters for the material.
  30819. */
  30820. readonly detailMap: DetailMapConfiguration;
  30821. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30822. protected _worldViewProjectionMatrix: Matrix;
  30823. protected _globalAmbientColor: Color3;
  30824. protected _useLogarithmicDepth: boolean;
  30825. protected _rebuildInParallel: boolean;
  30826. /**
  30827. * Instantiates a new standard material.
  30828. * This is the default material used in Babylon. It is the best trade off between quality
  30829. * and performances.
  30830. * @see https://doc.babylonjs.com/babylon101/materials
  30831. * @param name Define the name of the material in the scene
  30832. * @param scene Define the scene the material belong to
  30833. */
  30834. constructor(name: string, scene: Scene);
  30835. /**
  30836. * Gets a boolean indicating that current material needs to register RTT
  30837. */
  30838. get hasRenderTargetTextures(): boolean;
  30839. /**
  30840. * Gets the current class name of the material e.g. "StandardMaterial"
  30841. * Mainly use in serialization.
  30842. * @returns the class name
  30843. */
  30844. getClassName(): string;
  30845. /**
  30846. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30847. * You can try switching to logarithmic depth.
  30848. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30849. */
  30850. get useLogarithmicDepth(): boolean;
  30851. set useLogarithmicDepth(value: boolean);
  30852. /**
  30853. * Specifies if the material will require alpha blending
  30854. * @returns a boolean specifying if alpha blending is needed
  30855. */
  30856. needAlphaBlending(): boolean;
  30857. /**
  30858. * Specifies if this material should be rendered in alpha test mode
  30859. * @returns a boolean specifying if an alpha test is needed.
  30860. */
  30861. needAlphaTesting(): boolean;
  30862. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30863. /**
  30864. * Get the texture used for alpha test purpose.
  30865. * @returns the diffuse texture in case of the standard material.
  30866. */
  30867. getAlphaTestTexture(): Nullable<BaseTexture>;
  30868. /**
  30869. * Get if the submesh is ready to be used and all its information available.
  30870. * Child classes can use it to update shaders
  30871. * @param mesh defines the mesh to check
  30872. * @param subMesh defines which submesh to check
  30873. * @param useInstances specifies that instances should be used
  30874. * @returns a boolean indicating that the submesh is ready or not
  30875. */
  30876. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30877. /**
  30878. * Builds the material UBO layouts.
  30879. * Used internally during the effect preparation.
  30880. */
  30881. buildUniformLayout(): void;
  30882. /**
  30883. * Unbinds the material from the mesh
  30884. */
  30885. unbind(): void;
  30886. /**
  30887. * Binds the submesh to this material by preparing the effect and shader to draw
  30888. * @param world defines the world transformation matrix
  30889. * @param mesh defines the mesh containing the submesh
  30890. * @param subMesh defines the submesh to bind the material to
  30891. */
  30892. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30893. /**
  30894. * Get the list of animatables in the material.
  30895. * @returns the list of animatables object used in the material
  30896. */
  30897. getAnimatables(): IAnimatable[];
  30898. /**
  30899. * Gets the active textures from the material
  30900. * @returns an array of textures
  30901. */
  30902. getActiveTextures(): BaseTexture[];
  30903. /**
  30904. * Specifies if the material uses a texture
  30905. * @param texture defines the texture to check against the material
  30906. * @returns a boolean specifying if the material uses the texture
  30907. */
  30908. hasTexture(texture: BaseTexture): boolean;
  30909. /**
  30910. * Disposes the material
  30911. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30912. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30913. */
  30914. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30915. /**
  30916. * Makes a duplicate of the material, and gives it a new name
  30917. * @param name defines the new name for the duplicated material
  30918. * @returns the cloned material
  30919. */
  30920. clone(name: string): StandardMaterial;
  30921. /**
  30922. * Serializes this material in a JSON representation
  30923. * @returns the serialized material object
  30924. */
  30925. serialize(): any;
  30926. /**
  30927. * Creates a standard material from parsed material data
  30928. * @param source defines the JSON representation of the material
  30929. * @param scene defines the hosting scene
  30930. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  30931. * @returns a new standard material
  30932. */
  30933. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  30934. /**
  30935. * Are diffuse textures enabled in the application.
  30936. */
  30937. static get DiffuseTextureEnabled(): boolean;
  30938. static set DiffuseTextureEnabled(value: boolean);
  30939. /**
  30940. * Are detail textures enabled in the application.
  30941. */
  30942. static get DetailTextureEnabled(): boolean;
  30943. static set DetailTextureEnabled(value: boolean);
  30944. /**
  30945. * Are ambient textures enabled in the application.
  30946. */
  30947. static get AmbientTextureEnabled(): boolean;
  30948. static set AmbientTextureEnabled(value: boolean);
  30949. /**
  30950. * Are opacity textures enabled in the application.
  30951. */
  30952. static get OpacityTextureEnabled(): boolean;
  30953. static set OpacityTextureEnabled(value: boolean);
  30954. /**
  30955. * Are reflection textures enabled in the application.
  30956. */
  30957. static get ReflectionTextureEnabled(): boolean;
  30958. static set ReflectionTextureEnabled(value: boolean);
  30959. /**
  30960. * Are emissive textures enabled in the application.
  30961. */
  30962. static get EmissiveTextureEnabled(): boolean;
  30963. static set EmissiveTextureEnabled(value: boolean);
  30964. /**
  30965. * Are specular textures enabled in the application.
  30966. */
  30967. static get SpecularTextureEnabled(): boolean;
  30968. static set SpecularTextureEnabled(value: boolean);
  30969. /**
  30970. * Are bump textures enabled in the application.
  30971. */
  30972. static get BumpTextureEnabled(): boolean;
  30973. static set BumpTextureEnabled(value: boolean);
  30974. /**
  30975. * Are lightmap textures enabled in the application.
  30976. */
  30977. static get LightmapTextureEnabled(): boolean;
  30978. static set LightmapTextureEnabled(value: boolean);
  30979. /**
  30980. * Are refraction textures enabled in the application.
  30981. */
  30982. static get RefractionTextureEnabled(): boolean;
  30983. static set RefractionTextureEnabled(value: boolean);
  30984. /**
  30985. * Are color grading textures enabled in the application.
  30986. */
  30987. static get ColorGradingTextureEnabled(): boolean;
  30988. static set ColorGradingTextureEnabled(value: boolean);
  30989. /**
  30990. * Are fresnels enabled in the application.
  30991. */
  30992. static get FresnelEnabled(): boolean;
  30993. static set FresnelEnabled(value: boolean);
  30994. }
  30995. }
  30996. declare module BABYLON {
  30997. /**
  30998. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  30999. *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.
  31000. * The SPS is also a particle system. It provides some methods to manage the particles.
  31001. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31002. *
  31003. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  31004. */
  31005. export class SolidParticleSystem implements IDisposable {
  31006. /**
  31007. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31008. * Example : var p = SPS.particles[i];
  31009. */
  31010. particles: SolidParticle[];
  31011. /**
  31012. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31013. */
  31014. nbParticles: number;
  31015. /**
  31016. * If the particles must ever face the camera (default false). Useful for planar particles.
  31017. */
  31018. billboard: boolean;
  31019. /**
  31020. * Recompute normals when adding a shape
  31021. */
  31022. recomputeNormals: boolean;
  31023. /**
  31024. * This a counter ofr your own usage. It's not set by any SPS functions.
  31025. */
  31026. counter: number;
  31027. /**
  31028. * The SPS name. This name is also given to the underlying mesh.
  31029. */
  31030. name: string;
  31031. /**
  31032. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31033. */
  31034. mesh: Mesh;
  31035. /**
  31036. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31037. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  31038. */
  31039. vars: any;
  31040. /**
  31041. * This array is populated when the SPS is set as 'pickable'.
  31042. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31043. * Each element of this array is an object `{idx: int, faceId: int}`.
  31044. * `idx` is the picked particle index in the `SPS.particles` array
  31045. * `faceId` is the picked face index counted within this particle.
  31046. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  31047. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  31048. * Use the method SPS.pickedParticle(pickingInfo) instead.
  31049. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31050. */
  31051. pickedParticles: {
  31052. idx: number;
  31053. faceId: number;
  31054. }[];
  31055. /**
  31056. * This array is populated when the SPS is set as 'pickable'
  31057. * Each key of this array is a submesh index.
  31058. * Each element of this array is a second array defined like this :
  31059. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31060. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31061. * `idx` is the picked particle index in the `SPS.particles` array
  31062. * `faceId` is the picked face index counted within this particle.
  31063. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31064. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31065. */
  31066. pickedBySubMesh: {
  31067. idx: number;
  31068. faceId: number;
  31069. }[][];
  31070. /**
  31071. * This array is populated when `enableDepthSort` is set to true.
  31072. * Each element of this array is an instance of the class DepthSortedParticle.
  31073. */
  31074. depthSortedParticles: DepthSortedParticle[];
  31075. /**
  31076. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31077. * @hidden
  31078. */
  31079. _bSphereOnly: boolean;
  31080. /**
  31081. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31082. * @hidden
  31083. */
  31084. _bSphereRadiusFactor: number;
  31085. private _scene;
  31086. private _positions;
  31087. private _indices;
  31088. private _normals;
  31089. private _colors;
  31090. private _uvs;
  31091. private _indices32;
  31092. private _positions32;
  31093. private _normals32;
  31094. private _fixedNormal32;
  31095. private _colors32;
  31096. private _uvs32;
  31097. private _index;
  31098. private _updatable;
  31099. private _pickable;
  31100. private _isVisibilityBoxLocked;
  31101. private _alwaysVisible;
  31102. private _depthSort;
  31103. private _expandable;
  31104. private _shapeCounter;
  31105. private _copy;
  31106. private _color;
  31107. private _computeParticleColor;
  31108. private _computeParticleTexture;
  31109. private _computeParticleRotation;
  31110. private _computeParticleVertex;
  31111. private _computeBoundingBox;
  31112. private _depthSortParticles;
  31113. private _camera;
  31114. private _mustUnrotateFixedNormals;
  31115. private _particlesIntersect;
  31116. private _needs32Bits;
  31117. private _isNotBuilt;
  31118. private _lastParticleId;
  31119. private _idxOfId;
  31120. private _multimaterialEnabled;
  31121. private _useModelMaterial;
  31122. private _indicesByMaterial;
  31123. private _materialIndexes;
  31124. private _depthSortFunction;
  31125. private _materialSortFunction;
  31126. private _materials;
  31127. private _multimaterial;
  31128. private _materialIndexesById;
  31129. private _defaultMaterial;
  31130. private _autoUpdateSubMeshes;
  31131. private _tmpVertex;
  31132. /**
  31133. * Creates a SPS (Solid Particle System) object.
  31134. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31135. * @param scene (Scene) is the scene in which the SPS is added.
  31136. * @param options defines the options of the sps e.g.
  31137. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31138. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31139. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31140. * * 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.
  31141. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31142. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31143. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31144. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31145. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31146. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31147. */
  31148. constructor(name: string, scene: Scene, options?: {
  31149. updatable?: boolean;
  31150. isPickable?: boolean;
  31151. enableDepthSort?: boolean;
  31152. particleIntersection?: boolean;
  31153. boundingSphereOnly?: boolean;
  31154. bSphereRadiusFactor?: number;
  31155. expandable?: boolean;
  31156. useModelMaterial?: boolean;
  31157. enableMultiMaterial?: boolean;
  31158. });
  31159. /**
  31160. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31161. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31162. * @returns the created mesh
  31163. */
  31164. buildMesh(): Mesh;
  31165. /**
  31166. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31167. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31168. * Thus the particles generated from `digest()` have their property `position` set yet.
  31169. * @param mesh ( Mesh ) is the mesh to be digested
  31170. * @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
  31171. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31172. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31173. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31174. * @returns the current SPS
  31175. */
  31176. digest(mesh: Mesh, options?: {
  31177. facetNb?: number;
  31178. number?: number;
  31179. delta?: number;
  31180. storage?: [];
  31181. }): SolidParticleSystem;
  31182. /**
  31183. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31184. * @hidden
  31185. */
  31186. private _unrotateFixedNormals;
  31187. /**
  31188. * Resets the temporary working copy particle
  31189. * @hidden
  31190. */
  31191. private _resetCopy;
  31192. /**
  31193. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31194. * @param p the current index in the positions array to be updated
  31195. * @param ind the current index in the indices array
  31196. * @param shape a Vector3 array, the shape geometry
  31197. * @param positions the positions array to be updated
  31198. * @param meshInd the shape indices array
  31199. * @param indices the indices array to be updated
  31200. * @param meshUV the shape uv array
  31201. * @param uvs the uv array to be updated
  31202. * @param meshCol the shape color array
  31203. * @param colors the color array to be updated
  31204. * @param meshNor the shape normals array
  31205. * @param normals the normals array to be updated
  31206. * @param idx the particle index
  31207. * @param idxInShape the particle index in its shape
  31208. * @param options the addShape() method passed options
  31209. * @model the particle model
  31210. * @hidden
  31211. */
  31212. private _meshBuilder;
  31213. /**
  31214. * Returns a shape Vector3 array from positions float array
  31215. * @param positions float array
  31216. * @returns a vector3 array
  31217. * @hidden
  31218. */
  31219. private _posToShape;
  31220. /**
  31221. * Returns a shapeUV array from a float uvs (array deep copy)
  31222. * @param uvs as a float array
  31223. * @returns a shapeUV array
  31224. * @hidden
  31225. */
  31226. private _uvsToShapeUV;
  31227. /**
  31228. * Adds a new particle object in the particles array
  31229. * @param idx particle index in particles array
  31230. * @param id particle id
  31231. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31232. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31233. * @param model particle ModelShape object
  31234. * @param shapeId model shape identifier
  31235. * @param idxInShape index of the particle in the current model
  31236. * @param bInfo model bounding info object
  31237. * @param storage target storage array, if any
  31238. * @hidden
  31239. */
  31240. private _addParticle;
  31241. /**
  31242. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31243. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31244. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31245. * @param nb (positive integer) the number of particles to be created from this model
  31246. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31247. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31248. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31249. * @returns the number of shapes in the system
  31250. */
  31251. addShape(mesh: Mesh, nb: number, options?: {
  31252. positionFunction?: any;
  31253. vertexFunction?: any;
  31254. storage?: [];
  31255. }): number;
  31256. /**
  31257. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31258. * @hidden
  31259. */
  31260. private _rebuildParticle;
  31261. /**
  31262. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31263. * @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.
  31264. * @returns the SPS.
  31265. */
  31266. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31267. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31268. * Returns an array with the removed particles.
  31269. * 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.
  31270. * The SPS can't be empty so at least one particle needs to remain in place.
  31271. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31272. * @param start index of the first particle to remove
  31273. * @param end index of the last particle to remove (included)
  31274. * @returns an array populated with the removed particles
  31275. */
  31276. removeParticles(start: number, end: number): SolidParticle[];
  31277. /**
  31278. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31279. * @param solidParticleArray an array populated with Solid Particles objects
  31280. * @returns the SPS
  31281. */
  31282. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31283. /**
  31284. * Creates a new particle and modifies the SPS mesh geometry :
  31285. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31286. * - calls _addParticle() to populate the particle array
  31287. * factorized code from addShape() and insertParticlesFromArray()
  31288. * @param idx particle index in the particles array
  31289. * @param i particle index in its shape
  31290. * @param modelShape particle ModelShape object
  31291. * @param shape shape vertex array
  31292. * @param meshInd shape indices array
  31293. * @param meshUV shape uv array
  31294. * @param meshCol shape color array
  31295. * @param meshNor shape normals array
  31296. * @param bbInfo shape bounding info
  31297. * @param storage target particle storage
  31298. * @options addShape() passed options
  31299. * @hidden
  31300. */
  31301. private _insertNewParticle;
  31302. /**
  31303. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31304. * This method calls `updateParticle()` for each particle of the SPS.
  31305. * For an animated SPS, it is usually called within the render loop.
  31306. * 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.
  31307. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31308. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31309. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31310. * @returns the SPS.
  31311. */
  31312. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31313. /**
  31314. * Disposes the SPS.
  31315. */
  31316. dispose(): void;
  31317. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31318. * idx is the particle index in the SPS
  31319. * faceId is the picked face index counted within this particle.
  31320. * Returns null if the pickInfo can't identify a picked particle.
  31321. * @param pickingInfo (PickingInfo object)
  31322. * @returns {idx: number, faceId: number} or null
  31323. */
  31324. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31325. idx: number;
  31326. faceId: number;
  31327. }>;
  31328. /**
  31329. * Returns a SolidParticle object from its identifier : particle.id
  31330. * @param id (integer) the particle Id
  31331. * @returns the searched particle or null if not found in the SPS.
  31332. */
  31333. getParticleById(id: number): Nullable<SolidParticle>;
  31334. /**
  31335. * Returns a new array populated with the particles having the passed shapeId.
  31336. * @param shapeId (integer) the shape identifier
  31337. * @returns a new solid particle array
  31338. */
  31339. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31340. /**
  31341. * Populates the passed array "ref" with the particles having the passed shapeId.
  31342. * @param shapeId the shape identifier
  31343. * @returns the SPS
  31344. * @param ref
  31345. */
  31346. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31347. /**
  31348. * Computes the required SubMeshes according the materials assigned to the particles.
  31349. * @returns the solid particle system.
  31350. * Does nothing if called before the SPS mesh is built.
  31351. */
  31352. computeSubMeshes(): SolidParticleSystem;
  31353. /**
  31354. * Sorts the solid particles by material when MultiMaterial is enabled.
  31355. * Updates the indices32 array.
  31356. * Updates the indicesByMaterial array.
  31357. * Updates the mesh indices array.
  31358. * @returns the SPS
  31359. * @hidden
  31360. */
  31361. private _sortParticlesByMaterial;
  31362. /**
  31363. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31364. * @hidden
  31365. */
  31366. private _setMaterialIndexesById;
  31367. /**
  31368. * Returns an array with unique values of Materials from the passed array
  31369. * @param array the material array to be checked and filtered
  31370. * @hidden
  31371. */
  31372. private _filterUniqueMaterialId;
  31373. /**
  31374. * Sets a new Standard Material as _defaultMaterial if not already set.
  31375. * @hidden
  31376. */
  31377. private _setDefaultMaterial;
  31378. /**
  31379. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31380. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31381. * @returns the SPS.
  31382. */
  31383. refreshVisibleSize(): SolidParticleSystem;
  31384. /**
  31385. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31386. * @param size the size (float) of the visibility box
  31387. * note : this doesn't lock the SPS mesh bounding box.
  31388. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31389. */
  31390. setVisibilityBox(size: number): void;
  31391. /**
  31392. * Gets whether the SPS as always visible or not
  31393. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31394. */
  31395. get isAlwaysVisible(): boolean;
  31396. /**
  31397. * Sets the SPS as always visible or not
  31398. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31399. */
  31400. set isAlwaysVisible(val: boolean);
  31401. /**
  31402. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31403. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31404. */
  31405. set isVisibilityBoxLocked(val: boolean);
  31406. /**
  31407. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31408. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31409. */
  31410. get isVisibilityBoxLocked(): boolean;
  31411. /**
  31412. * Tells to `setParticles()` to compute the particle rotations or not.
  31413. * Default value : true. The SPS is faster when it's set to false.
  31414. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31415. */
  31416. set computeParticleRotation(val: boolean);
  31417. /**
  31418. * Tells to `setParticles()` to compute the particle colors or not.
  31419. * Default value : true. The SPS is faster when it's set to false.
  31420. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31421. */
  31422. set computeParticleColor(val: boolean);
  31423. set computeParticleTexture(val: boolean);
  31424. /**
  31425. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31426. * Default value : false. The SPS is faster when it's set to false.
  31427. * Note : the particle custom vertex positions aren't stored values.
  31428. */
  31429. set computeParticleVertex(val: boolean);
  31430. /**
  31431. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31432. */
  31433. set computeBoundingBox(val: boolean);
  31434. /**
  31435. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31436. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31437. * Default : `true`
  31438. */
  31439. set depthSortParticles(val: boolean);
  31440. /**
  31441. * Gets if `setParticles()` computes the particle rotations or not.
  31442. * Default value : true. The SPS is faster when it's set to false.
  31443. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31444. */
  31445. get computeParticleRotation(): boolean;
  31446. /**
  31447. * Gets if `setParticles()` computes the particle colors or not.
  31448. * Default value : true. The SPS is faster when it's set to false.
  31449. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31450. */
  31451. get computeParticleColor(): boolean;
  31452. /**
  31453. * Gets if `setParticles()` computes the particle textures or not.
  31454. * Default value : true. The SPS is faster when it's set to false.
  31455. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31456. */
  31457. get computeParticleTexture(): boolean;
  31458. /**
  31459. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31460. * Default value : false. The SPS is faster when it's set to false.
  31461. * Note : the particle custom vertex positions aren't stored values.
  31462. */
  31463. get computeParticleVertex(): boolean;
  31464. /**
  31465. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31466. */
  31467. get computeBoundingBox(): boolean;
  31468. /**
  31469. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31470. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31471. * Default : `true`
  31472. */
  31473. get depthSortParticles(): boolean;
  31474. /**
  31475. * Gets if the SPS is created as expandable at construction time.
  31476. * Default : `false`
  31477. */
  31478. get expandable(): boolean;
  31479. /**
  31480. * Gets if the SPS supports the Multi Materials
  31481. */
  31482. get multimaterialEnabled(): boolean;
  31483. /**
  31484. * Gets if the SPS uses the model materials for its own multimaterial.
  31485. */
  31486. get useModelMaterial(): boolean;
  31487. /**
  31488. * The SPS used material array.
  31489. */
  31490. get materials(): Material[];
  31491. /**
  31492. * Sets the SPS MultiMaterial from the passed materials.
  31493. * Note : the passed array is internally copied and not used then by reference.
  31494. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31495. */
  31496. setMultiMaterial(materials: Material[]): void;
  31497. /**
  31498. * The SPS computed multimaterial object
  31499. */
  31500. get multimaterial(): MultiMaterial;
  31501. set multimaterial(mm: MultiMaterial);
  31502. /**
  31503. * If the subMeshes must be updated on the next call to setParticles()
  31504. */
  31505. get autoUpdateSubMeshes(): boolean;
  31506. set autoUpdateSubMeshes(val: boolean);
  31507. /**
  31508. * This function does nothing. It may be overwritten to set all the particle first values.
  31509. * The SPS doesn't call this function, you may have to call it by your own.
  31510. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31511. */
  31512. initParticles(): void;
  31513. /**
  31514. * This function does nothing. It may be overwritten to recycle a particle.
  31515. * The SPS doesn't call this function, you may have to call it by your own.
  31516. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31517. * @param particle The particle to recycle
  31518. * @returns the recycled particle
  31519. */
  31520. recycleParticle(particle: SolidParticle): SolidParticle;
  31521. /**
  31522. * Updates a particle : this function should be overwritten by the user.
  31523. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31524. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31525. * @example : just set a particle position or velocity and recycle conditions
  31526. * @param particle The particle to update
  31527. * @returns the updated particle
  31528. */
  31529. updateParticle(particle: SolidParticle): SolidParticle;
  31530. /**
  31531. * Updates a vertex of a particle : it can be overwritten by the user.
  31532. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31533. * @param particle the current particle
  31534. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31535. * @param pt the index of the current vertex in the particle shape
  31536. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31537. * @example : just set a vertex particle position or color
  31538. * @returns the sps
  31539. */
  31540. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31541. /**
  31542. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31543. * This does nothing and may be overwritten by the user.
  31544. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31545. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31546. * @param update the boolean update value actually passed to setParticles()
  31547. */
  31548. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31549. /**
  31550. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31551. * This will be passed three parameters.
  31552. * This does nothing and may be overwritten by the user.
  31553. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31554. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31555. * @param update the boolean update value actually passed to setParticles()
  31556. */
  31557. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31558. }
  31559. }
  31560. declare module BABYLON {
  31561. /**
  31562. * Represents one particle of a solid particle system.
  31563. */
  31564. export class SolidParticle {
  31565. /**
  31566. * particle global index
  31567. */
  31568. idx: number;
  31569. /**
  31570. * particle identifier
  31571. */
  31572. id: number;
  31573. /**
  31574. * The color of the particle
  31575. */
  31576. color: Nullable<Color4>;
  31577. /**
  31578. * The world space position of the particle.
  31579. */
  31580. position: Vector3;
  31581. /**
  31582. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31583. */
  31584. rotation: Vector3;
  31585. /**
  31586. * The world space rotation quaternion of the particle.
  31587. */
  31588. rotationQuaternion: Nullable<Quaternion>;
  31589. /**
  31590. * The scaling of the particle.
  31591. */
  31592. scaling: Vector3;
  31593. /**
  31594. * The uvs of the particle.
  31595. */
  31596. uvs: Vector4;
  31597. /**
  31598. * The current speed of the particle.
  31599. */
  31600. velocity: Vector3;
  31601. /**
  31602. * The pivot point in the particle local space.
  31603. */
  31604. pivot: Vector3;
  31605. /**
  31606. * Must the particle be translated from its pivot point in its local space ?
  31607. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31608. * Default : false
  31609. */
  31610. translateFromPivot: boolean;
  31611. /**
  31612. * Is the particle active or not ?
  31613. */
  31614. alive: boolean;
  31615. /**
  31616. * Is the particle visible or not ?
  31617. */
  31618. isVisible: boolean;
  31619. /**
  31620. * Index of this particle in the global "positions" array (Internal use)
  31621. * @hidden
  31622. */
  31623. _pos: number;
  31624. /**
  31625. * @hidden Index of this particle in the global "indices" array (Internal use)
  31626. */
  31627. _ind: number;
  31628. /**
  31629. * @hidden ModelShape of this particle (Internal use)
  31630. */
  31631. _model: ModelShape;
  31632. /**
  31633. * ModelShape id of this particle
  31634. */
  31635. shapeId: number;
  31636. /**
  31637. * Index of the particle in its shape id
  31638. */
  31639. idxInShape: number;
  31640. /**
  31641. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31642. */
  31643. _modelBoundingInfo: BoundingInfo;
  31644. /**
  31645. * @hidden Particle BoundingInfo object (Internal use)
  31646. */
  31647. _boundingInfo: BoundingInfo;
  31648. /**
  31649. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31650. */
  31651. _sps: SolidParticleSystem;
  31652. /**
  31653. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31654. */
  31655. _stillInvisible: boolean;
  31656. /**
  31657. * @hidden Last computed particle rotation matrix
  31658. */
  31659. _rotationMatrix: number[];
  31660. /**
  31661. * Parent particle Id, if any.
  31662. * Default null.
  31663. */
  31664. parentId: Nullable<number>;
  31665. /**
  31666. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31667. */
  31668. materialIndex: Nullable<number>;
  31669. /**
  31670. * Custom object or properties.
  31671. */
  31672. props: Nullable<any>;
  31673. /**
  31674. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31675. * The possible values are :
  31676. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31677. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31678. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31679. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31680. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31681. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31682. * */
  31683. cullingStrategy: number;
  31684. /**
  31685. * @hidden Internal global position in the SPS.
  31686. */
  31687. _globalPosition: Vector3;
  31688. /**
  31689. * Creates a Solid Particle object.
  31690. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31691. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31692. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31693. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31694. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31695. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31696. * @param shapeId (integer) is the model shape identifier in the SPS.
  31697. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31698. * @param sps defines the sps it is associated to
  31699. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31700. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31701. */
  31702. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31703. /**
  31704. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31705. * @param target the particle target
  31706. * @returns the current particle
  31707. */
  31708. copyToRef(target: SolidParticle): SolidParticle;
  31709. /**
  31710. * Legacy support, changed scale to scaling
  31711. */
  31712. get scale(): Vector3;
  31713. /**
  31714. * Legacy support, changed scale to scaling
  31715. */
  31716. set scale(scale: Vector3);
  31717. /**
  31718. * Legacy support, changed quaternion to rotationQuaternion
  31719. */
  31720. get quaternion(): Nullable<Quaternion>;
  31721. /**
  31722. * Legacy support, changed quaternion to rotationQuaternion
  31723. */
  31724. set quaternion(q: Nullable<Quaternion>);
  31725. /**
  31726. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31727. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31728. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31729. * @returns true if it intersects
  31730. */
  31731. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31732. /**
  31733. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31734. * A particle is in the frustum if its bounding box intersects the frustum
  31735. * @param frustumPlanes defines the frustum to test
  31736. * @returns true if the particle is in the frustum planes
  31737. */
  31738. isInFrustum(frustumPlanes: Plane[]): boolean;
  31739. /**
  31740. * get the rotation matrix of the particle
  31741. * @hidden
  31742. */
  31743. getRotationMatrix(m: Matrix): void;
  31744. }
  31745. /**
  31746. * Represents the shape of the model used by one particle of a solid particle system.
  31747. * SPS internal tool, don't use it manually.
  31748. */
  31749. export class ModelShape {
  31750. /**
  31751. * The shape id
  31752. * @hidden
  31753. */
  31754. shapeID: number;
  31755. /**
  31756. * flat array of model positions (internal use)
  31757. * @hidden
  31758. */
  31759. _shape: Vector3[];
  31760. /**
  31761. * flat array of model UVs (internal use)
  31762. * @hidden
  31763. */
  31764. _shapeUV: number[];
  31765. /**
  31766. * color array of the model
  31767. * @hidden
  31768. */
  31769. _shapeColors: number[];
  31770. /**
  31771. * indices array of the model
  31772. * @hidden
  31773. */
  31774. _indices: number[];
  31775. /**
  31776. * normals array of the model
  31777. * @hidden
  31778. */
  31779. _normals: number[];
  31780. /**
  31781. * length of the shape in the model indices array (internal use)
  31782. * @hidden
  31783. */
  31784. _indicesLength: number;
  31785. /**
  31786. * Custom position function (internal use)
  31787. * @hidden
  31788. */
  31789. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31790. /**
  31791. * Custom vertex function (internal use)
  31792. * @hidden
  31793. */
  31794. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31795. /**
  31796. * Model material (internal use)
  31797. * @hidden
  31798. */
  31799. _material: Nullable<Material>;
  31800. /**
  31801. * 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.
  31802. * SPS internal tool, don't use it manually.
  31803. * @hidden
  31804. */
  31805. 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>);
  31806. }
  31807. /**
  31808. * Represents a Depth Sorted Particle in the solid particle system.
  31809. * @hidden
  31810. */
  31811. export class DepthSortedParticle {
  31812. /**
  31813. * Particle index
  31814. */
  31815. idx: number;
  31816. /**
  31817. * Index of the particle in the "indices" array
  31818. */
  31819. ind: number;
  31820. /**
  31821. * Length of the particle shape in the "indices" array
  31822. */
  31823. indicesLength: number;
  31824. /**
  31825. * Squared distance from the particle to the camera
  31826. */
  31827. sqDistance: number;
  31828. /**
  31829. * Material index when used with MultiMaterials
  31830. */
  31831. materialIndex: number;
  31832. /**
  31833. * Creates a new sorted particle
  31834. * @param materialIndex
  31835. */
  31836. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31837. }
  31838. /**
  31839. * Represents a solid particle vertex
  31840. */
  31841. export class SolidParticleVertex {
  31842. /**
  31843. * Vertex position
  31844. */
  31845. position: Vector3;
  31846. /**
  31847. * Vertex color
  31848. */
  31849. color: Color4;
  31850. /**
  31851. * Vertex UV
  31852. */
  31853. uv: Vector2;
  31854. /**
  31855. * Creates a new solid particle vertex
  31856. */
  31857. constructor();
  31858. /** Vertex x coordinate */
  31859. get x(): number;
  31860. set x(val: number);
  31861. /** Vertex y coordinate */
  31862. get y(): number;
  31863. set y(val: number);
  31864. /** Vertex z coordinate */
  31865. get z(): number;
  31866. set z(val: number);
  31867. }
  31868. }
  31869. declare module BABYLON {
  31870. /**
  31871. * @hidden
  31872. */
  31873. export class _MeshCollisionData {
  31874. _checkCollisions: boolean;
  31875. _collisionMask: number;
  31876. _collisionGroup: number;
  31877. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31878. _collider: Nullable<Collider>;
  31879. _oldPositionForCollisions: Vector3;
  31880. _diffPositionForCollisions: Vector3;
  31881. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31882. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31883. }
  31884. }
  31885. declare module BABYLON {
  31886. /** @hidden */
  31887. class _FacetDataStorage {
  31888. facetPositions: Vector3[];
  31889. facetNormals: Vector3[];
  31890. facetPartitioning: number[][];
  31891. facetNb: number;
  31892. partitioningSubdivisions: number;
  31893. partitioningBBoxRatio: number;
  31894. facetDataEnabled: boolean;
  31895. facetParameters: any;
  31896. bbSize: Vector3;
  31897. subDiv: {
  31898. max: number;
  31899. X: number;
  31900. Y: number;
  31901. Z: number;
  31902. };
  31903. facetDepthSort: boolean;
  31904. facetDepthSortEnabled: boolean;
  31905. depthSortedIndices: IndicesArray;
  31906. depthSortedFacets: {
  31907. ind: number;
  31908. sqDistance: number;
  31909. }[];
  31910. facetDepthSortFunction: (f1: {
  31911. ind: number;
  31912. sqDistance: number;
  31913. }, f2: {
  31914. ind: number;
  31915. sqDistance: number;
  31916. }) => number;
  31917. facetDepthSortFrom: Vector3;
  31918. facetDepthSortOrigin: Vector3;
  31919. invertedMatrix: Matrix;
  31920. }
  31921. /**
  31922. * @hidden
  31923. **/
  31924. class _InternalAbstractMeshDataInfo {
  31925. _hasVertexAlpha: boolean;
  31926. _useVertexColors: boolean;
  31927. _numBoneInfluencers: number;
  31928. _applyFog: boolean;
  31929. _receiveShadows: boolean;
  31930. _facetData: _FacetDataStorage;
  31931. _visibility: number;
  31932. _skeleton: Nullable<Skeleton>;
  31933. _layerMask: number;
  31934. _computeBonesUsingShaders: boolean;
  31935. _isActive: boolean;
  31936. _onlyForInstances: boolean;
  31937. _isActiveIntermediate: boolean;
  31938. _onlyForInstancesIntermediate: boolean;
  31939. _actAsRegularMesh: boolean;
  31940. }
  31941. /**
  31942. * Class used to store all common mesh properties
  31943. */
  31944. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  31945. /** No occlusion */
  31946. static OCCLUSION_TYPE_NONE: number;
  31947. /** Occlusion set to optimisitic */
  31948. static OCCLUSION_TYPE_OPTIMISTIC: number;
  31949. /** Occlusion set to strict */
  31950. static OCCLUSION_TYPE_STRICT: number;
  31951. /** Use an accurante occlusion algorithm */
  31952. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  31953. /** Use a conservative occlusion algorithm */
  31954. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  31955. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  31956. * Test order :
  31957. * Is the bounding sphere outside the frustum ?
  31958. * If not, are the bounding box vertices outside the frustum ?
  31959. * It not, then the cullable object is in the frustum.
  31960. */
  31961. static readonly CULLINGSTRATEGY_STANDARD: number;
  31962. /** Culling strategy : Bounding Sphere Only.
  31963. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  31964. * It's also less accurate than the standard because some not visible objects can still be selected.
  31965. * Test : is the bounding sphere outside the frustum ?
  31966. * If not, then the cullable object is in the frustum.
  31967. */
  31968. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  31969. /** Culling strategy : Optimistic Inclusion.
  31970. * This in an inclusion test first, then the standard exclusion test.
  31971. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  31972. * 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.
  31973. * Anyway, it's as accurate as the standard strategy.
  31974. * Test :
  31975. * Is the cullable object bounding sphere center in the frustum ?
  31976. * If not, apply the default culling strategy.
  31977. */
  31978. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  31979. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  31980. * This in an inclusion test first, then the bounding sphere only exclusion test.
  31981. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  31982. * 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.
  31983. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  31984. * Test :
  31985. * Is the cullable object bounding sphere center in the frustum ?
  31986. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  31987. */
  31988. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  31989. /**
  31990. * No billboard
  31991. */
  31992. static get BILLBOARDMODE_NONE(): number;
  31993. /** Billboard on X axis */
  31994. static get BILLBOARDMODE_X(): number;
  31995. /** Billboard on Y axis */
  31996. static get BILLBOARDMODE_Y(): number;
  31997. /** Billboard on Z axis */
  31998. static get BILLBOARDMODE_Z(): number;
  31999. /** Billboard on all axes */
  32000. static get BILLBOARDMODE_ALL(): number;
  32001. /** Billboard on using position instead of orientation */
  32002. static get BILLBOARDMODE_USE_POSITION(): number;
  32003. /** @hidden */
  32004. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  32005. /**
  32006. * The culling strategy to use to check whether the mesh must be rendered or not.
  32007. * This value can be changed at any time and will be used on the next render mesh selection.
  32008. * The possible values are :
  32009. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32010. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32011. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32012. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32013. * Please read each static variable documentation to get details about the culling process.
  32014. * */
  32015. cullingStrategy: number;
  32016. /**
  32017. * Gets the number of facets in the mesh
  32018. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32019. */
  32020. get facetNb(): number;
  32021. /**
  32022. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32023. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32024. */
  32025. get partitioningSubdivisions(): number;
  32026. set partitioningSubdivisions(nb: number);
  32027. /**
  32028. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32029. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  32030. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32031. */
  32032. get partitioningBBoxRatio(): number;
  32033. set partitioningBBoxRatio(ratio: number);
  32034. /**
  32035. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  32036. * Works only for updatable meshes.
  32037. * Doesn't work with multi-materials
  32038. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32039. */
  32040. get mustDepthSortFacets(): boolean;
  32041. set mustDepthSortFacets(sort: boolean);
  32042. /**
  32043. * The location (Vector3) where the facet depth sort must be computed from.
  32044. * By default, the active camera position.
  32045. * Used only when facet depth sort is enabled
  32046. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32047. */
  32048. get facetDepthSortFrom(): Vector3;
  32049. set facetDepthSortFrom(location: Vector3);
  32050. /**
  32051. * gets a boolean indicating if facetData is enabled
  32052. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32053. */
  32054. get isFacetDataEnabled(): boolean;
  32055. /** @hidden */
  32056. _updateNonUniformScalingState(value: boolean): boolean;
  32057. /**
  32058. * An event triggered when this mesh collides with another one
  32059. */
  32060. onCollideObservable: Observable<AbstractMesh>;
  32061. /** Set a function to call when this mesh collides with another one */
  32062. set onCollide(callback: () => void);
  32063. /**
  32064. * An event triggered when the collision's position changes
  32065. */
  32066. onCollisionPositionChangeObservable: Observable<Vector3>;
  32067. /** Set a function to call when the collision's position changes */
  32068. set onCollisionPositionChange(callback: () => void);
  32069. /**
  32070. * An event triggered when material is changed
  32071. */
  32072. onMaterialChangedObservable: Observable<AbstractMesh>;
  32073. /**
  32074. * Gets or sets the orientation for POV movement & rotation
  32075. */
  32076. definedFacingForward: boolean;
  32077. /** @hidden */
  32078. _occlusionQuery: Nullable<WebGLQuery>;
  32079. /** @hidden */
  32080. _renderingGroup: Nullable<RenderingGroup>;
  32081. /**
  32082. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32083. */
  32084. get visibility(): number;
  32085. /**
  32086. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32087. */
  32088. set visibility(value: number);
  32089. /** Gets or sets the alpha index used to sort transparent meshes
  32090. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32091. */
  32092. alphaIndex: number;
  32093. /**
  32094. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32095. */
  32096. isVisible: boolean;
  32097. /**
  32098. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32099. */
  32100. isPickable: boolean;
  32101. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32102. showSubMeshesBoundingBox: boolean;
  32103. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32104. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32105. */
  32106. isBlocker: boolean;
  32107. /**
  32108. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32109. */
  32110. enablePointerMoveEvents: boolean;
  32111. /**
  32112. * Specifies the rendering group id for this mesh (0 by default)
  32113. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32114. */
  32115. renderingGroupId: number;
  32116. private _material;
  32117. /** Gets or sets current material */
  32118. get material(): Nullable<Material>;
  32119. set material(value: Nullable<Material>);
  32120. /**
  32121. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32122. * @see https://doc.babylonjs.com/babylon101/shadows
  32123. */
  32124. get receiveShadows(): boolean;
  32125. set receiveShadows(value: boolean);
  32126. /** Defines color to use when rendering outline */
  32127. outlineColor: Color3;
  32128. /** Define width to use when rendering outline */
  32129. outlineWidth: number;
  32130. /** Defines color to use when rendering overlay */
  32131. overlayColor: Color3;
  32132. /** Defines alpha to use when rendering overlay */
  32133. overlayAlpha: number;
  32134. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32135. get hasVertexAlpha(): boolean;
  32136. set hasVertexAlpha(value: boolean);
  32137. /** 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) */
  32138. get useVertexColors(): boolean;
  32139. set useVertexColors(value: boolean);
  32140. /**
  32141. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32142. */
  32143. get computeBonesUsingShaders(): boolean;
  32144. set computeBonesUsingShaders(value: boolean);
  32145. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32146. get numBoneInfluencers(): number;
  32147. set numBoneInfluencers(value: number);
  32148. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32149. get applyFog(): boolean;
  32150. set applyFog(value: boolean);
  32151. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32152. useOctreeForRenderingSelection: boolean;
  32153. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32154. useOctreeForPicking: boolean;
  32155. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32156. useOctreeForCollisions: boolean;
  32157. /**
  32158. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32159. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32160. */
  32161. get layerMask(): number;
  32162. set layerMask(value: number);
  32163. /**
  32164. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32165. */
  32166. alwaysSelectAsActiveMesh: boolean;
  32167. /**
  32168. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32169. */
  32170. doNotSyncBoundingInfo: boolean;
  32171. /**
  32172. * Gets or sets the current action manager
  32173. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32174. */
  32175. actionManager: Nullable<AbstractActionManager>;
  32176. private _meshCollisionData;
  32177. /**
  32178. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32179. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32180. */
  32181. ellipsoid: Vector3;
  32182. /**
  32183. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32184. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32185. */
  32186. ellipsoidOffset: Vector3;
  32187. /**
  32188. * Gets or sets a collision mask used to mask collisions (default is -1).
  32189. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32190. */
  32191. get collisionMask(): number;
  32192. set collisionMask(mask: number);
  32193. /**
  32194. * Gets or sets the current collision group mask (-1 by default).
  32195. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32196. */
  32197. get collisionGroup(): number;
  32198. set collisionGroup(mask: number);
  32199. /**
  32200. * Gets or sets current surrounding meshes (null by default).
  32201. *
  32202. * By default collision detection is tested against every mesh in the scene.
  32203. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32204. * meshes will be tested for the collision.
  32205. *
  32206. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32207. */
  32208. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32209. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32210. /**
  32211. * Defines edge width used when edgesRenderer is enabled
  32212. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32213. */
  32214. edgesWidth: number;
  32215. /**
  32216. * Defines edge color used when edgesRenderer is enabled
  32217. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32218. */
  32219. edgesColor: Color4;
  32220. /** @hidden */
  32221. _edgesRenderer: Nullable<IEdgesRenderer>;
  32222. /** @hidden */
  32223. _masterMesh: Nullable<AbstractMesh>;
  32224. /** @hidden */
  32225. _boundingInfo: Nullable<BoundingInfo>;
  32226. /** @hidden */
  32227. _renderId: number;
  32228. /**
  32229. * Gets or sets the list of subMeshes
  32230. * @see https://doc.babylonjs.com/how_to/multi_materials
  32231. */
  32232. subMeshes: SubMesh[];
  32233. /** @hidden */
  32234. _intersectionsInProgress: AbstractMesh[];
  32235. /** @hidden */
  32236. _unIndexed: boolean;
  32237. /** @hidden */
  32238. _lightSources: Light[];
  32239. /** Gets the list of lights affecting that mesh */
  32240. get lightSources(): Light[];
  32241. /** @hidden */
  32242. get _positions(): Nullable<Vector3[]>;
  32243. /** @hidden */
  32244. _waitingData: {
  32245. lods: Nullable<any>;
  32246. actions: Nullable<any>;
  32247. freezeWorldMatrix: Nullable<boolean>;
  32248. };
  32249. /** @hidden */
  32250. _bonesTransformMatrices: Nullable<Float32Array>;
  32251. /** @hidden */
  32252. _transformMatrixTexture: Nullable<RawTexture>;
  32253. /**
  32254. * Gets or sets a skeleton to apply skining transformations
  32255. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32256. */
  32257. set skeleton(value: Nullable<Skeleton>);
  32258. get skeleton(): Nullable<Skeleton>;
  32259. /**
  32260. * An event triggered when the mesh is rebuilt.
  32261. */
  32262. onRebuildObservable: Observable<AbstractMesh>;
  32263. /**
  32264. * Creates a new AbstractMesh
  32265. * @param name defines the name of the mesh
  32266. * @param scene defines the hosting scene
  32267. */
  32268. constructor(name: string, scene?: Nullable<Scene>);
  32269. /**
  32270. * Returns the string "AbstractMesh"
  32271. * @returns "AbstractMesh"
  32272. */
  32273. getClassName(): string;
  32274. /**
  32275. * Gets a string representation of the current mesh
  32276. * @param fullDetails defines a boolean indicating if full details must be included
  32277. * @returns a string representation of the current mesh
  32278. */
  32279. toString(fullDetails?: boolean): string;
  32280. /**
  32281. * @hidden
  32282. */
  32283. protected _getEffectiveParent(): Nullable<Node>;
  32284. /** @hidden */
  32285. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32286. /** @hidden */
  32287. _rebuild(): void;
  32288. /** @hidden */
  32289. _resyncLightSources(): void;
  32290. /** @hidden */
  32291. _resyncLightSource(light: Light): void;
  32292. /** @hidden */
  32293. _unBindEffect(): void;
  32294. /** @hidden */
  32295. _removeLightSource(light: Light, dispose: boolean): void;
  32296. private _markSubMeshesAsDirty;
  32297. /** @hidden */
  32298. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32299. /** @hidden */
  32300. _markSubMeshesAsAttributesDirty(): void;
  32301. /** @hidden */
  32302. _markSubMeshesAsMiscDirty(): void;
  32303. /**
  32304. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32305. */
  32306. get scaling(): Vector3;
  32307. set scaling(newScaling: Vector3);
  32308. /**
  32309. * Returns true if the mesh is blocked. Implemented by child classes
  32310. */
  32311. get isBlocked(): boolean;
  32312. /**
  32313. * Returns the mesh itself by default. Implemented by child classes
  32314. * @param camera defines the camera to use to pick the right LOD level
  32315. * @returns the currentAbstractMesh
  32316. */
  32317. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32318. /**
  32319. * Returns 0 by default. Implemented by child classes
  32320. * @returns an integer
  32321. */
  32322. getTotalVertices(): number;
  32323. /**
  32324. * Returns a positive integer : the total number of indices in this mesh geometry.
  32325. * @returns the numner of indices or zero if the mesh has no geometry.
  32326. */
  32327. getTotalIndices(): number;
  32328. /**
  32329. * Returns null by default. Implemented by child classes
  32330. * @returns null
  32331. */
  32332. getIndices(): Nullable<IndicesArray>;
  32333. /**
  32334. * Returns the array of the requested vertex data kind. Implemented by child classes
  32335. * @param kind defines the vertex data kind to use
  32336. * @returns null
  32337. */
  32338. getVerticesData(kind: string): Nullable<FloatArray>;
  32339. /**
  32340. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32341. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32342. * Note that a new underlying VertexBuffer object is created each call.
  32343. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32344. * @param kind defines vertex data kind:
  32345. * * VertexBuffer.PositionKind
  32346. * * VertexBuffer.UVKind
  32347. * * VertexBuffer.UV2Kind
  32348. * * VertexBuffer.UV3Kind
  32349. * * VertexBuffer.UV4Kind
  32350. * * VertexBuffer.UV5Kind
  32351. * * VertexBuffer.UV6Kind
  32352. * * VertexBuffer.ColorKind
  32353. * * VertexBuffer.MatricesIndicesKind
  32354. * * VertexBuffer.MatricesIndicesExtraKind
  32355. * * VertexBuffer.MatricesWeightsKind
  32356. * * VertexBuffer.MatricesWeightsExtraKind
  32357. * @param data defines the data source
  32358. * @param updatable defines if the data must be flagged as updatable (or static)
  32359. * @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
  32360. * @returns the current mesh
  32361. */
  32362. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32363. /**
  32364. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32365. * If the mesh has no geometry, it is simply returned as it is.
  32366. * @param kind defines vertex data kind:
  32367. * * VertexBuffer.PositionKind
  32368. * * VertexBuffer.UVKind
  32369. * * VertexBuffer.UV2Kind
  32370. * * VertexBuffer.UV3Kind
  32371. * * VertexBuffer.UV4Kind
  32372. * * VertexBuffer.UV5Kind
  32373. * * VertexBuffer.UV6Kind
  32374. * * VertexBuffer.ColorKind
  32375. * * VertexBuffer.MatricesIndicesKind
  32376. * * VertexBuffer.MatricesIndicesExtraKind
  32377. * * VertexBuffer.MatricesWeightsKind
  32378. * * VertexBuffer.MatricesWeightsExtraKind
  32379. * @param data defines the data source
  32380. * @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
  32381. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32382. * @returns the current mesh
  32383. */
  32384. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32385. /**
  32386. * Sets the mesh indices,
  32387. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32388. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32389. * @param totalVertices Defines the total number of vertices
  32390. * @returns the current mesh
  32391. */
  32392. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32393. /**
  32394. * Gets a boolean indicating if specific vertex data is present
  32395. * @param kind defines the vertex data kind to use
  32396. * @returns true is data kind is present
  32397. */
  32398. isVerticesDataPresent(kind: string): boolean;
  32399. /**
  32400. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32401. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32402. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32403. * @returns a BoundingInfo
  32404. */
  32405. getBoundingInfo(): BoundingInfo;
  32406. /**
  32407. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32408. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32409. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32410. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32411. * @returns the current mesh
  32412. */
  32413. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32414. /**
  32415. * Overwrite the current bounding info
  32416. * @param boundingInfo defines the new bounding info
  32417. * @returns the current mesh
  32418. */
  32419. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32420. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32421. get useBones(): boolean;
  32422. /** @hidden */
  32423. _preActivate(): void;
  32424. /** @hidden */
  32425. _preActivateForIntermediateRendering(renderId: number): void;
  32426. /** @hidden */
  32427. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32428. /** @hidden */
  32429. _postActivate(): void;
  32430. /** @hidden */
  32431. _freeze(): void;
  32432. /** @hidden */
  32433. _unFreeze(): void;
  32434. /**
  32435. * Gets the current world matrix
  32436. * @returns a Matrix
  32437. */
  32438. getWorldMatrix(): Matrix;
  32439. /** @hidden */
  32440. _getWorldMatrixDeterminant(): number;
  32441. /**
  32442. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32443. */
  32444. get isAnInstance(): boolean;
  32445. /**
  32446. * Gets a boolean indicating if this mesh has instances
  32447. */
  32448. get hasInstances(): boolean;
  32449. /**
  32450. * Gets a boolean indicating if this mesh has thin instances
  32451. */
  32452. get hasThinInstances(): boolean;
  32453. /**
  32454. * Perform relative position change from the point of view of behind the front of the mesh.
  32455. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32456. * Supports definition of mesh facing forward or backward
  32457. * @param amountRight defines the distance on the right axis
  32458. * @param amountUp defines the distance on the up axis
  32459. * @param amountForward defines the distance on the forward axis
  32460. * @returns the current mesh
  32461. */
  32462. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32463. /**
  32464. * Calculate relative position change from the point of view of behind the front of the mesh.
  32465. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32466. * Supports definition of mesh facing forward or backward
  32467. * @param amountRight defines the distance on the right axis
  32468. * @param amountUp defines the distance on the up axis
  32469. * @param amountForward defines the distance on the forward axis
  32470. * @returns the new displacement vector
  32471. */
  32472. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32473. /**
  32474. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32475. * Supports definition of mesh facing forward or backward
  32476. * @param flipBack defines the flip
  32477. * @param twirlClockwise defines the twirl
  32478. * @param tiltRight defines the tilt
  32479. * @returns the current mesh
  32480. */
  32481. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32482. /**
  32483. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32484. * Supports definition of mesh facing forward or backward.
  32485. * @param flipBack defines the flip
  32486. * @param twirlClockwise defines the twirl
  32487. * @param tiltRight defines the tilt
  32488. * @returns the new rotation vector
  32489. */
  32490. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32491. /**
  32492. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32493. * This means the mesh underlying bounding box and sphere are recomputed.
  32494. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32495. * @returns the current mesh
  32496. */
  32497. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32498. /** @hidden */
  32499. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32500. /** @hidden */
  32501. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32502. /** @hidden */
  32503. _updateBoundingInfo(): AbstractMesh;
  32504. /** @hidden */
  32505. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32506. /** @hidden */
  32507. protected _afterComputeWorldMatrix(): void;
  32508. /** @hidden */
  32509. get _effectiveMesh(): AbstractMesh;
  32510. /**
  32511. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32512. * A mesh is in the frustum if its bounding box intersects the frustum
  32513. * @param frustumPlanes defines the frustum to test
  32514. * @returns true if the mesh is in the frustum planes
  32515. */
  32516. isInFrustum(frustumPlanes: Plane[]): boolean;
  32517. /**
  32518. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32519. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32520. * @param frustumPlanes defines the frustum to test
  32521. * @returns true if the mesh is completely in the frustum planes
  32522. */
  32523. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32524. /**
  32525. * True if the mesh intersects another mesh or a SolidParticle object
  32526. * @param mesh defines a target mesh or SolidParticle to test
  32527. * @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)
  32528. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32529. * @returns true if there is an intersection
  32530. */
  32531. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32532. /**
  32533. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32534. * @param point defines the point to test
  32535. * @returns true if there is an intersection
  32536. */
  32537. intersectsPoint(point: Vector3): boolean;
  32538. /**
  32539. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32540. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32541. */
  32542. get checkCollisions(): boolean;
  32543. set checkCollisions(collisionEnabled: boolean);
  32544. /**
  32545. * Gets Collider object used to compute collisions (not physics)
  32546. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32547. */
  32548. get collider(): Nullable<Collider>;
  32549. /**
  32550. * Move the mesh using collision engine
  32551. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32552. * @param displacement defines the requested displacement vector
  32553. * @returns the current mesh
  32554. */
  32555. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32556. private _onCollisionPositionChange;
  32557. /** @hidden */
  32558. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32559. /** @hidden */
  32560. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32561. /** @hidden */
  32562. _checkCollision(collider: Collider): AbstractMesh;
  32563. /** @hidden */
  32564. _generatePointsArray(): boolean;
  32565. /**
  32566. * Checks if the passed Ray intersects with the mesh
  32567. * @param ray defines the ray to use
  32568. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32569. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32570. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32571. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  32572. * @returns the picking info
  32573. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32574. */
  32575. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  32576. /**
  32577. * Clones the current mesh
  32578. * @param name defines the mesh name
  32579. * @param newParent defines the new mesh parent
  32580. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32581. * @returns the new mesh
  32582. */
  32583. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32584. /**
  32585. * Disposes all the submeshes of the current meshnp
  32586. * @returns the current mesh
  32587. */
  32588. releaseSubMeshes(): AbstractMesh;
  32589. /**
  32590. * Releases resources associated with this abstract mesh.
  32591. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32592. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32593. */
  32594. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32595. /**
  32596. * Adds the passed mesh as a child to the current mesh
  32597. * @param mesh defines the child mesh
  32598. * @returns the current mesh
  32599. */
  32600. addChild(mesh: AbstractMesh): AbstractMesh;
  32601. /**
  32602. * Removes the passed mesh from the current mesh children list
  32603. * @param mesh defines the child mesh
  32604. * @returns the current mesh
  32605. */
  32606. removeChild(mesh: AbstractMesh): AbstractMesh;
  32607. /** @hidden */
  32608. private _initFacetData;
  32609. /**
  32610. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32611. * This method can be called within the render loop.
  32612. * 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
  32613. * @returns the current mesh
  32614. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32615. */
  32616. updateFacetData(): AbstractMesh;
  32617. /**
  32618. * Returns the facetLocalNormals array.
  32619. * The normals are expressed in the mesh local spac
  32620. * @returns an array of Vector3
  32621. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32622. */
  32623. getFacetLocalNormals(): Vector3[];
  32624. /**
  32625. * Returns the facetLocalPositions array.
  32626. * The facet positions are expressed in the mesh local space
  32627. * @returns an array of Vector3
  32628. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32629. */
  32630. getFacetLocalPositions(): Vector3[];
  32631. /**
  32632. * Returns the facetLocalPartioning array
  32633. * @returns an array of array of numbers
  32634. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32635. */
  32636. getFacetLocalPartitioning(): number[][];
  32637. /**
  32638. * Returns the i-th facet position in the world system.
  32639. * This method allocates a new Vector3 per call
  32640. * @param i defines the facet index
  32641. * @returns a new Vector3
  32642. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32643. */
  32644. getFacetPosition(i: number): Vector3;
  32645. /**
  32646. * Sets the reference Vector3 with the i-th facet position in the world system
  32647. * @param i defines the facet index
  32648. * @param ref defines the target vector
  32649. * @returns the current mesh
  32650. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32651. */
  32652. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32653. /**
  32654. * Returns the i-th facet normal in the world system.
  32655. * This method allocates a new Vector3 per call
  32656. * @param i defines the facet index
  32657. * @returns a new Vector3
  32658. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32659. */
  32660. getFacetNormal(i: number): Vector3;
  32661. /**
  32662. * Sets the reference Vector3 with the i-th facet normal in the world system
  32663. * @param i defines the facet index
  32664. * @param ref defines the target vector
  32665. * @returns the current mesh
  32666. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32667. */
  32668. getFacetNormalToRef(i: number, ref: Vector3): this;
  32669. /**
  32670. * 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)
  32671. * @param x defines x coordinate
  32672. * @param y defines y coordinate
  32673. * @param z defines z coordinate
  32674. * @returns the array of facet indexes
  32675. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32676. */
  32677. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32678. /**
  32679. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32680. * @param projected sets as the (x,y,z) world projection on the facet
  32681. * @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
  32682. * @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
  32683. * @param x defines x coordinate
  32684. * @param y defines y coordinate
  32685. * @param z defines z coordinate
  32686. * @returns the face index if found (or null instead)
  32687. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32688. */
  32689. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32690. /**
  32691. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32692. * @param projected sets as the (x,y,z) local projection on the facet
  32693. * @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
  32694. * @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
  32695. * @param x defines x coordinate
  32696. * @param y defines y coordinate
  32697. * @param z defines z coordinate
  32698. * @returns the face index if found (or null instead)
  32699. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32700. */
  32701. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32702. /**
  32703. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32704. * @returns the parameters
  32705. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32706. */
  32707. getFacetDataParameters(): any;
  32708. /**
  32709. * Disables the feature FacetData and frees the related memory
  32710. * @returns the current mesh
  32711. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32712. */
  32713. disableFacetData(): AbstractMesh;
  32714. /**
  32715. * Updates the AbstractMesh indices array
  32716. * @param indices defines the data source
  32717. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32718. * @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)
  32719. * @returns the current mesh
  32720. */
  32721. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32722. /**
  32723. * Creates new normals data for the mesh
  32724. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32725. * @returns the current mesh
  32726. */
  32727. createNormals(updatable: boolean): AbstractMesh;
  32728. /**
  32729. * Align the mesh with a normal
  32730. * @param normal defines the normal to use
  32731. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32732. * @returns the current mesh
  32733. */
  32734. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32735. /** @hidden */
  32736. _checkOcclusionQuery(): boolean;
  32737. /**
  32738. * Disables the mesh edge rendering mode
  32739. * @returns the currentAbstractMesh
  32740. */
  32741. disableEdgesRendering(): AbstractMesh;
  32742. /**
  32743. * Enables the edge rendering mode on the mesh.
  32744. * This mode makes the mesh edges visible
  32745. * @param epsilon defines the maximal distance between two angles to detect a face
  32746. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32747. * @returns the currentAbstractMesh
  32748. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32749. */
  32750. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32751. /**
  32752. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  32753. * @returns an array of particle systems in the scene that use the mesh as an emitter
  32754. */
  32755. getConnectedParticleSystems(): IParticleSystem[];
  32756. }
  32757. }
  32758. declare module BABYLON {
  32759. /**
  32760. * Interface used to define ActionEvent
  32761. */
  32762. export interface IActionEvent {
  32763. /** The mesh or sprite that triggered the action */
  32764. source: any;
  32765. /** The X mouse cursor position at the time of the event */
  32766. pointerX: number;
  32767. /** The Y mouse cursor position at the time of the event */
  32768. pointerY: number;
  32769. /** The mesh that is currently pointed at (can be null) */
  32770. meshUnderPointer: Nullable<AbstractMesh>;
  32771. /** the original (browser) event that triggered the ActionEvent */
  32772. sourceEvent?: any;
  32773. /** additional data for the event */
  32774. additionalData?: any;
  32775. }
  32776. /**
  32777. * ActionEvent is the event being sent when an action is triggered.
  32778. */
  32779. export class ActionEvent implements IActionEvent {
  32780. /** The mesh or sprite that triggered the action */
  32781. source: any;
  32782. /** The X mouse cursor position at the time of the event */
  32783. pointerX: number;
  32784. /** The Y mouse cursor position at the time of the event */
  32785. pointerY: number;
  32786. /** The mesh that is currently pointed at (can be null) */
  32787. meshUnderPointer: Nullable<AbstractMesh>;
  32788. /** the original (browser) event that triggered the ActionEvent */
  32789. sourceEvent?: any;
  32790. /** additional data for the event */
  32791. additionalData?: any;
  32792. /**
  32793. * Creates a new ActionEvent
  32794. * @param source The mesh or sprite that triggered the action
  32795. * @param pointerX The X mouse cursor position at the time of the event
  32796. * @param pointerY The Y mouse cursor position at the time of the event
  32797. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32798. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32799. * @param additionalData additional data for the event
  32800. */
  32801. constructor(
  32802. /** The mesh or sprite that triggered the action */
  32803. source: any,
  32804. /** The X mouse cursor position at the time of the event */
  32805. pointerX: number,
  32806. /** The Y mouse cursor position at the time of the event */
  32807. pointerY: number,
  32808. /** The mesh that is currently pointed at (can be null) */
  32809. meshUnderPointer: Nullable<AbstractMesh>,
  32810. /** the original (browser) event that triggered the ActionEvent */
  32811. sourceEvent?: any,
  32812. /** additional data for the event */
  32813. additionalData?: any);
  32814. /**
  32815. * Helper function to auto-create an ActionEvent from a source mesh.
  32816. * @param source The source mesh that triggered the event
  32817. * @param evt The original (browser) event
  32818. * @param additionalData additional data for the event
  32819. * @returns the new ActionEvent
  32820. */
  32821. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32822. /**
  32823. * Helper function to auto-create an ActionEvent from a source sprite
  32824. * @param source The source sprite that triggered the event
  32825. * @param scene Scene associated with the sprite
  32826. * @param evt The original (browser) event
  32827. * @param additionalData additional data for the event
  32828. * @returns the new ActionEvent
  32829. */
  32830. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32831. /**
  32832. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32833. * @param scene the scene where the event occurred
  32834. * @param evt The original (browser) event
  32835. * @returns the new ActionEvent
  32836. */
  32837. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32838. /**
  32839. * Helper function to auto-create an ActionEvent from a primitive
  32840. * @param prim defines the target primitive
  32841. * @param pointerPos defines the pointer position
  32842. * @param evt The original (browser) event
  32843. * @param additionalData additional data for the event
  32844. * @returns the new ActionEvent
  32845. */
  32846. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32847. }
  32848. }
  32849. declare module BABYLON {
  32850. /**
  32851. * Abstract class used to decouple action Manager from scene and meshes.
  32852. * Do not instantiate.
  32853. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32854. */
  32855. export abstract class AbstractActionManager implements IDisposable {
  32856. /** Gets the list of active triggers */
  32857. static Triggers: {
  32858. [key: string]: number;
  32859. };
  32860. /** Gets the cursor to use when hovering items */
  32861. hoverCursor: string;
  32862. /** Gets the list of actions */
  32863. actions: IAction[];
  32864. /**
  32865. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  32866. */
  32867. isRecursive: boolean;
  32868. /**
  32869. * Releases all associated resources
  32870. */
  32871. abstract dispose(): void;
  32872. /**
  32873. * Does this action manager has pointer triggers
  32874. */
  32875. abstract get hasPointerTriggers(): boolean;
  32876. /**
  32877. * Does this action manager has pick triggers
  32878. */
  32879. abstract get hasPickTriggers(): boolean;
  32880. /**
  32881. * Process a specific trigger
  32882. * @param trigger defines the trigger to process
  32883. * @param evt defines the event details to be processed
  32884. */
  32885. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  32886. /**
  32887. * Does this action manager handles actions of any of the given triggers
  32888. * @param triggers defines the triggers to be tested
  32889. * @return a boolean indicating whether one (or more) of the triggers is handled
  32890. */
  32891. abstract hasSpecificTriggers(triggers: number[]): boolean;
  32892. /**
  32893. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  32894. * speed.
  32895. * @param triggerA defines the trigger to be tested
  32896. * @param triggerB defines the trigger to be tested
  32897. * @return a boolean indicating whether one (or more) of the triggers is handled
  32898. */
  32899. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  32900. /**
  32901. * Does this action manager handles actions of a given trigger
  32902. * @param trigger defines the trigger to be tested
  32903. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  32904. * @return whether the trigger is handled
  32905. */
  32906. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  32907. /**
  32908. * Serialize this manager to a JSON object
  32909. * @param name defines the property name to store this manager
  32910. * @returns a JSON representation of this manager
  32911. */
  32912. abstract serialize(name: string): any;
  32913. /**
  32914. * Registers an action to this action manager
  32915. * @param action defines the action to be registered
  32916. * @return the action amended (prepared) after registration
  32917. */
  32918. abstract registerAction(action: IAction): Nullable<IAction>;
  32919. /**
  32920. * Unregisters an action to this action manager
  32921. * @param action defines the action to be unregistered
  32922. * @return a boolean indicating whether the action has been unregistered
  32923. */
  32924. abstract unregisterAction(action: IAction): Boolean;
  32925. /**
  32926. * Does exist one action manager with at least one trigger
  32927. **/
  32928. static get HasTriggers(): boolean;
  32929. /**
  32930. * Does exist one action manager with at least one pick trigger
  32931. **/
  32932. static get HasPickTriggers(): boolean;
  32933. /**
  32934. * Does exist one action manager that handles actions of a given trigger
  32935. * @param trigger defines the trigger to be tested
  32936. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  32937. **/
  32938. static HasSpecificTrigger(trigger: number): boolean;
  32939. }
  32940. }
  32941. declare module BABYLON {
  32942. /**
  32943. * Defines how a node can be built from a string name.
  32944. */
  32945. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  32946. /**
  32947. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  32948. */
  32949. export class Node implements IBehaviorAware<Node> {
  32950. /** @hidden */
  32951. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  32952. private static _NodeConstructors;
  32953. /**
  32954. * Add a new node constructor
  32955. * @param type defines the type name of the node to construct
  32956. * @param constructorFunc defines the constructor function
  32957. */
  32958. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  32959. /**
  32960. * Returns a node constructor based on type name
  32961. * @param type defines the type name
  32962. * @param name defines the new node name
  32963. * @param scene defines the hosting scene
  32964. * @param options defines optional options to transmit to constructors
  32965. * @returns the new constructor or null
  32966. */
  32967. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  32968. /**
  32969. * Gets or sets the name of the node
  32970. */
  32971. name: string;
  32972. /**
  32973. * Gets or sets the id of the node
  32974. */
  32975. id: string;
  32976. /**
  32977. * Gets or sets the unique id of the node
  32978. */
  32979. uniqueId: number;
  32980. /**
  32981. * Gets or sets a string used to store user defined state for the node
  32982. */
  32983. state: string;
  32984. /**
  32985. * Gets or sets an object used to store user defined information for the node
  32986. */
  32987. metadata: any;
  32988. /**
  32989. * For internal use only. Please do not use.
  32990. */
  32991. reservedDataStore: any;
  32992. /**
  32993. * List of inspectable custom properties (used by the Inspector)
  32994. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  32995. */
  32996. inspectableCustomProperties: IInspectable[];
  32997. private _doNotSerialize;
  32998. /**
  32999. * Gets or sets a boolean used to define if the node must be serialized
  33000. */
  33001. get doNotSerialize(): boolean;
  33002. set doNotSerialize(value: boolean);
  33003. /** @hidden */
  33004. _isDisposed: boolean;
  33005. /**
  33006. * Gets a list of Animations associated with the node
  33007. */
  33008. animations: Animation[];
  33009. protected _ranges: {
  33010. [name: string]: Nullable<AnimationRange>;
  33011. };
  33012. /**
  33013. * Callback raised when the node is ready to be used
  33014. */
  33015. onReady: Nullable<(node: Node) => void>;
  33016. private _isEnabled;
  33017. private _isParentEnabled;
  33018. private _isReady;
  33019. /** @hidden */
  33020. _currentRenderId: number;
  33021. private _parentUpdateId;
  33022. /** @hidden */
  33023. _childUpdateId: number;
  33024. /** @hidden */
  33025. _waitingParentId: Nullable<string>;
  33026. /** @hidden */
  33027. _scene: Scene;
  33028. /** @hidden */
  33029. _cache: any;
  33030. private _parentNode;
  33031. private _children;
  33032. /** @hidden */
  33033. _worldMatrix: Matrix;
  33034. /** @hidden */
  33035. _worldMatrixDeterminant: number;
  33036. /** @hidden */
  33037. _worldMatrixDeterminantIsDirty: boolean;
  33038. /** @hidden */
  33039. private _sceneRootNodesIndex;
  33040. /**
  33041. * Gets a boolean indicating if the node has been disposed
  33042. * @returns true if the node was disposed
  33043. */
  33044. isDisposed(): boolean;
  33045. /**
  33046. * Gets or sets the parent of the node (without keeping the current position in the scene)
  33047. * @see https://doc.babylonjs.com/how_to/parenting
  33048. */
  33049. set parent(parent: Nullable<Node>);
  33050. get parent(): Nullable<Node>;
  33051. /** @hidden */
  33052. _addToSceneRootNodes(): void;
  33053. /** @hidden */
  33054. _removeFromSceneRootNodes(): void;
  33055. private _animationPropertiesOverride;
  33056. /**
  33057. * Gets or sets the animation properties override
  33058. */
  33059. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33060. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33061. /**
  33062. * Gets a string identifying the name of the class
  33063. * @returns "Node" string
  33064. */
  33065. getClassName(): string;
  33066. /** @hidden */
  33067. readonly _isNode: boolean;
  33068. /**
  33069. * An event triggered when the mesh is disposed
  33070. */
  33071. onDisposeObservable: Observable<Node>;
  33072. private _onDisposeObserver;
  33073. /**
  33074. * Sets a callback that will be raised when the node will be disposed
  33075. */
  33076. set onDispose(callback: () => void);
  33077. /**
  33078. * Creates a new Node
  33079. * @param name the name and id to be given to this node
  33080. * @param scene the scene this node will be added to
  33081. */
  33082. constructor(name: string, scene?: Nullable<Scene>);
  33083. /**
  33084. * Gets the scene of the node
  33085. * @returns a scene
  33086. */
  33087. getScene(): Scene;
  33088. /**
  33089. * Gets the engine of the node
  33090. * @returns a Engine
  33091. */
  33092. getEngine(): Engine;
  33093. private _behaviors;
  33094. /**
  33095. * Attach a behavior to the node
  33096. * @see https://doc.babylonjs.com/features/behaviour
  33097. * @param behavior defines the behavior to attach
  33098. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33099. * @returns the current Node
  33100. */
  33101. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33102. /**
  33103. * Remove an attached behavior
  33104. * @see https://doc.babylonjs.com/features/behaviour
  33105. * @param behavior defines the behavior to attach
  33106. * @returns the current Node
  33107. */
  33108. removeBehavior(behavior: Behavior<Node>): Node;
  33109. /**
  33110. * Gets the list of attached behaviors
  33111. * @see https://doc.babylonjs.com/features/behaviour
  33112. */
  33113. get behaviors(): Behavior<Node>[];
  33114. /**
  33115. * Gets an attached behavior by name
  33116. * @param name defines the name of the behavior to look for
  33117. * @see https://doc.babylonjs.com/features/behaviour
  33118. * @returns null if behavior was not found else the requested behavior
  33119. */
  33120. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33121. /**
  33122. * Returns the latest update of the World matrix
  33123. * @returns a Matrix
  33124. */
  33125. getWorldMatrix(): Matrix;
  33126. /** @hidden */
  33127. _getWorldMatrixDeterminant(): number;
  33128. /**
  33129. * Returns directly the latest state of the mesh World matrix.
  33130. * A Matrix is returned.
  33131. */
  33132. get worldMatrixFromCache(): Matrix;
  33133. /** @hidden */
  33134. _initCache(): void;
  33135. /** @hidden */
  33136. updateCache(force?: boolean): void;
  33137. /** @hidden */
  33138. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33139. /** @hidden */
  33140. _updateCache(ignoreParentClass?: boolean): void;
  33141. /** @hidden */
  33142. _isSynchronized(): boolean;
  33143. /** @hidden */
  33144. _markSyncedWithParent(): void;
  33145. /** @hidden */
  33146. isSynchronizedWithParent(): boolean;
  33147. /** @hidden */
  33148. isSynchronized(): boolean;
  33149. /**
  33150. * Is this node ready to be used/rendered
  33151. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33152. * @return true if the node is ready
  33153. */
  33154. isReady(completeCheck?: boolean): boolean;
  33155. /**
  33156. * Is this node enabled?
  33157. * 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
  33158. * @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
  33159. * @return whether this node (and its parent) is enabled
  33160. */
  33161. isEnabled(checkAncestors?: boolean): boolean;
  33162. /** @hidden */
  33163. protected _syncParentEnabledState(): void;
  33164. /**
  33165. * Set the enabled state of this node
  33166. * @param value defines the new enabled state
  33167. */
  33168. setEnabled(value: boolean): void;
  33169. /**
  33170. * Is this node a descendant of the given node?
  33171. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33172. * @param ancestor defines the parent node to inspect
  33173. * @returns a boolean indicating if this node is a descendant of the given node
  33174. */
  33175. isDescendantOf(ancestor: Node): boolean;
  33176. /** @hidden */
  33177. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33178. /**
  33179. * Will return all nodes that have this node as ascendant
  33180. * @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
  33181. * @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
  33182. * @return all children nodes of all types
  33183. */
  33184. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33185. /**
  33186. * Get all child-meshes of this node
  33187. * @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)
  33188. * @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
  33189. * @returns an array of AbstractMesh
  33190. */
  33191. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33192. /**
  33193. * Get all direct children of this node
  33194. * @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
  33195. * @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)
  33196. * @returns an array of Node
  33197. */
  33198. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33199. /** @hidden */
  33200. _setReady(state: boolean): void;
  33201. /**
  33202. * Get an animation by name
  33203. * @param name defines the name of the animation to look for
  33204. * @returns null if not found else the requested animation
  33205. */
  33206. getAnimationByName(name: string): Nullable<Animation>;
  33207. /**
  33208. * Creates an animation range for this node
  33209. * @param name defines the name of the range
  33210. * @param from defines the starting key
  33211. * @param to defines the end key
  33212. */
  33213. createAnimationRange(name: string, from: number, to: number): void;
  33214. /**
  33215. * Delete a specific animation range
  33216. * @param name defines the name of the range to delete
  33217. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33218. */
  33219. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33220. /**
  33221. * Get an animation range by name
  33222. * @param name defines the name of the animation range to look for
  33223. * @returns null if not found else the requested animation range
  33224. */
  33225. getAnimationRange(name: string): Nullable<AnimationRange>;
  33226. /**
  33227. * Gets the list of all animation ranges defined on this node
  33228. * @returns an array
  33229. */
  33230. getAnimationRanges(): Nullable<AnimationRange>[];
  33231. /**
  33232. * Will start the animation sequence
  33233. * @param name defines the range frames for animation sequence
  33234. * @param loop defines if the animation should loop (false by default)
  33235. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33236. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33237. * @returns the object created for this animation. If range does not exist, it will return null
  33238. */
  33239. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33240. /**
  33241. * Serialize animation ranges into a JSON compatible object
  33242. * @returns serialization object
  33243. */
  33244. serializeAnimationRanges(): any;
  33245. /**
  33246. * Computes the world matrix of the node
  33247. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33248. * @returns the world matrix
  33249. */
  33250. computeWorldMatrix(force?: boolean): Matrix;
  33251. /**
  33252. * Releases resources associated with this node.
  33253. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33254. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33255. */
  33256. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33257. /**
  33258. * Parse animation range data from a serialization object and store them into a given node
  33259. * @param node defines where to store the animation ranges
  33260. * @param parsedNode defines the serialization object to read data from
  33261. * @param scene defines the hosting scene
  33262. */
  33263. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33264. /**
  33265. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33266. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33267. * @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
  33268. * @returns the new bounding vectors
  33269. */
  33270. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33271. min: Vector3;
  33272. max: Vector3;
  33273. };
  33274. }
  33275. }
  33276. declare module BABYLON {
  33277. /**
  33278. * @hidden
  33279. */
  33280. export class _IAnimationState {
  33281. key: number;
  33282. repeatCount: number;
  33283. workValue?: any;
  33284. loopMode?: number;
  33285. offsetValue?: any;
  33286. highLimitValue?: any;
  33287. }
  33288. /**
  33289. * Class used to store any kind of animation
  33290. */
  33291. export class Animation {
  33292. /**Name of the animation */
  33293. name: string;
  33294. /**Property to animate */
  33295. targetProperty: string;
  33296. /**The frames per second of the animation */
  33297. framePerSecond: number;
  33298. /**The data type of the animation */
  33299. dataType: number;
  33300. /**The loop mode of the animation */
  33301. loopMode?: number | undefined;
  33302. /**Specifies if blending should be enabled */
  33303. enableBlending?: boolean | undefined;
  33304. /**
  33305. * Use matrix interpolation instead of using direct key value when animating matrices
  33306. */
  33307. static AllowMatricesInterpolation: boolean;
  33308. /**
  33309. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33310. */
  33311. static AllowMatrixDecomposeForInterpolation: boolean;
  33312. /** Define the Url to load snippets */
  33313. static SnippetUrl: string;
  33314. /** Snippet ID if the animation was created from the snippet server */
  33315. snippetId: string;
  33316. /**
  33317. * Stores the key frames of the animation
  33318. */
  33319. private _keys;
  33320. /**
  33321. * Stores the easing function of the animation
  33322. */
  33323. private _easingFunction;
  33324. /**
  33325. * @hidden Internal use only
  33326. */
  33327. _runtimeAnimations: RuntimeAnimation[];
  33328. /**
  33329. * The set of event that will be linked to this animation
  33330. */
  33331. private _events;
  33332. /**
  33333. * Stores an array of target property paths
  33334. */
  33335. targetPropertyPath: string[];
  33336. /**
  33337. * Stores the blending speed of the animation
  33338. */
  33339. blendingSpeed: number;
  33340. /**
  33341. * Stores the animation ranges for the animation
  33342. */
  33343. private _ranges;
  33344. /**
  33345. * @hidden Internal use
  33346. */
  33347. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33348. /**
  33349. * Sets up an animation
  33350. * @param property The property to animate
  33351. * @param animationType The animation type to apply
  33352. * @param framePerSecond The frames per second of the animation
  33353. * @param easingFunction The easing function used in the animation
  33354. * @returns The created animation
  33355. */
  33356. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33357. /**
  33358. * Create and start an animation on a node
  33359. * @param name defines the name of the global animation that will be run on all nodes
  33360. * @param node defines the root node where the animation will take place
  33361. * @param targetProperty defines property to animate
  33362. * @param framePerSecond defines the number of frame per second yo use
  33363. * @param totalFrame defines the number of frames in total
  33364. * @param from defines the initial value
  33365. * @param to defines the final value
  33366. * @param loopMode defines which loop mode you want to use (off by default)
  33367. * @param easingFunction defines the easing function to use (linear by default)
  33368. * @param onAnimationEnd defines the callback to call when animation end
  33369. * @returns the animatable created for this animation
  33370. */
  33371. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33372. /**
  33373. * Create and start an animation on a node and its descendants
  33374. * @param name defines the name of the global animation that will be run on all nodes
  33375. * @param node defines the root node where the animation will take place
  33376. * @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
  33377. * @param targetProperty defines property to animate
  33378. * @param framePerSecond defines the number of frame per second to use
  33379. * @param totalFrame defines the number of frames in total
  33380. * @param from defines the initial value
  33381. * @param to defines the final value
  33382. * @param loopMode defines which loop mode you want to use (off by default)
  33383. * @param easingFunction defines the easing function to use (linear by default)
  33384. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33385. * @returns the list of animatables created for all nodes
  33386. * @example https://www.babylonjs-playground.com/#MH0VLI
  33387. */
  33388. 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[]>;
  33389. /**
  33390. * Creates a new animation, merges it with the existing animations and starts it
  33391. * @param name Name of the animation
  33392. * @param node Node which contains the scene that begins the animations
  33393. * @param targetProperty Specifies which property to animate
  33394. * @param framePerSecond The frames per second of the animation
  33395. * @param totalFrame The total number of frames
  33396. * @param from The frame at the beginning of the animation
  33397. * @param to The frame at the end of the animation
  33398. * @param loopMode Specifies the loop mode of the animation
  33399. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33400. * @param onAnimationEnd Callback to run once the animation is complete
  33401. * @returns Nullable animation
  33402. */
  33403. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33404. /**
  33405. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33406. * @param sourceAnimation defines the Animation containing keyframes to convert
  33407. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33408. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33409. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33410. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33411. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33412. */
  33413. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33414. /**
  33415. * Transition property of an host to the target Value
  33416. * @param property The property to transition
  33417. * @param targetValue The target Value of the property
  33418. * @param host The object where the property to animate belongs
  33419. * @param scene Scene used to run the animation
  33420. * @param frameRate Framerate (in frame/s) to use
  33421. * @param transition The transition type we want to use
  33422. * @param duration The duration of the animation, in milliseconds
  33423. * @param onAnimationEnd Callback trigger at the end of the animation
  33424. * @returns Nullable animation
  33425. */
  33426. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33427. /**
  33428. * Return the array of runtime animations currently using this animation
  33429. */
  33430. get runtimeAnimations(): RuntimeAnimation[];
  33431. /**
  33432. * Specifies if any of the runtime animations are currently running
  33433. */
  33434. get hasRunningRuntimeAnimations(): boolean;
  33435. /**
  33436. * Initializes the animation
  33437. * @param name Name of the animation
  33438. * @param targetProperty Property to animate
  33439. * @param framePerSecond The frames per second of the animation
  33440. * @param dataType The data type of the animation
  33441. * @param loopMode The loop mode of the animation
  33442. * @param enableBlending Specifies if blending should be enabled
  33443. */
  33444. constructor(
  33445. /**Name of the animation */
  33446. name: string,
  33447. /**Property to animate */
  33448. targetProperty: string,
  33449. /**The frames per second of the animation */
  33450. framePerSecond: number,
  33451. /**The data type of the animation */
  33452. dataType: number,
  33453. /**The loop mode of the animation */
  33454. loopMode?: number | undefined,
  33455. /**Specifies if blending should be enabled */
  33456. enableBlending?: boolean | undefined);
  33457. /**
  33458. * Converts the animation to a string
  33459. * @param fullDetails support for multiple levels of logging within scene loading
  33460. * @returns String form of the animation
  33461. */
  33462. toString(fullDetails?: boolean): string;
  33463. /**
  33464. * Add an event to this animation
  33465. * @param event Event to add
  33466. */
  33467. addEvent(event: AnimationEvent): void;
  33468. /**
  33469. * Remove all events found at the given frame
  33470. * @param frame The frame to remove events from
  33471. */
  33472. removeEvents(frame: number): void;
  33473. /**
  33474. * Retrieves all the events from the animation
  33475. * @returns Events from the animation
  33476. */
  33477. getEvents(): AnimationEvent[];
  33478. /**
  33479. * Creates an animation range
  33480. * @param name Name of the animation range
  33481. * @param from Starting frame of the animation range
  33482. * @param to Ending frame of the animation
  33483. */
  33484. createRange(name: string, from: number, to: number): void;
  33485. /**
  33486. * Deletes an animation range by name
  33487. * @param name Name of the animation range to delete
  33488. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33489. */
  33490. deleteRange(name: string, deleteFrames?: boolean): void;
  33491. /**
  33492. * Gets the animation range by name, or null if not defined
  33493. * @param name Name of the animation range
  33494. * @returns Nullable animation range
  33495. */
  33496. getRange(name: string): Nullable<AnimationRange>;
  33497. /**
  33498. * Gets the key frames from the animation
  33499. * @returns The key frames of the animation
  33500. */
  33501. getKeys(): Array<IAnimationKey>;
  33502. /**
  33503. * Gets the highest frame rate of the animation
  33504. * @returns Highest frame rate of the animation
  33505. */
  33506. getHighestFrame(): number;
  33507. /**
  33508. * Gets the easing function of the animation
  33509. * @returns Easing function of the animation
  33510. */
  33511. getEasingFunction(): IEasingFunction;
  33512. /**
  33513. * Sets the easing function of the animation
  33514. * @param easingFunction A custom mathematical formula for animation
  33515. */
  33516. setEasingFunction(easingFunction: EasingFunction): void;
  33517. /**
  33518. * Interpolates a scalar linearly
  33519. * @param startValue Start value of the animation curve
  33520. * @param endValue End value of the animation curve
  33521. * @param gradient Scalar amount to interpolate
  33522. * @returns Interpolated scalar value
  33523. */
  33524. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33525. /**
  33526. * Interpolates a scalar cubically
  33527. * @param startValue Start value of the animation curve
  33528. * @param outTangent End tangent of the animation
  33529. * @param endValue End value of the animation curve
  33530. * @param inTangent Start tangent of the animation curve
  33531. * @param gradient Scalar amount to interpolate
  33532. * @returns Interpolated scalar value
  33533. */
  33534. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33535. /**
  33536. * Interpolates a quaternion using a spherical linear interpolation
  33537. * @param startValue Start value of the animation curve
  33538. * @param endValue End value of the animation curve
  33539. * @param gradient Scalar amount to interpolate
  33540. * @returns Interpolated quaternion value
  33541. */
  33542. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33543. /**
  33544. * Interpolates a quaternion cubically
  33545. * @param startValue Start value of the animation curve
  33546. * @param outTangent End tangent of the animation curve
  33547. * @param endValue End value of the animation curve
  33548. * @param inTangent Start tangent of the animation curve
  33549. * @param gradient Scalar amount to interpolate
  33550. * @returns Interpolated quaternion value
  33551. */
  33552. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33553. /**
  33554. * Interpolates a Vector3 linearl
  33555. * @param startValue Start value of the animation curve
  33556. * @param endValue End value of the animation curve
  33557. * @param gradient Scalar amount to interpolate
  33558. * @returns Interpolated scalar value
  33559. */
  33560. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33561. /**
  33562. * Interpolates a Vector3 cubically
  33563. * @param startValue Start value of the animation curve
  33564. * @param outTangent End tangent of the animation
  33565. * @param endValue End value of the animation curve
  33566. * @param inTangent Start tangent of the animation curve
  33567. * @param gradient Scalar amount to interpolate
  33568. * @returns InterpolatedVector3 value
  33569. */
  33570. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33571. /**
  33572. * Interpolates a Vector2 linearly
  33573. * @param startValue Start value of the animation curve
  33574. * @param endValue End value of the animation curve
  33575. * @param gradient Scalar amount to interpolate
  33576. * @returns Interpolated Vector2 value
  33577. */
  33578. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33579. /**
  33580. * Interpolates a Vector2 cubically
  33581. * @param startValue Start value of the animation curve
  33582. * @param outTangent End tangent of the animation
  33583. * @param endValue End value of the animation curve
  33584. * @param inTangent Start tangent of the animation curve
  33585. * @param gradient Scalar amount to interpolate
  33586. * @returns Interpolated Vector2 value
  33587. */
  33588. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33589. /**
  33590. * Interpolates a size linearly
  33591. * @param startValue Start value of the animation curve
  33592. * @param endValue End value of the animation curve
  33593. * @param gradient Scalar amount to interpolate
  33594. * @returns Interpolated Size value
  33595. */
  33596. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33597. /**
  33598. * Interpolates a Color3 linearly
  33599. * @param startValue Start value of the animation curve
  33600. * @param endValue End value of the animation curve
  33601. * @param gradient Scalar amount to interpolate
  33602. * @returns Interpolated Color3 value
  33603. */
  33604. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33605. /**
  33606. * Interpolates a Color4 linearly
  33607. * @param startValue Start value of the animation curve
  33608. * @param endValue End value of the animation curve
  33609. * @param gradient Scalar amount to interpolate
  33610. * @returns Interpolated Color3 value
  33611. */
  33612. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33613. /**
  33614. * @hidden Internal use only
  33615. */
  33616. _getKeyValue(value: any): any;
  33617. /**
  33618. * @hidden Internal use only
  33619. */
  33620. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33621. /**
  33622. * Defines the function to use to interpolate matrices
  33623. * @param startValue defines the start matrix
  33624. * @param endValue defines the end matrix
  33625. * @param gradient defines the gradient between both matrices
  33626. * @param result defines an optional target matrix where to store the interpolation
  33627. * @returns the interpolated matrix
  33628. */
  33629. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33630. /**
  33631. * Makes a copy of the animation
  33632. * @returns Cloned animation
  33633. */
  33634. clone(): Animation;
  33635. /**
  33636. * Sets the key frames of the animation
  33637. * @param values The animation key frames to set
  33638. */
  33639. setKeys(values: Array<IAnimationKey>): void;
  33640. /**
  33641. * Serializes the animation to an object
  33642. * @returns Serialized object
  33643. */
  33644. serialize(): any;
  33645. /**
  33646. * Float animation type
  33647. */
  33648. static readonly ANIMATIONTYPE_FLOAT: number;
  33649. /**
  33650. * Vector3 animation type
  33651. */
  33652. static readonly ANIMATIONTYPE_VECTOR3: number;
  33653. /**
  33654. * Quaternion animation type
  33655. */
  33656. static readonly ANIMATIONTYPE_QUATERNION: number;
  33657. /**
  33658. * Matrix animation type
  33659. */
  33660. static readonly ANIMATIONTYPE_MATRIX: number;
  33661. /**
  33662. * Color3 animation type
  33663. */
  33664. static readonly ANIMATIONTYPE_COLOR3: number;
  33665. /**
  33666. * Color3 animation type
  33667. */
  33668. static readonly ANIMATIONTYPE_COLOR4: number;
  33669. /**
  33670. * Vector2 animation type
  33671. */
  33672. static readonly ANIMATIONTYPE_VECTOR2: number;
  33673. /**
  33674. * Size animation type
  33675. */
  33676. static readonly ANIMATIONTYPE_SIZE: number;
  33677. /**
  33678. * Relative Loop Mode
  33679. */
  33680. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33681. /**
  33682. * Cycle Loop Mode
  33683. */
  33684. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33685. /**
  33686. * Constant Loop Mode
  33687. */
  33688. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33689. /** @hidden */
  33690. static _UniversalLerp(left: any, right: any, amount: number): any;
  33691. /**
  33692. * Parses an animation object and creates an animation
  33693. * @param parsedAnimation Parsed animation object
  33694. * @returns Animation object
  33695. */
  33696. static Parse(parsedAnimation: any): Animation;
  33697. /**
  33698. * Appends the serialized animations from the source animations
  33699. * @param source Source containing the animations
  33700. * @param destination Target to store the animations
  33701. */
  33702. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33703. /**
  33704. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33705. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33706. * @param url defines the url to load from
  33707. * @returns a promise that will resolve to the new animation or an array of animations
  33708. */
  33709. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33710. /**
  33711. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33712. * @param snippetId defines the snippet to load
  33713. * @returns a promise that will resolve to the new animation or a new array of animations
  33714. */
  33715. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33716. }
  33717. }
  33718. declare module BABYLON {
  33719. /**
  33720. * Interface containing an array of animations
  33721. */
  33722. export interface IAnimatable {
  33723. /**
  33724. * Array of animations
  33725. */
  33726. animations: Nullable<Array<Animation>>;
  33727. }
  33728. }
  33729. declare module BABYLON {
  33730. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33731. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33732. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33733. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33734. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33735. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33736. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33737. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33738. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33739. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33740. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33741. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33742. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33743. /**
  33744. * Decorator used to define property that can be serialized as reference to a camera
  33745. * @param sourceName defines the name of the property to decorate
  33746. */
  33747. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33748. /**
  33749. * Class used to help serialization objects
  33750. */
  33751. export class SerializationHelper {
  33752. /** @hidden */
  33753. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  33754. /** @hidden */
  33755. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  33756. /** @hidden */
  33757. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  33758. /** @hidden */
  33759. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  33760. /**
  33761. * Appends the serialized animations from the source animations
  33762. * @param source Source containing the animations
  33763. * @param destination Target to store the animations
  33764. */
  33765. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33766. /**
  33767. * Static function used to serialized a specific entity
  33768. * @param entity defines the entity to serialize
  33769. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33770. * @returns a JSON compatible object representing the serialization of the entity
  33771. */
  33772. static Serialize<T>(entity: T, serializationObject?: any): any;
  33773. /**
  33774. * Creates a new entity from a serialization data object
  33775. * @param creationFunction defines a function used to instanciated the new entity
  33776. * @param source defines the source serialization data
  33777. * @param scene defines the hosting scene
  33778. * @param rootUrl defines the root url for resources
  33779. * @returns a new entity
  33780. */
  33781. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33782. /**
  33783. * Clones an object
  33784. * @param creationFunction defines the function used to instanciate the new object
  33785. * @param source defines the source object
  33786. * @returns the cloned object
  33787. */
  33788. static Clone<T>(creationFunction: () => T, source: T): T;
  33789. /**
  33790. * Instanciates a new object based on a source one (some data will be shared between both object)
  33791. * @param creationFunction defines the function used to instanciate the new object
  33792. * @param source defines the source object
  33793. * @returns the new object
  33794. */
  33795. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33796. }
  33797. }
  33798. declare module BABYLON {
  33799. /**
  33800. * Base class of all the textures in babylon.
  33801. * It groups all the common properties the materials, post process, lights... might need
  33802. * in order to make a correct use of the texture.
  33803. */
  33804. export class BaseTexture implements IAnimatable {
  33805. /**
  33806. * Default anisotropic filtering level for the application.
  33807. * It is set to 4 as a good tradeoff between perf and quality.
  33808. */
  33809. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33810. /**
  33811. * Gets or sets the unique id of the texture
  33812. */
  33813. uniqueId: number;
  33814. /**
  33815. * Define the name of the texture.
  33816. */
  33817. name: string;
  33818. /**
  33819. * Gets or sets an object used to store user defined information.
  33820. */
  33821. metadata: any;
  33822. /**
  33823. * For internal use only. Please do not use.
  33824. */
  33825. reservedDataStore: any;
  33826. private _hasAlpha;
  33827. /**
  33828. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  33829. */
  33830. set hasAlpha(value: boolean);
  33831. get hasAlpha(): boolean;
  33832. /**
  33833. * Defines if the alpha value should be determined via the rgb values.
  33834. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  33835. */
  33836. getAlphaFromRGB: boolean;
  33837. /**
  33838. * Intensity or strength of the texture.
  33839. * It is commonly used by materials to fine tune the intensity of the texture
  33840. */
  33841. level: number;
  33842. /**
  33843. * Define the UV chanel to use starting from 0 and defaulting to 0.
  33844. * This is part of the texture as textures usually maps to one uv set.
  33845. */
  33846. coordinatesIndex: number;
  33847. private _coordinatesMode;
  33848. /**
  33849. * How a texture is mapped.
  33850. *
  33851. * | Value | Type | Description |
  33852. * | ----- | ----------------------------------- | ----------- |
  33853. * | 0 | EXPLICIT_MODE | |
  33854. * | 1 | SPHERICAL_MODE | |
  33855. * | 2 | PLANAR_MODE | |
  33856. * | 3 | CUBIC_MODE | |
  33857. * | 4 | PROJECTION_MODE | |
  33858. * | 5 | SKYBOX_MODE | |
  33859. * | 6 | INVCUBIC_MODE | |
  33860. * | 7 | EQUIRECTANGULAR_MODE | |
  33861. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33862. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33863. */
  33864. set coordinatesMode(value: number);
  33865. get coordinatesMode(): number;
  33866. /**
  33867. * | Value | Type | Description |
  33868. * | ----- | ------------------ | ----------- |
  33869. * | 0 | CLAMP_ADDRESSMODE | |
  33870. * | 1 | WRAP_ADDRESSMODE | |
  33871. * | 2 | MIRROR_ADDRESSMODE | |
  33872. */
  33873. wrapU: number;
  33874. /**
  33875. * | Value | Type | Description |
  33876. * | ----- | ------------------ | ----------- |
  33877. * | 0 | CLAMP_ADDRESSMODE | |
  33878. * | 1 | WRAP_ADDRESSMODE | |
  33879. * | 2 | MIRROR_ADDRESSMODE | |
  33880. */
  33881. wrapV: number;
  33882. /**
  33883. * | Value | Type | Description |
  33884. * | ----- | ------------------ | ----------- |
  33885. * | 0 | CLAMP_ADDRESSMODE | |
  33886. * | 1 | WRAP_ADDRESSMODE | |
  33887. * | 2 | MIRROR_ADDRESSMODE | |
  33888. */
  33889. wrapR: number;
  33890. /**
  33891. * With compliant hardware and browser (supporting anisotropic filtering)
  33892. * this defines the level of anisotropic filtering in the texture.
  33893. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  33894. */
  33895. anisotropicFilteringLevel: number;
  33896. /**
  33897. * Define if the texture is a cube texture or if false a 2d texture.
  33898. */
  33899. get isCube(): boolean;
  33900. set isCube(value: boolean);
  33901. /**
  33902. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  33903. */
  33904. get is3D(): boolean;
  33905. set is3D(value: boolean);
  33906. /**
  33907. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  33908. */
  33909. get is2DArray(): boolean;
  33910. set is2DArray(value: boolean);
  33911. /**
  33912. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  33913. * HDR texture are usually stored in linear space.
  33914. * This only impacts the PBR and Background materials
  33915. */
  33916. gammaSpace: boolean;
  33917. /**
  33918. * Gets or sets whether or not the texture contains RGBD data.
  33919. */
  33920. get isRGBD(): boolean;
  33921. set isRGBD(value: boolean);
  33922. /**
  33923. * Is Z inverted in the texture (useful in a cube texture).
  33924. */
  33925. invertZ: boolean;
  33926. /**
  33927. * Are mip maps generated for this texture or not.
  33928. */
  33929. get noMipmap(): boolean;
  33930. /**
  33931. * @hidden
  33932. */
  33933. lodLevelInAlpha: boolean;
  33934. /**
  33935. * With prefiltered texture, defined the offset used during the prefiltering steps.
  33936. */
  33937. get lodGenerationOffset(): number;
  33938. set lodGenerationOffset(value: number);
  33939. /**
  33940. * With prefiltered texture, defined the scale used during the prefiltering steps.
  33941. */
  33942. get lodGenerationScale(): number;
  33943. set lodGenerationScale(value: number);
  33944. /**
  33945. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  33946. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  33947. * average roughness values.
  33948. */
  33949. get linearSpecularLOD(): boolean;
  33950. set linearSpecularLOD(value: boolean);
  33951. /**
  33952. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  33953. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  33954. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  33955. */
  33956. get irradianceTexture(): Nullable<BaseTexture>;
  33957. set irradianceTexture(value: Nullable<BaseTexture>);
  33958. /**
  33959. * Define if the texture is a render target.
  33960. */
  33961. isRenderTarget: boolean;
  33962. /**
  33963. * Define the unique id of the texture in the scene.
  33964. */
  33965. get uid(): string;
  33966. /** @hidden */
  33967. _prefiltered: boolean;
  33968. /**
  33969. * Return a string representation of the texture.
  33970. * @returns the texture as a string
  33971. */
  33972. toString(): string;
  33973. /**
  33974. * Get the class name of the texture.
  33975. * @returns "BaseTexture"
  33976. */
  33977. getClassName(): string;
  33978. /**
  33979. * Define the list of animation attached to the texture.
  33980. */
  33981. animations: Animation[];
  33982. /**
  33983. * An event triggered when the texture is disposed.
  33984. */
  33985. onDisposeObservable: Observable<BaseTexture>;
  33986. private _onDisposeObserver;
  33987. /**
  33988. * Callback triggered when the texture has been disposed.
  33989. * Kept for back compatibility, you can use the onDisposeObservable instead.
  33990. */
  33991. set onDispose(callback: () => void);
  33992. /**
  33993. * Define the current state of the loading sequence when in delayed load mode.
  33994. */
  33995. delayLoadState: number;
  33996. protected _scene: Nullable<Scene>;
  33997. protected _engine: Nullable<ThinEngine>;
  33998. /** @hidden */
  33999. _texture: Nullable<InternalTexture>;
  34000. private _uid;
  34001. /**
  34002. * Define if the texture is preventinga material to render or not.
  34003. * If not and the texture is not ready, the engine will use a default black texture instead.
  34004. */
  34005. get isBlocking(): boolean;
  34006. /**
  34007. * Instantiates a new BaseTexture.
  34008. * Base class of all the textures in babylon.
  34009. * It groups all the common properties the materials, post process, lights... might need
  34010. * in order to make a correct use of the texture.
  34011. * @param sceneOrEngine Define the scene or engine the texture blongs to
  34012. */
  34013. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  34014. /**
  34015. * Get the scene the texture belongs to.
  34016. * @returns the scene or null if undefined
  34017. */
  34018. getScene(): Nullable<Scene>;
  34019. /** @hidden */
  34020. protected _getEngine(): Nullable<ThinEngine>;
  34021. /**
  34022. * Get the texture transform matrix used to offset tile the texture for istance.
  34023. * @returns the transformation matrix
  34024. */
  34025. getTextureMatrix(): Matrix;
  34026. /**
  34027. * Get the texture reflection matrix used to rotate/transform the reflection.
  34028. * @returns the reflection matrix
  34029. */
  34030. getReflectionTextureMatrix(): Matrix;
  34031. /**
  34032. * Get the underlying lower level texture from Babylon.
  34033. * @returns the insternal texture
  34034. */
  34035. getInternalTexture(): Nullable<InternalTexture>;
  34036. /**
  34037. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  34038. * @returns true if ready or not blocking
  34039. */
  34040. isReadyOrNotBlocking(): boolean;
  34041. /**
  34042. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  34043. * @returns true if fully ready
  34044. */
  34045. isReady(): boolean;
  34046. private _cachedSize;
  34047. /**
  34048. * Get the size of the texture.
  34049. * @returns the texture size.
  34050. */
  34051. getSize(): ISize;
  34052. /**
  34053. * Get the base size of the texture.
  34054. * It can be different from the size if the texture has been resized for POT for instance
  34055. * @returns the base size
  34056. */
  34057. getBaseSize(): ISize;
  34058. /**
  34059. * Update the sampling mode of the texture.
  34060. * Default is Trilinear mode.
  34061. *
  34062. * | Value | Type | Description |
  34063. * | ----- | ------------------ | ----------- |
  34064. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  34065. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  34066. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  34067. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  34068. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  34069. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  34070. * | 7 | NEAREST_LINEAR | |
  34071. * | 8 | NEAREST_NEAREST | |
  34072. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  34073. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  34074. * | 11 | LINEAR_LINEAR | |
  34075. * | 12 | LINEAR_NEAREST | |
  34076. *
  34077. * > _mag_: magnification filter (close to the viewer)
  34078. * > _min_: minification filter (far from the viewer)
  34079. * > _mip_: filter used between mip map levels
  34080. *@param samplingMode Define the new sampling mode of the texture
  34081. */
  34082. updateSamplingMode(samplingMode: number): void;
  34083. /**
  34084. * Scales the texture if is `canRescale()`
  34085. * @param ratio the resize factor we want to use to rescale
  34086. */
  34087. scale(ratio: number): void;
  34088. /**
  34089. * Get if the texture can rescale.
  34090. */
  34091. get canRescale(): boolean;
  34092. /** @hidden */
  34093. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34094. /** @hidden */
  34095. _rebuild(): void;
  34096. /**
  34097. * Triggers the load sequence in delayed load mode.
  34098. */
  34099. delayLoad(): void;
  34100. /**
  34101. * Clones the texture.
  34102. * @returns the cloned texture
  34103. */
  34104. clone(): Nullable<BaseTexture>;
  34105. /**
  34106. * Get the texture underlying type (INT, FLOAT...)
  34107. */
  34108. get textureType(): number;
  34109. /**
  34110. * Get the texture underlying format (RGB, RGBA...)
  34111. */
  34112. get textureFormat(): number;
  34113. /**
  34114. * Indicates that textures need to be re-calculated for all materials
  34115. */
  34116. protected _markAllSubMeshesAsTexturesDirty(): void;
  34117. /**
  34118. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34119. * This will returns an RGBA array buffer containing either in values (0-255) or
  34120. * float values (0-1) depending of the underlying buffer type.
  34121. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34122. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34123. * @param buffer defines a user defined buffer to fill with data (can be null)
  34124. * @returns The Array buffer containing the pixels data.
  34125. */
  34126. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34127. /**
  34128. * Release and destroy the underlying lower level texture aka internalTexture.
  34129. */
  34130. releaseInternalTexture(): void;
  34131. /** @hidden */
  34132. get _lodTextureHigh(): Nullable<BaseTexture>;
  34133. /** @hidden */
  34134. get _lodTextureMid(): Nullable<BaseTexture>;
  34135. /** @hidden */
  34136. get _lodTextureLow(): Nullable<BaseTexture>;
  34137. /**
  34138. * Dispose the texture and release its associated resources.
  34139. */
  34140. dispose(): void;
  34141. /**
  34142. * Serialize the texture into a JSON representation that can be parsed later on.
  34143. * @returns the JSON representation of the texture
  34144. */
  34145. serialize(): any;
  34146. /**
  34147. * Helper function to be called back once a list of texture contains only ready textures.
  34148. * @param textures Define the list of textures to wait for
  34149. * @param callback Define the callback triggered once the entire list will be ready
  34150. */
  34151. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34152. private static _isScene;
  34153. }
  34154. }
  34155. declare module BABYLON {
  34156. /**
  34157. * Options to be used when creating an effect.
  34158. */
  34159. export interface IEffectCreationOptions {
  34160. /**
  34161. * Atrributes that will be used in the shader.
  34162. */
  34163. attributes: string[];
  34164. /**
  34165. * Uniform varible names that will be set in the shader.
  34166. */
  34167. uniformsNames: string[];
  34168. /**
  34169. * Uniform buffer variable names that will be set in the shader.
  34170. */
  34171. uniformBuffersNames: string[];
  34172. /**
  34173. * Sampler texture variable names that will be set in the shader.
  34174. */
  34175. samplers: string[];
  34176. /**
  34177. * Define statements that will be set in the shader.
  34178. */
  34179. defines: any;
  34180. /**
  34181. * Possible fallbacks for this effect to improve performance when needed.
  34182. */
  34183. fallbacks: Nullable<IEffectFallbacks>;
  34184. /**
  34185. * Callback that will be called when the shader is compiled.
  34186. */
  34187. onCompiled: Nullable<(effect: Effect) => void>;
  34188. /**
  34189. * Callback that will be called if an error occurs during shader compilation.
  34190. */
  34191. onError: Nullable<(effect: Effect, errors: string) => void>;
  34192. /**
  34193. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34194. */
  34195. indexParameters?: any;
  34196. /**
  34197. * Max number of lights that can be used in the shader.
  34198. */
  34199. maxSimultaneousLights?: number;
  34200. /**
  34201. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34202. */
  34203. transformFeedbackVaryings?: Nullable<string[]>;
  34204. /**
  34205. * 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
  34206. */
  34207. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34208. /**
  34209. * Is this effect rendering to several color attachments ?
  34210. */
  34211. multiTarget?: boolean;
  34212. }
  34213. /**
  34214. * Effect containing vertex and fragment shader that can be executed on an object.
  34215. */
  34216. export class Effect implements IDisposable {
  34217. /**
  34218. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34219. */
  34220. static ShadersRepository: string;
  34221. /**
  34222. * Enable logging of the shader code when a compilation error occurs
  34223. */
  34224. static LogShaderCodeOnCompilationError: boolean;
  34225. /**
  34226. * Name of the effect.
  34227. */
  34228. name: any;
  34229. /**
  34230. * String container all the define statements that should be set on the shader.
  34231. */
  34232. defines: string;
  34233. /**
  34234. * Callback that will be called when the shader is compiled.
  34235. */
  34236. onCompiled: Nullable<(effect: Effect) => void>;
  34237. /**
  34238. * Callback that will be called if an error occurs during shader compilation.
  34239. */
  34240. onError: Nullable<(effect: Effect, errors: string) => void>;
  34241. /**
  34242. * Callback that will be called when effect is bound.
  34243. */
  34244. onBind: Nullable<(effect: Effect) => void>;
  34245. /**
  34246. * Unique ID of the effect.
  34247. */
  34248. uniqueId: number;
  34249. /**
  34250. * Observable that will be called when the shader is compiled.
  34251. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34252. */
  34253. onCompileObservable: Observable<Effect>;
  34254. /**
  34255. * Observable that will be called if an error occurs during shader compilation.
  34256. */
  34257. onErrorObservable: Observable<Effect>;
  34258. /** @hidden */
  34259. _onBindObservable: Nullable<Observable<Effect>>;
  34260. /**
  34261. * @hidden
  34262. * Specifies if the effect was previously ready
  34263. */
  34264. _wasPreviouslyReady: boolean;
  34265. /**
  34266. * Observable that will be called when effect is bound.
  34267. */
  34268. get onBindObservable(): Observable<Effect>;
  34269. /** @hidden */
  34270. _bonesComputationForcedToCPU: boolean;
  34271. /** @hidden */
  34272. _multiTarget: boolean;
  34273. private static _uniqueIdSeed;
  34274. private _engine;
  34275. private _uniformBuffersNames;
  34276. private _uniformBuffersNamesList;
  34277. private _uniformsNames;
  34278. private _samplerList;
  34279. private _samplers;
  34280. private _isReady;
  34281. private _compilationError;
  34282. private _allFallbacksProcessed;
  34283. private _attributesNames;
  34284. private _attributes;
  34285. private _attributeLocationByName;
  34286. private _uniforms;
  34287. /**
  34288. * Key for the effect.
  34289. * @hidden
  34290. */
  34291. _key: string;
  34292. private _indexParameters;
  34293. private _fallbacks;
  34294. private _vertexSourceCode;
  34295. private _fragmentSourceCode;
  34296. private _vertexSourceCodeOverride;
  34297. private _fragmentSourceCodeOverride;
  34298. private _transformFeedbackVaryings;
  34299. /**
  34300. * Compiled shader to webGL program.
  34301. * @hidden
  34302. */
  34303. _pipelineContext: Nullable<IPipelineContext>;
  34304. private _valueCache;
  34305. private static _baseCache;
  34306. /**
  34307. * Instantiates an effect.
  34308. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34309. * @param baseName Name of the effect.
  34310. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34311. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34312. * @param samplers List of sampler variables that will be passed to the shader.
  34313. * @param engine Engine to be used to render the effect
  34314. * @param defines Define statements to be added to the shader.
  34315. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34316. * @param onCompiled Callback that will be called when the shader is compiled.
  34317. * @param onError Callback that will be called if an error occurs during shader compilation.
  34318. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34319. */
  34320. 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);
  34321. private _useFinalCode;
  34322. /**
  34323. * Unique key for this effect
  34324. */
  34325. get key(): string;
  34326. /**
  34327. * If the effect has been compiled and prepared.
  34328. * @returns if the effect is compiled and prepared.
  34329. */
  34330. isReady(): boolean;
  34331. private _isReadyInternal;
  34332. /**
  34333. * The engine the effect was initialized with.
  34334. * @returns the engine.
  34335. */
  34336. getEngine(): Engine;
  34337. /**
  34338. * The pipeline context for this effect
  34339. * @returns the associated pipeline context
  34340. */
  34341. getPipelineContext(): Nullable<IPipelineContext>;
  34342. /**
  34343. * The set of names of attribute variables for the shader.
  34344. * @returns An array of attribute names.
  34345. */
  34346. getAttributesNames(): string[];
  34347. /**
  34348. * Returns the attribute at the given index.
  34349. * @param index The index of the attribute.
  34350. * @returns The location of the attribute.
  34351. */
  34352. getAttributeLocation(index: number): number;
  34353. /**
  34354. * Returns the attribute based on the name of the variable.
  34355. * @param name of the attribute to look up.
  34356. * @returns the attribute location.
  34357. */
  34358. getAttributeLocationByName(name: string): number;
  34359. /**
  34360. * The number of attributes.
  34361. * @returns the numnber of attributes.
  34362. */
  34363. getAttributesCount(): number;
  34364. /**
  34365. * Gets the index of a uniform variable.
  34366. * @param uniformName of the uniform to look up.
  34367. * @returns the index.
  34368. */
  34369. getUniformIndex(uniformName: string): number;
  34370. /**
  34371. * Returns the attribute based on the name of the variable.
  34372. * @param uniformName of the uniform to look up.
  34373. * @returns the location of the uniform.
  34374. */
  34375. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34376. /**
  34377. * Returns an array of sampler variable names
  34378. * @returns The array of sampler variable names.
  34379. */
  34380. getSamplers(): string[];
  34381. /**
  34382. * Returns an array of uniform variable names
  34383. * @returns The array of uniform variable names.
  34384. */
  34385. getUniformNames(): string[];
  34386. /**
  34387. * Returns an array of uniform buffer variable names
  34388. * @returns The array of uniform buffer variable names.
  34389. */
  34390. getUniformBuffersNames(): string[];
  34391. /**
  34392. * Returns the index parameters used to create the effect
  34393. * @returns The index parameters object
  34394. */
  34395. getIndexParameters(): any;
  34396. /**
  34397. * The error from the last compilation.
  34398. * @returns the error string.
  34399. */
  34400. getCompilationError(): string;
  34401. /**
  34402. * Gets a boolean indicating that all fallbacks were used during compilation
  34403. * @returns true if all fallbacks were used
  34404. */
  34405. allFallbacksProcessed(): boolean;
  34406. /**
  34407. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34408. * @param func The callback to be used.
  34409. */
  34410. executeWhenCompiled(func: (effect: Effect) => void): void;
  34411. private _checkIsReady;
  34412. private _loadShader;
  34413. /**
  34414. * Gets the vertex shader source code of this effect
  34415. */
  34416. get vertexSourceCode(): string;
  34417. /**
  34418. * Gets the fragment shader source code of this effect
  34419. */
  34420. get fragmentSourceCode(): string;
  34421. /**
  34422. * Recompiles the webGL program
  34423. * @param vertexSourceCode The source code for the vertex shader.
  34424. * @param fragmentSourceCode The source code for the fragment shader.
  34425. * @param onCompiled Callback called when completed.
  34426. * @param onError Callback called on error.
  34427. * @hidden
  34428. */
  34429. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34430. /**
  34431. * Prepares the effect
  34432. * @hidden
  34433. */
  34434. _prepareEffect(): void;
  34435. private _getShaderCodeAndErrorLine;
  34436. private _processCompilationErrors;
  34437. /**
  34438. * Checks if the effect is supported. (Must be called after compilation)
  34439. */
  34440. get isSupported(): boolean;
  34441. /**
  34442. * Binds a texture to the engine to be used as output of the shader.
  34443. * @param channel Name of the output variable.
  34444. * @param texture Texture to bind.
  34445. * @hidden
  34446. */
  34447. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34448. /**
  34449. * Sets a texture on the engine to be used in the shader.
  34450. * @param channel Name of the sampler variable.
  34451. * @param texture Texture to set.
  34452. */
  34453. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34454. /**
  34455. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34456. * @param channel Name of the sampler variable.
  34457. * @param texture Texture to set.
  34458. */
  34459. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34460. /**
  34461. * Sets an array of textures on the engine to be used in the shader.
  34462. * @param channel Name of the variable.
  34463. * @param textures Textures to set.
  34464. */
  34465. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34466. /**
  34467. * 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)
  34468. * @param channel Name of the sampler variable.
  34469. * @param postProcess Post process to get the input texture from.
  34470. */
  34471. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34472. /**
  34473. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34474. * 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)
  34475. * @param channel Name of the sampler variable.
  34476. * @param postProcess Post process to get the output texture from.
  34477. */
  34478. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34479. /** @hidden */
  34480. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34481. /** @hidden */
  34482. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34483. /** @hidden */
  34484. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34485. /** @hidden */
  34486. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34487. /**
  34488. * Binds a buffer to a uniform.
  34489. * @param buffer Buffer to bind.
  34490. * @param name Name of the uniform variable to bind to.
  34491. */
  34492. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34493. /**
  34494. * Binds block to a uniform.
  34495. * @param blockName Name of the block to bind.
  34496. * @param index Index to bind.
  34497. */
  34498. bindUniformBlock(blockName: string, index: number): void;
  34499. /**
  34500. * Sets an interger value on a uniform variable.
  34501. * @param uniformName Name of the variable.
  34502. * @param value Value to be set.
  34503. * @returns this effect.
  34504. */
  34505. setInt(uniformName: string, value: number): Effect;
  34506. /**
  34507. * Sets an int array on a uniform variable.
  34508. * @param uniformName Name of the variable.
  34509. * @param array array to be set.
  34510. * @returns this effect.
  34511. */
  34512. setIntArray(uniformName: string, array: Int32Array): Effect;
  34513. /**
  34514. * 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)
  34515. * @param uniformName Name of the variable.
  34516. * @param array array to be set.
  34517. * @returns this effect.
  34518. */
  34519. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34520. /**
  34521. * 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)
  34522. * @param uniformName Name of the variable.
  34523. * @param array array to be set.
  34524. * @returns this effect.
  34525. */
  34526. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34527. /**
  34528. * 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)
  34529. * @param uniformName Name of the variable.
  34530. * @param array array to be set.
  34531. * @returns this effect.
  34532. */
  34533. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34534. /**
  34535. * Sets an float 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. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34541. /**
  34542. * 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)
  34543. * @param uniformName Name of the variable.
  34544. * @param array array to be set.
  34545. * @returns this effect.
  34546. */
  34547. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34548. /**
  34549. * 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)
  34550. * @param uniformName Name of the variable.
  34551. * @param array array to be set.
  34552. * @returns this effect.
  34553. */
  34554. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34555. /**
  34556. * 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)
  34557. * @param uniformName Name of the variable.
  34558. * @param array array to be set.
  34559. * @returns this effect.
  34560. */
  34561. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34562. /**
  34563. * Sets an 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. setArray(uniformName: string, array: number[]): Effect;
  34569. /**
  34570. * 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)
  34571. * @param uniformName Name of the variable.
  34572. * @param array array to be set.
  34573. * @returns this effect.
  34574. */
  34575. setArray2(uniformName: string, array: number[]): Effect;
  34576. /**
  34577. * 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)
  34578. * @param uniformName Name of the variable.
  34579. * @param array array to be set.
  34580. * @returns this effect.
  34581. */
  34582. setArray3(uniformName: string, array: number[]): Effect;
  34583. /**
  34584. * 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)
  34585. * @param uniformName Name of the variable.
  34586. * @param array array to be set.
  34587. * @returns this effect.
  34588. */
  34589. setArray4(uniformName: string, array: number[]): Effect;
  34590. /**
  34591. * Sets matrices on a uniform variable.
  34592. * @param uniformName Name of the variable.
  34593. * @param matrices matrices to be set.
  34594. * @returns this effect.
  34595. */
  34596. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  34597. /**
  34598. * Sets matrix on a uniform variable.
  34599. * @param uniformName Name of the variable.
  34600. * @param matrix matrix to be set.
  34601. * @returns this effect.
  34602. */
  34603. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34604. /**
  34605. * 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)
  34606. * @param uniformName Name of the variable.
  34607. * @param matrix matrix to be set.
  34608. * @returns this effect.
  34609. */
  34610. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34611. /**
  34612. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34613. * @param uniformName Name of the variable.
  34614. * @param matrix matrix to be set.
  34615. * @returns this effect.
  34616. */
  34617. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34618. /**
  34619. * Sets a float on a uniform variable.
  34620. * @param uniformName Name of the variable.
  34621. * @param value value to be set.
  34622. * @returns this effect.
  34623. */
  34624. setFloat(uniformName: string, value: number): Effect;
  34625. /**
  34626. * Sets a boolean on a uniform variable.
  34627. * @param uniformName Name of the variable.
  34628. * @param bool value to be set.
  34629. * @returns this effect.
  34630. */
  34631. setBool(uniformName: string, bool: boolean): Effect;
  34632. /**
  34633. * Sets a Vector2 on a uniform variable.
  34634. * @param uniformName Name of the variable.
  34635. * @param vector2 vector2 to be set.
  34636. * @returns this effect.
  34637. */
  34638. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34639. /**
  34640. * Sets a float2 on a uniform variable.
  34641. * @param uniformName Name of the variable.
  34642. * @param x First float in float2.
  34643. * @param y Second float in float2.
  34644. * @returns this effect.
  34645. */
  34646. setFloat2(uniformName: string, x: number, y: number): Effect;
  34647. /**
  34648. * Sets a Vector3 on a uniform variable.
  34649. * @param uniformName Name of the variable.
  34650. * @param vector3 Value to be set.
  34651. * @returns this effect.
  34652. */
  34653. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34654. /**
  34655. * Sets a float3 on a uniform variable.
  34656. * @param uniformName Name of the variable.
  34657. * @param x First float in float3.
  34658. * @param y Second float in float3.
  34659. * @param z Third float in float3.
  34660. * @returns this effect.
  34661. */
  34662. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34663. /**
  34664. * Sets a Vector4 on a uniform variable.
  34665. * @param uniformName Name of the variable.
  34666. * @param vector4 Value to be set.
  34667. * @returns this effect.
  34668. */
  34669. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34670. /**
  34671. * Sets a float4 on a uniform variable.
  34672. * @param uniformName Name of the variable.
  34673. * @param x First float in float4.
  34674. * @param y Second float in float4.
  34675. * @param z Third float in float4.
  34676. * @param w Fourth float in float4.
  34677. * @returns this effect.
  34678. */
  34679. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34680. /**
  34681. * Sets a Color3 on a uniform variable.
  34682. * @param uniformName Name of the variable.
  34683. * @param color3 Value to be set.
  34684. * @returns this effect.
  34685. */
  34686. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34687. /**
  34688. * Sets a Color4 on a uniform variable.
  34689. * @param uniformName Name of the variable.
  34690. * @param color3 Value to be set.
  34691. * @param alpha Alpha value to be set.
  34692. * @returns this effect.
  34693. */
  34694. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34695. /**
  34696. * Sets a Color4 on a uniform variable
  34697. * @param uniformName defines the name of the variable
  34698. * @param color4 defines the value to be set
  34699. * @returns this effect.
  34700. */
  34701. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34702. /** Release all associated resources */
  34703. dispose(): void;
  34704. /**
  34705. * This function will add a new shader to the shader store
  34706. * @param name the name of the shader
  34707. * @param pixelShader optional pixel shader content
  34708. * @param vertexShader optional vertex shader content
  34709. */
  34710. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34711. /**
  34712. * Store of each shader (The can be looked up using effect.key)
  34713. */
  34714. static ShadersStore: {
  34715. [key: string]: string;
  34716. };
  34717. /**
  34718. * Store of each included file for a shader (The can be looked up using effect.key)
  34719. */
  34720. static IncludesShadersStore: {
  34721. [key: string]: string;
  34722. };
  34723. /**
  34724. * Resets the cache of effects.
  34725. */
  34726. static ResetCache(): void;
  34727. }
  34728. }
  34729. declare module BABYLON {
  34730. /**
  34731. * Interface used to describe the capabilities of the engine relatively to the current browser
  34732. */
  34733. export interface EngineCapabilities {
  34734. /** Maximum textures units per fragment shader */
  34735. maxTexturesImageUnits: number;
  34736. /** Maximum texture units per vertex shader */
  34737. maxVertexTextureImageUnits: number;
  34738. /** Maximum textures units in the entire pipeline */
  34739. maxCombinedTexturesImageUnits: number;
  34740. /** Maximum texture size */
  34741. maxTextureSize: number;
  34742. /** Maximum texture samples */
  34743. maxSamples?: number;
  34744. /** Maximum cube texture size */
  34745. maxCubemapTextureSize: number;
  34746. /** Maximum render texture size */
  34747. maxRenderTextureSize: number;
  34748. /** Maximum number of vertex attributes */
  34749. maxVertexAttribs: number;
  34750. /** Maximum number of varyings */
  34751. maxVaryingVectors: number;
  34752. /** Maximum number of uniforms per vertex shader */
  34753. maxVertexUniformVectors: number;
  34754. /** Maximum number of uniforms per fragment shader */
  34755. maxFragmentUniformVectors: number;
  34756. /** Defines if standard derivates (dx/dy) are supported */
  34757. standardDerivatives: boolean;
  34758. /** Defines if s3tc texture compression is supported */
  34759. s3tc?: WEBGL_compressed_texture_s3tc;
  34760. /** Defines if pvrtc texture compression is supported */
  34761. pvrtc: any;
  34762. /** Defines if etc1 texture compression is supported */
  34763. etc1: any;
  34764. /** Defines if etc2 texture compression is supported */
  34765. etc2: any;
  34766. /** Defines if astc texture compression is supported */
  34767. astc: any;
  34768. /** Defines if float textures are supported */
  34769. textureFloat: boolean;
  34770. /** Defines if vertex array objects are supported */
  34771. vertexArrayObject: boolean;
  34772. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34773. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34774. /** Gets the maximum level of anisotropy supported */
  34775. maxAnisotropy: number;
  34776. /** Defines if instancing is supported */
  34777. instancedArrays: boolean;
  34778. /** Defines if 32 bits indices are supported */
  34779. uintIndices: boolean;
  34780. /** Defines if high precision shaders are supported */
  34781. highPrecisionShaderSupported: boolean;
  34782. /** Defines if depth reading in the fragment shader is supported */
  34783. fragmentDepthSupported: boolean;
  34784. /** Defines if float texture linear filtering is supported*/
  34785. textureFloatLinearFiltering: boolean;
  34786. /** Defines if rendering to float textures is supported */
  34787. textureFloatRender: boolean;
  34788. /** Defines if half float textures are supported*/
  34789. textureHalfFloat: boolean;
  34790. /** Defines if half float texture linear filtering is supported*/
  34791. textureHalfFloatLinearFiltering: boolean;
  34792. /** Defines if rendering to half float textures is supported */
  34793. textureHalfFloatRender: boolean;
  34794. /** Defines if textureLOD shader command is supported */
  34795. textureLOD: boolean;
  34796. /** Defines if draw buffers extension is supported */
  34797. drawBuffersExtension: boolean;
  34798. /** Defines if depth textures are supported */
  34799. depthTextureExtension: boolean;
  34800. /** Defines if float color buffer are supported */
  34801. colorBufferFloat: boolean;
  34802. /** Gets disjoint timer query extension (null if not supported) */
  34803. timerQuery?: EXT_disjoint_timer_query;
  34804. /** Defines if timestamp can be used with timer query */
  34805. canUseTimestampForTimerQuery: boolean;
  34806. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  34807. multiview?: any;
  34808. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  34809. oculusMultiview?: any;
  34810. /** Function used to let the system compiles shaders in background */
  34811. parallelShaderCompile?: {
  34812. COMPLETION_STATUS_KHR: number;
  34813. };
  34814. /** Max number of texture samples for MSAA */
  34815. maxMSAASamples: number;
  34816. /** Defines if the blend min max extension is supported */
  34817. blendMinMax: boolean;
  34818. }
  34819. }
  34820. declare module BABYLON {
  34821. /**
  34822. * @hidden
  34823. **/
  34824. export class DepthCullingState {
  34825. private _isDepthTestDirty;
  34826. private _isDepthMaskDirty;
  34827. private _isDepthFuncDirty;
  34828. private _isCullFaceDirty;
  34829. private _isCullDirty;
  34830. private _isZOffsetDirty;
  34831. private _isFrontFaceDirty;
  34832. private _depthTest;
  34833. private _depthMask;
  34834. private _depthFunc;
  34835. private _cull;
  34836. private _cullFace;
  34837. private _zOffset;
  34838. private _frontFace;
  34839. /**
  34840. * Initializes the state.
  34841. */
  34842. constructor();
  34843. get isDirty(): boolean;
  34844. get zOffset(): number;
  34845. set zOffset(value: number);
  34846. get cullFace(): Nullable<number>;
  34847. set cullFace(value: Nullable<number>);
  34848. get cull(): Nullable<boolean>;
  34849. set cull(value: Nullable<boolean>);
  34850. get depthFunc(): Nullable<number>;
  34851. set depthFunc(value: Nullable<number>);
  34852. get depthMask(): boolean;
  34853. set depthMask(value: boolean);
  34854. get depthTest(): boolean;
  34855. set depthTest(value: boolean);
  34856. get frontFace(): Nullable<number>;
  34857. set frontFace(value: Nullable<number>);
  34858. reset(): void;
  34859. apply(gl: WebGLRenderingContext): void;
  34860. }
  34861. }
  34862. declare module BABYLON {
  34863. /**
  34864. * @hidden
  34865. **/
  34866. export class StencilState {
  34867. /** 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 */
  34868. static readonly ALWAYS: number;
  34869. /** Passed to stencilOperation to specify that stencil value must be kept */
  34870. static readonly KEEP: number;
  34871. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34872. static readonly REPLACE: number;
  34873. private _isStencilTestDirty;
  34874. private _isStencilMaskDirty;
  34875. private _isStencilFuncDirty;
  34876. private _isStencilOpDirty;
  34877. private _stencilTest;
  34878. private _stencilMask;
  34879. private _stencilFunc;
  34880. private _stencilFuncRef;
  34881. private _stencilFuncMask;
  34882. private _stencilOpStencilFail;
  34883. private _stencilOpDepthFail;
  34884. private _stencilOpStencilDepthPass;
  34885. get isDirty(): boolean;
  34886. get stencilFunc(): number;
  34887. set stencilFunc(value: number);
  34888. get stencilFuncRef(): number;
  34889. set stencilFuncRef(value: number);
  34890. get stencilFuncMask(): number;
  34891. set stencilFuncMask(value: number);
  34892. get stencilOpStencilFail(): number;
  34893. set stencilOpStencilFail(value: number);
  34894. get stencilOpDepthFail(): number;
  34895. set stencilOpDepthFail(value: number);
  34896. get stencilOpStencilDepthPass(): number;
  34897. set stencilOpStencilDepthPass(value: number);
  34898. get stencilMask(): number;
  34899. set stencilMask(value: number);
  34900. get stencilTest(): boolean;
  34901. set stencilTest(value: boolean);
  34902. constructor();
  34903. reset(): void;
  34904. apply(gl: WebGLRenderingContext): void;
  34905. }
  34906. }
  34907. declare module BABYLON {
  34908. /**
  34909. * @hidden
  34910. **/
  34911. export class AlphaState {
  34912. private _isAlphaBlendDirty;
  34913. private _isBlendFunctionParametersDirty;
  34914. private _isBlendEquationParametersDirty;
  34915. private _isBlendConstantsDirty;
  34916. private _alphaBlend;
  34917. private _blendFunctionParameters;
  34918. private _blendEquationParameters;
  34919. private _blendConstants;
  34920. /**
  34921. * Initializes the state.
  34922. */
  34923. constructor();
  34924. get isDirty(): boolean;
  34925. get alphaBlend(): boolean;
  34926. set alphaBlend(value: boolean);
  34927. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  34928. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  34929. setAlphaEquationParameters(rgb: number, alpha: number): void;
  34930. reset(): void;
  34931. apply(gl: WebGLRenderingContext): void;
  34932. }
  34933. }
  34934. declare module BABYLON {
  34935. /** @hidden */
  34936. export class WebGL2ShaderProcessor implements IShaderProcessor {
  34937. attributeProcessor(attribute: string): string;
  34938. varyingProcessor(varying: string, isFragment: boolean): string;
  34939. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  34940. }
  34941. }
  34942. declare module BABYLON {
  34943. /**
  34944. * Interface for attribute information associated with buffer instanciation
  34945. */
  34946. export interface InstancingAttributeInfo {
  34947. /**
  34948. * Name of the GLSL attribute
  34949. * if attribute index is not specified, this is used to retrieve the index from the effect
  34950. */
  34951. attributeName: string;
  34952. /**
  34953. * Index/offset of the attribute in the vertex shader
  34954. * if not specified, this will be computes from the name.
  34955. */
  34956. index?: number;
  34957. /**
  34958. * size of the attribute, 1, 2, 3 or 4
  34959. */
  34960. attributeSize: number;
  34961. /**
  34962. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  34963. */
  34964. offset: number;
  34965. /**
  34966. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  34967. * default to 1
  34968. */
  34969. divisor?: number;
  34970. /**
  34971. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  34972. * default is FLOAT
  34973. */
  34974. attributeType?: number;
  34975. /**
  34976. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  34977. */
  34978. normalized?: boolean;
  34979. }
  34980. }
  34981. declare module BABYLON {
  34982. interface ThinEngine {
  34983. /**
  34984. * Update a video texture
  34985. * @param texture defines the texture to update
  34986. * @param video defines the video element to use
  34987. * @param invertY defines if data must be stored with Y axis inverted
  34988. */
  34989. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  34990. }
  34991. }
  34992. declare module BABYLON {
  34993. interface ThinEngine {
  34994. /**
  34995. * Creates a dynamic texture
  34996. * @param width defines the width of the texture
  34997. * @param height defines the height of the texture
  34998. * @param generateMipMaps defines if the engine should generate the mip levels
  34999. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  35000. * @returns the dynamic texture inside an InternalTexture
  35001. */
  35002. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  35003. /**
  35004. * Update the content of a dynamic texture
  35005. * @param texture defines the texture to update
  35006. * @param canvas defines the canvas containing the source
  35007. * @param invertY defines if data must be stored with Y axis inverted
  35008. * @param premulAlpha defines if alpha is stored as premultiplied
  35009. * @param format defines the format of the data
  35010. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  35011. */
  35012. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  35013. }
  35014. }
  35015. declare module BABYLON {
  35016. /**
  35017. * Settings for finer control over video usage
  35018. */
  35019. export interface VideoTextureSettings {
  35020. /**
  35021. * Applies `autoplay` to video, if specified
  35022. */
  35023. autoPlay?: boolean;
  35024. /**
  35025. * Applies `loop` to video, if specified
  35026. */
  35027. loop?: boolean;
  35028. /**
  35029. * Automatically updates internal texture from video at every frame in the render loop
  35030. */
  35031. autoUpdateTexture: boolean;
  35032. /**
  35033. * Image src displayed during the video loading or until the user interacts with the video.
  35034. */
  35035. poster?: string;
  35036. }
  35037. /**
  35038. * If you want to display a video in your scene, this is the special texture for that.
  35039. * This special texture works similar to other textures, with the exception of a few parameters.
  35040. * @see https://doc.babylonjs.com/how_to/video_texture
  35041. */
  35042. export class VideoTexture extends Texture {
  35043. /**
  35044. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35045. */
  35046. readonly autoUpdateTexture: boolean;
  35047. /**
  35048. * The video instance used by the texture internally
  35049. */
  35050. readonly video: HTMLVideoElement;
  35051. private _onUserActionRequestedObservable;
  35052. /**
  35053. * Event triggerd when a dom action is required by the user to play the video.
  35054. * This happens due to recent changes in browser policies preventing video to auto start.
  35055. */
  35056. get onUserActionRequestedObservable(): Observable<Texture>;
  35057. private _generateMipMaps;
  35058. private _stillImageCaptured;
  35059. private _displayingPosterTexture;
  35060. private _settings;
  35061. private _createInternalTextureOnEvent;
  35062. private _frameId;
  35063. private _currentSrc;
  35064. /**
  35065. * Creates a video texture.
  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. * @param name optional name, will detect from video source, if not defined
  35070. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35071. * @param scene is obviously the current scene.
  35072. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35073. * @param invertY is false by default but can be used to invert video on Y axis
  35074. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35075. * @param settings allows finer control over video usage
  35076. */
  35077. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35078. private _getName;
  35079. private _getVideo;
  35080. private _createInternalTexture;
  35081. private reset;
  35082. /**
  35083. * @hidden Internal method to initiate `update`.
  35084. */
  35085. _rebuild(): void;
  35086. /**
  35087. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35088. */
  35089. update(): void;
  35090. /**
  35091. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35092. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35093. */
  35094. updateTexture(isVisible: boolean): void;
  35095. protected _updateInternalTexture: () => void;
  35096. /**
  35097. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35098. * @param url New url.
  35099. */
  35100. updateURL(url: string): void;
  35101. /**
  35102. * Clones the texture.
  35103. * @returns the cloned texture
  35104. */
  35105. clone(): VideoTexture;
  35106. /**
  35107. * Dispose the texture and release its associated resources.
  35108. */
  35109. dispose(): void;
  35110. /**
  35111. * Creates a video texture straight from a stream.
  35112. * @param scene Define the scene the texture should be created in
  35113. * @param stream Define the stream the texture should be created from
  35114. * @returns The created video texture as a promise
  35115. */
  35116. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35117. /**
  35118. * Creates a video texture straight from your WebCam video feed.
  35119. * @param scene Define the scene the texture should be created in
  35120. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35121. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35122. * @returns The created video texture as a promise
  35123. */
  35124. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35125. minWidth: number;
  35126. maxWidth: number;
  35127. minHeight: number;
  35128. maxHeight: number;
  35129. deviceId: string;
  35130. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35131. /**
  35132. * Creates a video texture straight from your WebCam video feed.
  35133. * @param scene Define the scene the texture should be created in
  35134. * @param onReady Define a callback to triggered once the texture will be ready
  35135. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35136. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35137. */
  35138. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35139. minWidth: number;
  35140. maxWidth: number;
  35141. minHeight: number;
  35142. maxHeight: number;
  35143. deviceId: string;
  35144. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35145. }
  35146. }
  35147. declare module BABYLON {
  35148. /**
  35149. * Defines the interface used by objects working like Scene
  35150. * @hidden
  35151. */
  35152. export interface ISceneLike {
  35153. _addPendingData(data: any): void;
  35154. _removePendingData(data: any): void;
  35155. offlineProvider: IOfflineProvider;
  35156. }
  35157. /** Interface defining initialization parameters for Engine class */
  35158. export interface EngineOptions extends WebGLContextAttributes {
  35159. /**
  35160. * Defines if the engine should no exceed a specified device ratio
  35161. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35162. */
  35163. limitDeviceRatio?: number;
  35164. /**
  35165. * Defines if webvr should be enabled automatically
  35166. * @see https://doc.babylonjs.com/how_to/webvr_camera
  35167. */
  35168. autoEnableWebVR?: boolean;
  35169. /**
  35170. * Defines if webgl2 should be turned off even if supported
  35171. * @see https://doc.babylonjs.com/features/webgl2
  35172. */
  35173. disableWebGL2Support?: boolean;
  35174. /**
  35175. * Defines if webaudio should be initialized as well
  35176. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35177. */
  35178. audioEngine?: boolean;
  35179. /**
  35180. * Defines if animations should run using a deterministic lock step
  35181. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35182. */
  35183. deterministicLockstep?: boolean;
  35184. /** Defines the maximum steps to use with deterministic lock step mode */
  35185. lockstepMaxSteps?: number;
  35186. /** Defines the seconds between each deterministic lock step */
  35187. timeStep?: number;
  35188. /**
  35189. * Defines that engine should ignore context lost events
  35190. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35191. */
  35192. doNotHandleContextLost?: boolean;
  35193. /**
  35194. * Defines that engine should ignore modifying touch action attribute and style
  35195. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35196. */
  35197. doNotHandleTouchAction?: boolean;
  35198. /**
  35199. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35200. */
  35201. useHighPrecisionFloats?: boolean;
  35202. /**
  35203. * Make the canvas XR Compatible for XR sessions
  35204. */
  35205. xrCompatible?: boolean;
  35206. /**
  35207. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  35208. */
  35209. useHighPrecisionMatrix?: boolean;
  35210. }
  35211. /**
  35212. * The base engine class (root of all engines)
  35213. */
  35214. export class ThinEngine {
  35215. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35216. static ExceptionList: ({
  35217. key: string;
  35218. capture: string;
  35219. captureConstraint: number;
  35220. targets: string[];
  35221. } | {
  35222. key: string;
  35223. capture: null;
  35224. captureConstraint: null;
  35225. targets: string[];
  35226. })[];
  35227. /** @hidden */
  35228. static _TextureLoaders: IInternalTextureLoader[];
  35229. /**
  35230. * Returns the current npm package of the sdk
  35231. */
  35232. static get NpmPackage(): string;
  35233. /**
  35234. * Returns the current version of the framework
  35235. */
  35236. static get Version(): string;
  35237. /**
  35238. * Returns a string describing the current engine
  35239. */
  35240. get description(): string;
  35241. /**
  35242. * Gets or sets the epsilon value used by collision engine
  35243. */
  35244. static CollisionsEpsilon: number;
  35245. /**
  35246. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35247. */
  35248. static get ShadersRepository(): string;
  35249. static set ShadersRepository(value: string);
  35250. /** @hidden */
  35251. _shaderProcessor: IShaderProcessor;
  35252. /**
  35253. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35254. */
  35255. forcePOTTextures: boolean;
  35256. /**
  35257. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35258. */
  35259. isFullscreen: boolean;
  35260. /**
  35261. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35262. */
  35263. cullBackFaces: boolean;
  35264. /**
  35265. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35266. */
  35267. renderEvenInBackground: boolean;
  35268. /**
  35269. * Gets or sets a boolean indicating that cache can be kept between frames
  35270. */
  35271. preventCacheWipeBetweenFrames: boolean;
  35272. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35273. validateShaderPrograms: boolean;
  35274. /**
  35275. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35276. * This can provide greater z depth for distant objects.
  35277. */
  35278. useReverseDepthBuffer: boolean;
  35279. /**
  35280. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35281. */
  35282. disableUniformBuffers: boolean;
  35283. /** @hidden */
  35284. _uniformBuffers: UniformBuffer[];
  35285. /**
  35286. * Gets a boolean indicating that the engine supports uniform buffers
  35287. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35288. */
  35289. get supportsUniformBuffers(): boolean;
  35290. /** @hidden */
  35291. _gl: WebGLRenderingContext;
  35292. /** @hidden */
  35293. _webGLVersion: number;
  35294. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35295. protected _windowIsBackground: boolean;
  35296. protected _creationOptions: EngineOptions;
  35297. protected _highPrecisionShadersAllowed: boolean;
  35298. /** @hidden */
  35299. get _shouldUseHighPrecisionShader(): boolean;
  35300. /**
  35301. * Gets a boolean indicating that only power of 2 textures are supported
  35302. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35303. */
  35304. get needPOTTextures(): boolean;
  35305. /** @hidden */
  35306. _badOS: boolean;
  35307. /** @hidden */
  35308. _badDesktopOS: boolean;
  35309. private _hardwareScalingLevel;
  35310. /** @hidden */
  35311. _caps: EngineCapabilities;
  35312. private _isStencilEnable;
  35313. private _glVersion;
  35314. private _glRenderer;
  35315. private _glVendor;
  35316. /** @hidden */
  35317. _videoTextureSupported: boolean;
  35318. protected _renderingQueueLaunched: boolean;
  35319. protected _activeRenderLoops: (() => void)[];
  35320. /**
  35321. * Observable signaled when a context lost event is raised
  35322. */
  35323. onContextLostObservable: Observable<ThinEngine>;
  35324. /**
  35325. * Observable signaled when a context restored event is raised
  35326. */
  35327. onContextRestoredObservable: Observable<ThinEngine>;
  35328. private _onContextLost;
  35329. private _onContextRestored;
  35330. protected _contextWasLost: boolean;
  35331. /** @hidden */
  35332. _doNotHandleContextLost: boolean;
  35333. /**
  35334. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35335. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35336. */
  35337. get doNotHandleContextLost(): boolean;
  35338. set doNotHandleContextLost(value: boolean);
  35339. /**
  35340. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35341. */
  35342. disableVertexArrayObjects: boolean;
  35343. /** @hidden */
  35344. protected _colorWrite: boolean;
  35345. /** @hidden */
  35346. protected _colorWriteChanged: boolean;
  35347. /** @hidden */
  35348. protected _depthCullingState: DepthCullingState;
  35349. /** @hidden */
  35350. protected _stencilState: StencilState;
  35351. /** @hidden */
  35352. _alphaState: AlphaState;
  35353. /** @hidden */
  35354. _alphaMode: number;
  35355. /** @hidden */
  35356. _alphaEquation: number;
  35357. /** @hidden */
  35358. _internalTexturesCache: InternalTexture[];
  35359. /** @hidden */
  35360. protected _activeChannel: number;
  35361. private _currentTextureChannel;
  35362. /** @hidden */
  35363. protected _boundTexturesCache: {
  35364. [key: string]: Nullable<InternalTexture>;
  35365. };
  35366. /** @hidden */
  35367. protected _currentEffect: Nullable<Effect>;
  35368. /** @hidden */
  35369. protected _currentProgram: Nullable<WebGLProgram>;
  35370. private _compiledEffects;
  35371. private _vertexAttribArraysEnabled;
  35372. /** @hidden */
  35373. protected _cachedViewport: Nullable<IViewportLike>;
  35374. private _cachedVertexArrayObject;
  35375. /** @hidden */
  35376. protected _cachedVertexBuffers: any;
  35377. /** @hidden */
  35378. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35379. /** @hidden */
  35380. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35381. /** @hidden */
  35382. _currentRenderTarget: Nullable<InternalTexture>;
  35383. private _uintIndicesCurrentlySet;
  35384. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35385. /** @hidden */
  35386. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35387. /** @hidden */
  35388. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35389. private _currentBufferPointers;
  35390. private _currentInstanceLocations;
  35391. private _currentInstanceBuffers;
  35392. private _textureUnits;
  35393. /** @hidden */
  35394. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35395. /** @hidden */
  35396. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35397. /** @hidden */
  35398. _boundRenderFunction: any;
  35399. private _vaoRecordInProgress;
  35400. private _mustWipeVertexAttributes;
  35401. private _emptyTexture;
  35402. private _emptyCubeTexture;
  35403. private _emptyTexture3D;
  35404. private _emptyTexture2DArray;
  35405. /** @hidden */
  35406. _frameHandler: number;
  35407. private _nextFreeTextureSlots;
  35408. private _maxSimultaneousTextures;
  35409. private _activeRequests;
  35410. /** @hidden */
  35411. _transformTextureUrl: Nullable<(url: string) => string>;
  35412. protected get _supportsHardwareTextureRescaling(): boolean;
  35413. private _framebufferDimensionsObject;
  35414. /**
  35415. * sets the object from which width and height will be taken from when getting render width and height
  35416. * Will fallback to the gl object
  35417. * @param dimensions the framebuffer width and height that will be used.
  35418. */
  35419. set framebufferDimensionsObject(dimensions: Nullable<{
  35420. framebufferWidth: number;
  35421. framebufferHeight: number;
  35422. }>);
  35423. /**
  35424. * Gets the current viewport
  35425. */
  35426. get currentViewport(): Nullable<IViewportLike>;
  35427. /**
  35428. * Gets the default empty texture
  35429. */
  35430. get emptyTexture(): InternalTexture;
  35431. /**
  35432. * Gets the default empty 3D texture
  35433. */
  35434. get emptyTexture3D(): InternalTexture;
  35435. /**
  35436. * Gets the default empty 2D array texture
  35437. */
  35438. get emptyTexture2DArray(): InternalTexture;
  35439. /**
  35440. * Gets the default empty cube texture
  35441. */
  35442. get emptyCubeTexture(): InternalTexture;
  35443. /**
  35444. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35445. */
  35446. readonly premultipliedAlpha: boolean;
  35447. /**
  35448. * Observable event triggered before each texture is initialized
  35449. */
  35450. onBeforeTextureInitObservable: Observable<Texture>;
  35451. /**
  35452. * Creates a new engine
  35453. * @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
  35454. * @param antialias defines enable antialiasing (default: false)
  35455. * @param options defines further options to be sent to the getContext() function
  35456. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35457. */
  35458. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35459. private _rebuildInternalTextures;
  35460. private _rebuildEffects;
  35461. /**
  35462. * Gets a boolean indicating if all created effects are ready
  35463. * @returns true if all effects are ready
  35464. */
  35465. areAllEffectsReady(): boolean;
  35466. protected _rebuildBuffers(): void;
  35467. protected _initGLContext(): void;
  35468. /**
  35469. * Gets version of the current webGL context
  35470. */
  35471. get webGLVersion(): number;
  35472. /**
  35473. * Gets a string identifying the name of the class
  35474. * @returns "Engine" string
  35475. */
  35476. getClassName(): string;
  35477. /**
  35478. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35479. */
  35480. get isStencilEnable(): boolean;
  35481. /** @hidden */
  35482. _prepareWorkingCanvas(): void;
  35483. /**
  35484. * Reset the texture cache to empty state
  35485. */
  35486. resetTextureCache(): void;
  35487. /**
  35488. * Gets an object containing information about the current webGL context
  35489. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35490. */
  35491. getGlInfo(): {
  35492. vendor: string;
  35493. renderer: string;
  35494. version: string;
  35495. };
  35496. /**
  35497. * Defines the hardware scaling level.
  35498. * By default the hardware scaling level is computed from the window device ratio.
  35499. * 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.
  35500. * @param level defines the level to use
  35501. */
  35502. setHardwareScalingLevel(level: number): void;
  35503. /**
  35504. * Gets the current hardware scaling level.
  35505. * By default the hardware scaling level is computed from the window device ratio.
  35506. * 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.
  35507. * @returns a number indicating the current hardware scaling level
  35508. */
  35509. getHardwareScalingLevel(): number;
  35510. /**
  35511. * Gets the list of loaded textures
  35512. * @returns an array containing all loaded textures
  35513. */
  35514. getLoadedTexturesCache(): InternalTexture[];
  35515. /**
  35516. * Gets the object containing all engine capabilities
  35517. * @returns the EngineCapabilities object
  35518. */
  35519. getCaps(): EngineCapabilities;
  35520. /**
  35521. * stop executing a render loop function and remove it from the execution array
  35522. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35523. */
  35524. stopRenderLoop(renderFunction?: () => void): void;
  35525. /** @hidden */
  35526. _renderLoop(): void;
  35527. /**
  35528. * Gets the HTML canvas attached with the current webGL context
  35529. * @returns a HTML canvas
  35530. */
  35531. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35532. /**
  35533. * Gets host window
  35534. * @returns the host window object
  35535. */
  35536. getHostWindow(): Nullable<Window>;
  35537. /**
  35538. * Gets the current render width
  35539. * @param useScreen defines if screen size must be used (or the current render target if any)
  35540. * @returns a number defining the current render width
  35541. */
  35542. getRenderWidth(useScreen?: boolean): number;
  35543. /**
  35544. * Gets the current render height
  35545. * @param useScreen defines if screen size must be used (or the current render target if any)
  35546. * @returns a number defining the current render height
  35547. */
  35548. getRenderHeight(useScreen?: boolean): number;
  35549. /**
  35550. * Can be used to override the current requestAnimationFrame requester.
  35551. * @hidden
  35552. */
  35553. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35554. /**
  35555. * Register and execute a render loop. The engine can have more than one render function
  35556. * @param renderFunction defines the function to continuously execute
  35557. */
  35558. runRenderLoop(renderFunction: () => void): void;
  35559. /**
  35560. * Clear the current render buffer or the current render target (if any is set up)
  35561. * @param color defines the color to use
  35562. * @param backBuffer defines if the back buffer must be cleared
  35563. * @param depth defines if the depth buffer must be cleared
  35564. * @param stencil defines if the stencil buffer must be cleared
  35565. */
  35566. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35567. private _viewportCached;
  35568. /** @hidden */
  35569. _viewport(x: number, y: number, width: number, height: number): void;
  35570. /**
  35571. * Set the WebGL's viewport
  35572. * @param viewport defines the viewport element to be used
  35573. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35574. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35575. */
  35576. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35577. /**
  35578. * Begin a new frame
  35579. */
  35580. beginFrame(): void;
  35581. /**
  35582. * Enf the current frame
  35583. */
  35584. endFrame(): void;
  35585. /**
  35586. * Resize the view according to the canvas' size
  35587. */
  35588. resize(): void;
  35589. /**
  35590. * Force a specific size of the canvas
  35591. * @param width defines the new canvas' width
  35592. * @param height defines the new canvas' height
  35593. * @returns true if the size was changed
  35594. */
  35595. setSize(width: number, height: number): boolean;
  35596. /**
  35597. * Binds the frame buffer to the specified texture.
  35598. * @param texture The texture to render to or null for the default canvas
  35599. * @param faceIndex The face of the texture to render to in case of cube texture
  35600. * @param requiredWidth The width of the target to render to
  35601. * @param requiredHeight The height of the target to render to
  35602. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35603. * @param lodLevel defines the lod level to bind to the frame buffer
  35604. * @param layer defines the 2d array index to bind to frame buffer to
  35605. */
  35606. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35607. /** @hidden */
  35608. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35609. /**
  35610. * Unbind the current render target texture from the webGL context
  35611. * @param texture defines the render target texture to unbind
  35612. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35613. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35614. */
  35615. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35616. /**
  35617. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35618. */
  35619. flushFramebuffer(): void;
  35620. /**
  35621. * Unbind the current render target and bind the default framebuffer
  35622. */
  35623. restoreDefaultFramebuffer(): void;
  35624. /** @hidden */
  35625. protected _resetVertexBufferBinding(): void;
  35626. /**
  35627. * Creates a vertex buffer
  35628. * @param data the data for the vertex buffer
  35629. * @returns the new WebGL static buffer
  35630. */
  35631. createVertexBuffer(data: DataArray): DataBuffer;
  35632. private _createVertexBuffer;
  35633. /**
  35634. * Creates a dynamic vertex buffer
  35635. * @param data the data for the dynamic vertex buffer
  35636. * @returns the new WebGL dynamic buffer
  35637. */
  35638. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35639. protected _resetIndexBufferBinding(): void;
  35640. /**
  35641. * Creates a new index buffer
  35642. * @param indices defines the content of the index buffer
  35643. * @param updatable defines if the index buffer must be updatable
  35644. * @returns a new webGL buffer
  35645. */
  35646. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35647. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35648. /**
  35649. * Bind a webGL buffer to the webGL context
  35650. * @param buffer defines the buffer to bind
  35651. */
  35652. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35653. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35654. private bindBuffer;
  35655. /**
  35656. * update the bound buffer with the given data
  35657. * @param data defines the data to update
  35658. */
  35659. updateArrayBuffer(data: Float32Array): void;
  35660. private _vertexAttribPointer;
  35661. /** @hidden */
  35662. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35663. private _bindVertexBuffersAttributes;
  35664. /**
  35665. * Records a vertex array object
  35666. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35667. * @param vertexBuffers defines the list of vertex buffers to store
  35668. * @param indexBuffer defines the index buffer to store
  35669. * @param effect defines the effect to store
  35670. * @returns the new vertex array object
  35671. */
  35672. recordVertexArrayObject(vertexBuffers: {
  35673. [key: string]: VertexBuffer;
  35674. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35675. /**
  35676. * Bind a specific vertex array object
  35677. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35678. * @param vertexArrayObject defines the vertex array object to bind
  35679. * @param indexBuffer defines the index buffer to bind
  35680. */
  35681. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35682. /**
  35683. * Bind webGl buffers directly to the webGL context
  35684. * @param vertexBuffer defines the vertex buffer to bind
  35685. * @param indexBuffer defines the index buffer to bind
  35686. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35687. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35688. * @param effect defines the effect associated with the vertex buffer
  35689. */
  35690. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35691. private _unbindVertexArrayObject;
  35692. /**
  35693. * Bind a list of vertex buffers to the webGL context
  35694. * @param vertexBuffers defines the list of vertex buffers to bind
  35695. * @param indexBuffer defines the index buffer to bind
  35696. * @param effect defines the effect associated with the vertex buffers
  35697. */
  35698. bindBuffers(vertexBuffers: {
  35699. [key: string]: Nullable<VertexBuffer>;
  35700. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35701. /**
  35702. * Unbind all instance attributes
  35703. */
  35704. unbindInstanceAttributes(): void;
  35705. /**
  35706. * Release and free the memory of a vertex array object
  35707. * @param vao defines the vertex array object to delete
  35708. */
  35709. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35710. /** @hidden */
  35711. _releaseBuffer(buffer: DataBuffer): boolean;
  35712. protected _deleteBuffer(buffer: DataBuffer): void;
  35713. /**
  35714. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35715. * @param instancesBuffer defines the webGL buffer to update and bind
  35716. * @param data defines the data to store in the buffer
  35717. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35718. */
  35719. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35720. /**
  35721. * Bind the content of a webGL buffer used with instantiation
  35722. * @param instancesBuffer defines the webGL buffer to bind
  35723. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35724. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35725. */
  35726. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35727. /**
  35728. * Disable the instance attribute corresponding to the name in parameter
  35729. * @param name defines the name of the attribute to disable
  35730. */
  35731. disableInstanceAttributeByName(name: string): void;
  35732. /**
  35733. * Disable the instance attribute corresponding to the location in parameter
  35734. * @param attributeLocation defines the attribute location of the attribute to disable
  35735. */
  35736. disableInstanceAttribute(attributeLocation: number): void;
  35737. /**
  35738. * Disable the attribute corresponding to the location in parameter
  35739. * @param attributeLocation defines the attribute location of the attribute to disable
  35740. */
  35741. disableAttributeByIndex(attributeLocation: number): void;
  35742. /**
  35743. * Send a draw order
  35744. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35745. * @param indexStart defines the starting index
  35746. * @param indexCount defines the number of index to draw
  35747. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35748. */
  35749. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35750. /**
  35751. * Draw a list of points
  35752. * @param verticesStart defines the index of first vertex to draw
  35753. * @param verticesCount defines the count of vertices to draw
  35754. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35755. */
  35756. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35757. /**
  35758. * Draw a list of unindexed primitives
  35759. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35760. * @param verticesStart defines the index of first vertex to draw
  35761. * @param verticesCount defines the count of vertices to draw
  35762. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35763. */
  35764. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35765. /**
  35766. * Draw a list of indexed primitives
  35767. * @param fillMode defines the primitive to use
  35768. * @param indexStart defines the starting index
  35769. * @param indexCount defines the number of index to draw
  35770. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35771. */
  35772. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  35773. /**
  35774. * Draw a list of unindexed primitives
  35775. * @param fillMode defines the primitive to use
  35776. * @param verticesStart defines the index of first vertex to draw
  35777. * @param verticesCount defines the count of vertices to draw
  35778. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35779. */
  35780. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35781. private _drawMode;
  35782. /** @hidden */
  35783. protected _reportDrawCall(): void;
  35784. /** @hidden */
  35785. _releaseEffect(effect: Effect): void;
  35786. /** @hidden */
  35787. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35788. /**
  35789. * Create a new effect (used to store vertex/fragment shaders)
  35790. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  35791. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  35792. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  35793. * @param samplers defines an array of string used to represent textures
  35794. * @param defines defines the string containing the defines to use to compile the shaders
  35795. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  35796. * @param onCompiled defines a function to call when the effect creation is successful
  35797. * @param onError defines a function to call when the effect creation has failed
  35798. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  35799. * @returns the new Effect
  35800. */
  35801. 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;
  35802. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  35803. private _compileShader;
  35804. private _compileRawShader;
  35805. /** @hidden */
  35806. _getShaderSource(shader: WebGLShader): Nullable<string>;
  35807. /**
  35808. * Directly creates a webGL program
  35809. * @param pipelineContext defines the pipeline context to attach to
  35810. * @param vertexCode defines the vertex shader code to use
  35811. * @param fragmentCode defines the fragment shader code to use
  35812. * @param context defines the webGL context to use (if not set, the current one will be used)
  35813. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35814. * @returns the new webGL program
  35815. */
  35816. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35817. /**
  35818. * Creates a webGL program
  35819. * @param pipelineContext defines the pipeline context to attach to
  35820. * @param vertexCode defines the vertex shader code to use
  35821. * @param fragmentCode defines the fragment shader code to use
  35822. * @param defines defines the string containing the defines to use to compile the shaders
  35823. * @param context defines the webGL context to use (if not set, the current one will be used)
  35824. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35825. * @returns the new webGL program
  35826. */
  35827. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35828. /**
  35829. * Creates a new pipeline context
  35830. * @returns the new pipeline
  35831. */
  35832. createPipelineContext(): IPipelineContext;
  35833. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35834. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  35835. /** @hidden */
  35836. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  35837. /** @hidden */
  35838. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  35839. /** @hidden */
  35840. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  35841. /**
  35842. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  35843. * @param pipelineContext defines the pipeline context to use
  35844. * @param uniformsNames defines the list of uniform names
  35845. * @returns an array of webGL uniform locations
  35846. */
  35847. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  35848. /**
  35849. * Gets the lsit of active attributes for a given webGL program
  35850. * @param pipelineContext defines the pipeline context to use
  35851. * @param attributesNames defines the list of attribute names to get
  35852. * @returns an array of indices indicating the offset of each attribute
  35853. */
  35854. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  35855. /**
  35856. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  35857. * @param effect defines the effect to activate
  35858. */
  35859. enableEffect(effect: Nullable<Effect>): void;
  35860. /**
  35861. * Set the value of an uniform to a number (int)
  35862. * @param uniform defines the webGL uniform location where to store the value
  35863. * @param value defines the int number to store
  35864. */
  35865. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35866. /**
  35867. * Set the value of an uniform to an array of int32
  35868. * @param uniform defines the webGL uniform location where to store the value
  35869. * @param array defines the array of int32 to store
  35870. */
  35871. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35872. /**
  35873. * Set the value of an uniform to an array of int32 (stored as vec2)
  35874. * @param uniform defines the webGL uniform location where to store the value
  35875. * @param array defines the array of int32 to store
  35876. */
  35877. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35878. /**
  35879. * Set the value of an uniform to an array of int32 (stored as vec3)
  35880. * @param uniform defines the webGL uniform location where to store the value
  35881. * @param array defines the array of int32 to store
  35882. */
  35883. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35884. /**
  35885. * Set the value of an uniform to an array of int32 (stored as vec4)
  35886. * @param uniform defines the webGL uniform location where to store the value
  35887. * @param array defines the array of int32 to store
  35888. */
  35889. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35890. /**
  35891. * Set the value of an uniform to an array of number
  35892. * @param uniform defines the webGL uniform location where to store the value
  35893. * @param array defines the array of number to store
  35894. */
  35895. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35896. /**
  35897. * Set the value of an uniform to an array of number (stored as vec2)
  35898. * @param uniform defines the webGL uniform location where to store the value
  35899. * @param array defines the array of number to store
  35900. */
  35901. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35902. /**
  35903. * Set the value of an uniform to an array of number (stored as vec3)
  35904. * @param uniform defines the webGL uniform location where to store the value
  35905. * @param array defines the array of number to store
  35906. */
  35907. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35908. /**
  35909. * Set the value of an uniform to an array of number (stored as vec4)
  35910. * @param uniform defines the webGL uniform location where to store the value
  35911. * @param array defines the array of number to store
  35912. */
  35913. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35914. /**
  35915. * Set the value of an uniform to an array of float32 (stored as matrices)
  35916. * @param uniform defines the webGL uniform location where to store the value
  35917. * @param matrices defines the array of float32 to store
  35918. */
  35919. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  35920. /**
  35921. * Set the value of an uniform to a matrix (3x3)
  35922. * @param uniform defines the webGL uniform location where to store the value
  35923. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  35924. */
  35925. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35926. /**
  35927. * Set the value of an uniform to a matrix (2x2)
  35928. * @param uniform defines the webGL uniform location where to store the value
  35929. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  35930. */
  35931. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35932. /**
  35933. * Set the value of an uniform to a number (float)
  35934. * @param uniform defines the webGL uniform location where to store the value
  35935. * @param value defines the float number to store
  35936. */
  35937. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35938. /**
  35939. * Set the value of an uniform to a vec2
  35940. * @param uniform defines the webGL uniform location where to store the value
  35941. * @param x defines the 1st component of the value
  35942. * @param y defines the 2nd component of the value
  35943. */
  35944. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  35945. /**
  35946. * Set the value of an uniform to a vec3
  35947. * @param uniform defines the webGL uniform location where to store the value
  35948. * @param x defines the 1st component of the value
  35949. * @param y defines the 2nd component of the value
  35950. * @param z defines the 3rd component of the value
  35951. */
  35952. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  35953. /**
  35954. * Set the value of an uniform to a vec4
  35955. * @param uniform defines the webGL uniform location where to store the value
  35956. * @param x defines the 1st component of the value
  35957. * @param y defines the 2nd component of the value
  35958. * @param z defines the 3rd component of the value
  35959. * @param w defines the 4th component of the value
  35960. */
  35961. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  35962. /**
  35963. * Apply all cached states (depth, culling, stencil and alpha)
  35964. */
  35965. applyStates(): void;
  35966. /**
  35967. * Enable or disable color writing
  35968. * @param enable defines the state to set
  35969. */
  35970. setColorWrite(enable: boolean): void;
  35971. /**
  35972. * Gets a boolean indicating if color writing is enabled
  35973. * @returns the current color writing state
  35974. */
  35975. getColorWrite(): boolean;
  35976. /**
  35977. * Gets the depth culling state manager
  35978. */
  35979. get depthCullingState(): DepthCullingState;
  35980. /**
  35981. * Gets the alpha state manager
  35982. */
  35983. get alphaState(): AlphaState;
  35984. /**
  35985. * Gets the stencil state manager
  35986. */
  35987. get stencilState(): StencilState;
  35988. /**
  35989. * Clears the list of texture accessible through engine.
  35990. * This can help preventing texture load conflict due to name collision.
  35991. */
  35992. clearInternalTexturesCache(): void;
  35993. /**
  35994. * Force the entire cache to be cleared
  35995. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  35996. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  35997. */
  35998. wipeCaches(bruteForce?: boolean): void;
  35999. /** @hidden */
  36000. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  36001. min: number;
  36002. mag: number;
  36003. };
  36004. /** @hidden */
  36005. _createTexture(): WebGLTexture;
  36006. /**
  36007. * Usually called from Texture.ts.
  36008. * Passed information to create a WebGLTexture
  36009. * @param url defines a value which contains one of the following:
  36010. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  36011. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  36012. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  36013. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  36014. * @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)
  36015. * @param scene needed for loading to the correct scene
  36016. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  36017. * @param onLoad optional callback to be called upon successful completion
  36018. * @param onError optional callback to be called upon failure
  36019. * @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
  36020. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  36021. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  36022. * @param forcedExtension defines the extension to use to pick the right loader
  36023. * @param mimeType defines an optional mime type
  36024. * @returns a InternalTexture for assignment back into BABYLON.Texture
  36025. */
  36026. 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;
  36027. /**
  36028. * Loads an image as an HTMLImageElement.
  36029. * @param input url string, ArrayBuffer, or Blob to load
  36030. * @param onLoad callback called when the image successfully loads
  36031. * @param onError callback called when the image fails to load
  36032. * @param offlineProvider offline provider for caching
  36033. * @param mimeType optional mime type
  36034. * @returns the HTMLImageElement of the loaded image
  36035. * @hidden
  36036. */
  36037. 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>;
  36038. /**
  36039. * @hidden
  36040. */
  36041. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36042. private _unpackFlipYCached;
  36043. /**
  36044. * In case you are sharing the context with other applications, it might
  36045. * be interested to not cache the unpack flip y state to ensure a consistent
  36046. * value would be set.
  36047. */
  36048. enableUnpackFlipYCached: boolean;
  36049. /** @hidden */
  36050. _unpackFlipY(value: boolean): void;
  36051. /** @hidden */
  36052. _getUnpackAlignement(): number;
  36053. private _getTextureTarget;
  36054. /**
  36055. * Update the sampling mode of a given texture
  36056. * @param samplingMode defines the required sampling mode
  36057. * @param texture defines the texture to update
  36058. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36059. */
  36060. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36061. /**
  36062. * Update the sampling mode of a given texture
  36063. * @param texture defines the texture to update
  36064. * @param wrapU defines the texture wrap mode of the u coordinates
  36065. * @param wrapV defines the texture wrap mode of the v coordinates
  36066. * @param wrapR defines the texture wrap mode of the r coordinates
  36067. */
  36068. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36069. /** @hidden */
  36070. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36071. width: number;
  36072. height: number;
  36073. layers?: number;
  36074. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36075. /** @hidden */
  36076. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36077. /** @hidden */
  36078. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36079. /**
  36080. * Update a portion of an internal texture
  36081. * @param texture defines the texture to update
  36082. * @param imageData defines the data to store into the texture
  36083. * @param xOffset defines the x coordinates of the update rectangle
  36084. * @param yOffset defines the y coordinates of the update rectangle
  36085. * @param width defines the width of the update rectangle
  36086. * @param height defines the height of the update rectangle
  36087. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36088. * @param lod defines the lod level to update (0 by default)
  36089. */
  36090. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36091. /** @hidden */
  36092. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36093. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36094. private _prepareWebGLTexture;
  36095. /** @hidden */
  36096. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36097. private _getDepthStencilBuffer;
  36098. /** @hidden */
  36099. _releaseFramebufferObjects(texture: InternalTexture): void;
  36100. /** @hidden */
  36101. _releaseTexture(texture: InternalTexture): void;
  36102. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36103. protected _setProgram(program: WebGLProgram): void;
  36104. protected _boundUniforms: {
  36105. [key: number]: WebGLUniformLocation;
  36106. };
  36107. /**
  36108. * Binds an effect to the webGL context
  36109. * @param effect defines the effect to bind
  36110. */
  36111. bindSamplers(effect: Effect): void;
  36112. private _activateCurrentTexture;
  36113. /** @hidden */
  36114. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36115. /** @hidden */
  36116. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36117. /**
  36118. * Unbind all textures from the webGL context
  36119. */
  36120. unbindAllTextures(): void;
  36121. /**
  36122. * Sets a texture to the according uniform.
  36123. * @param channel The texture channel
  36124. * @param uniform The uniform to set
  36125. * @param texture The texture to apply
  36126. */
  36127. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36128. private _bindSamplerUniformToChannel;
  36129. private _getTextureWrapMode;
  36130. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36131. /**
  36132. * Sets an array of texture to the webGL context
  36133. * @param channel defines the channel where the texture array must be set
  36134. * @param uniform defines the associated uniform location
  36135. * @param textures defines the array of textures to bind
  36136. */
  36137. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36138. /** @hidden */
  36139. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36140. private _setTextureParameterFloat;
  36141. private _setTextureParameterInteger;
  36142. /**
  36143. * Unbind all vertex attributes from the webGL context
  36144. */
  36145. unbindAllAttributes(): void;
  36146. /**
  36147. * 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
  36148. */
  36149. releaseEffects(): void;
  36150. /**
  36151. * Dispose and release all associated resources
  36152. */
  36153. dispose(): void;
  36154. /**
  36155. * Attach a new callback raised when context lost event is fired
  36156. * @param callback defines the callback to call
  36157. */
  36158. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36159. /**
  36160. * Attach a new callback raised when context restored event is fired
  36161. * @param callback defines the callback to call
  36162. */
  36163. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36164. /**
  36165. * Get the current error code of the webGL context
  36166. * @returns the error code
  36167. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36168. */
  36169. getError(): number;
  36170. private _canRenderToFloatFramebuffer;
  36171. private _canRenderToHalfFloatFramebuffer;
  36172. private _canRenderToFramebuffer;
  36173. /** @hidden */
  36174. _getWebGLTextureType(type: number): number;
  36175. /** @hidden */
  36176. _getInternalFormat(format: number): number;
  36177. /** @hidden */
  36178. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36179. /** @hidden */
  36180. _getRGBAMultiSampleBufferFormat(type: number): number;
  36181. /** @hidden */
  36182. _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;
  36183. /**
  36184. * Loads a file from a url
  36185. * @param url url to load
  36186. * @param onSuccess callback called when the file successfully loads
  36187. * @param onProgress callback called while file is loading (if the server supports this mode)
  36188. * @param offlineProvider defines the offline provider for caching
  36189. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36190. * @param onError callback called when the file fails to load
  36191. * @returns a file request object
  36192. * @hidden
  36193. */
  36194. 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;
  36195. /**
  36196. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36197. * @param x defines the x coordinate of the rectangle where pixels must be read
  36198. * @param y defines the y coordinate of the rectangle where pixels must be read
  36199. * @param width defines the width of the rectangle where pixels must be read
  36200. * @param height defines the height of the rectangle where pixels must be read
  36201. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36202. * @returns a Uint8Array containing RGBA colors
  36203. */
  36204. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36205. private static _isSupported;
  36206. /**
  36207. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36208. * @returns true if the engine can be created
  36209. * @ignorenaming
  36210. */
  36211. static isSupported(): boolean;
  36212. /**
  36213. * Find the next highest power of two.
  36214. * @param x Number to start search from.
  36215. * @return Next highest power of two.
  36216. */
  36217. static CeilingPOT(x: number): number;
  36218. /**
  36219. * Find the next lowest power of two.
  36220. * @param x Number to start search from.
  36221. * @return Next lowest power of two.
  36222. */
  36223. static FloorPOT(x: number): number;
  36224. /**
  36225. * Find the nearest power of two.
  36226. * @param x Number to start search from.
  36227. * @return Next nearest power of two.
  36228. */
  36229. static NearestPOT(x: number): number;
  36230. /**
  36231. * Get the closest exponent of two
  36232. * @param value defines the value to approximate
  36233. * @param max defines the maximum value to return
  36234. * @param mode defines how to define the closest value
  36235. * @returns closest exponent of two of the given value
  36236. */
  36237. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36238. /**
  36239. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36240. * @param func - the function to be called
  36241. * @param requester - the object that will request the next frame. Falls back to window.
  36242. * @returns frame number
  36243. */
  36244. static QueueNewFrame(func: () => void, requester?: any): number;
  36245. /**
  36246. * Gets host document
  36247. * @returns the host document object
  36248. */
  36249. getHostDocument(): Nullable<Document>;
  36250. }
  36251. }
  36252. declare module BABYLON {
  36253. /**
  36254. * Class representing spherical harmonics coefficients to the 3rd degree
  36255. */
  36256. export class SphericalHarmonics {
  36257. /**
  36258. * Defines whether or not the harmonics have been prescaled for rendering.
  36259. */
  36260. preScaled: boolean;
  36261. /**
  36262. * The l0,0 coefficients of the spherical harmonics
  36263. */
  36264. l00: Vector3;
  36265. /**
  36266. * The l1,-1 coefficients of the spherical harmonics
  36267. */
  36268. l1_1: Vector3;
  36269. /**
  36270. * The l1,0 coefficients of the spherical harmonics
  36271. */
  36272. l10: Vector3;
  36273. /**
  36274. * The l1,1 coefficients of the spherical harmonics
  36275. */
  36276. l11: Vector3;
  36277. /**
  36278. * The l2,-2 coefficients of the spherical harmonics
  36279. */
  36280. l2_2: Vector3;
  36281. /**
  36282. * The l2,-1 coefficients of the spherical harmonics
  36283. */
  36284. l2_1: Vector3;
  36285. /**
  36286. * The l2,0 coefficients of the spherical harmonics
  36287. */
  36288. l20: Vector3;
  36289. /**
  36290. * The l2,1 coefficients of the spherical harmonics
  36291. */
  36292. l21: Vector3;
  36293. /**
  36294. * The l2,2 coefficients of the spherical harmonics
  36295. */
  36296. l22: Vector3;
  36297. /**
  36298. * Adds a light to the spherical harmonics
  36299. * @param direction the direction of the light
  36300. * @param color the color of the light
  36301. * @param deltaSolidAngle the delta solid angle of the light
  36302. */
  36303. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36304. /**
  36305. * Scales the spherical harmonics by the given amount
  36306. * @param scale the amount to scale
  36307. */
  36308. scaleInPlace(scale: number): void;
  36309. /**
  36310. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36311. *
  36312. * ```
  36313. * E_lm = A_l * L_lm
  36314. * ```
  36315. *
  36316. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36317. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36318. * the scaling factors are given in equation 9.
  36319. */
  36320. convertIncidentRadianceToIrradiance(): void;
  36321. /**
  36322. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36323. *
  36324. * ```
  36325. * L = (1/pi) * E * rho
  36326. * ```
  36327. *
  36328. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36329. */
  36330. convertIrradianceToLambertianRadiance(): void;
  36331. /**
  36332. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36333. * required operations at run time.
  36334. *
  36335. * This is simply done by scaling back the SH with Ylm constants parameter.
  36336. * The trigonometric part being applied by the shader at run time.
  36337. */
  36338. preScaleForRendering(): void;
  36339. /**
  36340. * Constructs a spherical harmonics from an array.
  36341. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36342. * @returns the spherical harmonics
  36343. */
  36344. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36345. /**
  36346. * Gets the spherical harmonics from polynomial
  36347. * @param polynomial the spherical polynomial
  36348. * @returns the spherical harmonics
  36349. */
  36350. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36351. }
  36352. /**
  36353. * Class representing spherical polynomial coefficients to the 3rd degree
  36354. */
  36355. export class SphericalPolynomial {
  36356. private _harmonics;
  36357. /**
  36358. * The spherical harmonics used to create the polynomials.
  36359. */
  36360. get preScaledHarmonics(): SphericalHarmonics;
  36361. /**
  36362. * The x coefficients of the spherical polynomial
  36363. */
  36364. x: Vector3;
  36365. /**
  36366. * The y coefficients of the spherical polynomial
  36367. */
  36368. y: Vector3;
  36369. /**
  36370. * The z coefficients of the spherical polynomial
  36371. */
  36372. z: Vector3;
  36373. /**
  36374. * The xx coefficients of the spherical polynomial
  36375. */
  36376. xx: Vector3;
  36377. /**
  36378. * The yy coefficients of the spherical polynomial
  36379. */
  36380. yy: Vector3;
  36381. /**
  36382. * The zz coefficients of the spherical polynomial
  36383. */
  36384. zz: Vector3;
  36385. /**
  36386. * The xy coefficients of the spherical polynomial
  36387. */
  36388. xy: Vector3;
  36389. /**
  36390. * The yz coefficients of the spherical polynomial
  36391. */
  36392. yz: Vector3;
  36393. /**
  36394. * The zx coefficients of the spherical polynomial
  36395. */
  36396. zx: Vector3;
  36397. /**
  36398. * Adds an ambient color to the spherical polynomial
  36399. * @param color the color to add
  36400. */
  36401. addAmbient(color: Color3): void;
  36402. /**
  36403. * Scales the spherical polynomial by the given amount
  36404. * @param scale the amount to scale
  36405. */
  36406. scaleInPlace(scale: number): void;
  36407. /**
  36408. * Gets the spherical polynomial from harmonics
  36409. * @param harmonics the spherical harmonics
  36410. * @returns the spherical polynomial
  36411. */
  36412. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36413. /**
  36414. * Constructs a spherical polynomial from an array.
  36415. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36416. * @returns the spherical polynomial
  36417. */
  36418. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36419. }
  36420. }
  36421. declare module BABYLON {
  36422. /**
  36423. * Defines the source of the internal texture
  36424. */
  36425. export enum InternalTextureSource {
  36426. /**
  36427. * The source of the texture data is unknown
  36428. */
  36429. Unknown = 0,
  36430. /**
  36431. * Texture data comes from an URL
  36432. */
  36433. Url = 1,
  36434. /**
  36435. * Texture data is only used for temporary storage
  36436. */
  36437. Temp = 2,
  36438. /**
  36439. * Texture data comes from raw data (ArrayBuffer)
  36440. */
  36441. Raw = 3,
  36442. /**
  36443. * Texture content is dynamic (video or dynamic texture)
  36444. */
  36445. Dynamic = 4,
  36446. /**
  36447. * Texture content is generated by rendering to it
  36448. */
  36449. RenderTarget = 5,
  36450. /**
  36451. * Texture content is part of a multi render target process
  36452. */
  36453. MultiRenderTarget = 6,
  36454. /**
  36455. * Texture data comes from a cube data file
  36456. */
  36457. Cube = 7,
  36458. /**
  36459. * Texture data comes from a raw cube data
  36460. */
  36461. CubeRaw = 8,
  36462. /**
  36463. * Texture data come from a prefiltered cube data file
  36464. */
  36465. CubePrefiltered = 9,
  36466. /**
  36467. * Texture content is raw 3D data
  36468. */
  36469. Raw3D = 10,
  36470. /**
  36471. * Texture content is raw 2D array data
  36472. */
  36473. Raw2DArray = 11,
  36474. /**
  36475. * Texture content is a depth texture
  36476. */
  36477. Depth = 12,
  36478. /**
  36479. * Texture data comes from a raw cube data encoded with RGBD
  36480. */
  36481. CubeRawRGBD = 13
  36482. }
  36483. /**
  36484. * Class used to store data associated with WebGL texture data for the engine
  36485. * This class should not be used directly
  36486. */
  36487. export class InternalTexture {
  36488. /** @hidden */
  36489. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36490. /**
  36491. * Defines if the texture is ready
  36492. */
  36493. isReady: boolean;
  36494. /**
  36495. * Defines if the texture is a cube texture
  36496. */
  36497. isCube: boolean;
  36498. /**
  36499. * Defines if the texture contains 3D data
  36500. */
  36501. is3D: boolean;
  36502. /**
  36503. * Defines if the texture contains 2D array data
  36504. */
  36505. is2DArray: boolean;
  36506. /**
  36507. * Defines if the texture contains multiview data
  36508. */
  36509. isMultiview: boolean;
  36510. /**
  36511. * Gets the URL used to load this texture
  36512. */
  36513. url: string;
  36514. /**
  36515. * Gets the sampling mode of the texture
  36516. */
  36517. samplingMode: number;
  36518. /**
  36519. * Gets a boolean indicating if the texture needs mipmaps generation
  36520. */
  36521. generateMipMaps: boolean;
  36522. /**
  36523. * Gets the number of samples used by the texture (WebGL2+ only)
  36524. */
  36525. samples: number;
  36526. /**
  36527. * Gets the type of the texture (int, float...)
  36528. */
  36529. type: number;
  36530. /**
  36531. * Gets the format of the texture (RGB, RGBA...)
  36532. */
  36533. format: number;
  36534. /**
  36535. * Observable called when the texture is loaded
  36536. */
  36537. onLoadedObservable: Observable<InternalTexture>;
  36538. /**
  36539. * Gets the width of the texture
  36540. */
  36541. width: number;
  36542. /**
  36543. * Gets the height of the texture
  36544. */
  36545. height: number;
  36546. /**
  36547. * Gets the depth of the texture
  36548. */
  36549. depth: number;
  36550. /**
  36551. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36552. */
  36553. baseWidth: number;
  36554. /**
  36555. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36556. */
  36557. baseHeight: number;
  36558. /**
  36559. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36560. */
  36561. baseDepth: number;
  36562. /**
  36563. * Gets a boolean indicating if the texture is inverted on Y axis
  36564. */
  36565. invertY: boolean;
  36566. /** @hidden */
  36567. _invertVScale: boolean;
  36568. /** @hidden */
  36569. _associatedChannel: number;
  36570. /** @hidden */
  36571. _source: InternalTextureSource;
  36572. /** @hidden */
  36573. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36574. /** @hidden */
  36575. _bufferView: Nullable<ArrayBufferView>;
  36576. /** @hidden */
  36577. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36578. /** @hidden */
  36579. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36580. /** @hidden */
  36581. _size: number;
  36582. /** @hidden */
  36583. _extension: string;
  36584. /** @hidden */
  36585. _files: Nullable<string[]>;
  36586. /** @hidden */
  36587. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36588. /** @hidden */
  36589. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36590. /** @hidden */
  36591. _framebuffer: Nullable<WebGLFramebuffer>;
  36592. /** @hidden */
  36593. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36594. /** @hidden */
  36595. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36596. /** @hidden */
  36597. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36598. /** @hidden */
  36599. _attachments: Nullable<number[]>;
  36600. /** @hidden */
  36601. _textureArray: Nullable<InternalTexture[]>;
  36602. /** @hidden */
  36603. _cachedCoordinatesMode: Nullable<number>;
  36604. /** @hidden */
  36605. _cachedWrapU: Nullable<number>;
  36606. /** @hidden */
  36607. _cachedWrapV: Nullable<number>;
  36608. /** @hidden */
  36609. _cachedWrapR: Nullable<number>;
  36610. /** @hidden */
  36611. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36612. /** @hidden */
  36613. _isDisabled: boolean;
  36614. /** @hidden */
  36615. _compression: Nullable<string>;
  36616. /** @hidden */
  36617. _generateStencilBuffer: boolean;
  36618. /** @hidden */
  36619. _generateDepthBuffer: boolean;
  36620. /** @hidden */
  36621. _comparisonFunction: number;
  36622. /** @hidden */
  36623. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36624. /** @hidden */
  36625. _lodGenerationScale: number;
  36626. /** @hidden */
  36627. _lodGenerationOffset: number;
  36628. /** @hidden */
  36629. _depthStencilTexture: Nullable<InternalTexture>;
  36630. /** @hidden */
  36631. _colorTextureArray: Nullable<WebGLTexture>;
  36632. /** @hidden */
  36633. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36634. /** @hidden */
  36635. _lodTextureHigh: Nullable<BaseTexture>;
  36636. /** @hidden */
  36637. _lodTextureMid: Nullable<BaseTexture>;
  36638. /** @hidden */
  36639. _lodTextureLow: Nullable<BaseTexture>;
  36640. /** @hidden */
  36641. _isRGBD: boolean;
  36642. /** @hidden */
  36643. _linearSpecularLOD: boolean;
  36644. /** @hidden */
  36645. _irradianceTexture: Nullable<BaseTexture>;
  36646. /** @hidden */
  36647. _webGLTexture: Nullable<WebGLTexture>;
  36648. /** @hidden */
  36649. _references: number;
  36650. private _engine;
  36651. /**
  36652. * Gets the Engine the texture belongs to.
  36653. * @returns The babylon engine
  36654. */
  36655. getEngine(): ThinEngine;
  36656. /**
  36657. * Gets the data source type of the texture
  36658. */
  36659. get source(): InternalTextureSource;
  36660. /**
  36661. * Creates a new InternalTexture
  36662. * @param engine defines the engine to use
  36663. * @param source defines the type of data that will be used
  36664. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36665. */
  36666. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36667. /**
  36668. * Increments the number of references (ie. the number of Texture that point to it)
  36669. */
  36670. incrementReferences(): void;
  36671. /**
  36672. * Change the size of the texture (not the size of the content)
  36673. * @param width defines the new width
  36674. * @param height defines the new height
  36675. * @param depth defines the new depth (1 by default)
  36676. */
  36677. updateSize(width: int, height: int, depth?: int): void;
  36678. /** @hidden */
  36679. _rebuild(): void;
  36680. /** @hidden */
  36681. _swapAndDie(target: InternalTexture): void;
  36682. /**
  36683. * Dispose the current allocated resources
  36684. */
  36685. dispose(): void;
  36686. }
  36687. }
  36688. declare module BABYLON {
  36689. /**
  36690. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36691. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36692. */
  36693. export class Analyser {
  36694. /**
  36695. * Gets or sets the smoothing
  36696. * @ignorenaming
  36697. */
  36698. SMOOTHING: number;
  36699. /**
  36700. * Gets or sets the FFT table size
  36701. * @ignorenaming
  36702. */
  36703. FFT_SIZE: number;
  36704. /**
  36705. * Gets or sets the bar graph amplitude
  36706. * @ignorenaming
  36707. */
  36708. BARGRAPHAMPLITUDE: number;
  36709. /**
  36710. * Gets or sets the position of the debug canvas
  36711. * @ignorenaming
  36712. */
  36713. DEBUGCANVASPOS: {
  36714. x: number;
  36715. y: number;
  36716. };
  36717. /**
  36718. * Gets or sets the debug canvas size
  36719. * @ignorenaming
  36720. */
  36721. DEBUGCANVASSIZE: {
  36722. width: number;
  36723. height: number;
  36724. };
  36725. private _byteFreqs;
  36726. private _byteTime;
  36727. private _floatFreqs;
  36728. private _webAudioAnalyser;
  36729. private _debugCanvas;
  36730. private _debugCanvasContext;
  36731. private _scene;
  36732. private _registerFunc;
  36733. private _audioEngine;
  36734. /**
  36735. * Creates a new analyser
  36736. * @param scene defines hosting scene
  36737. */
  36738. constructor(scene: Scene);
  36739. /**
  36740. * Get the number of data values you will have to play with for the visualization
  36741. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36742. * @returns a number
  36743. */
  36744. getFrequencyBinCount(): number;
  36745. /**
  36746. * Gets the current frequency data as a byte array
  36747. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36748. * @returns a Uint8Array
  36749. */
  36750. getByteFrequencyData(): Uint8Array;
  36751. /**
  36752. * Gets the current waveform as a byte array
  36753. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  36754. * @returns a Uint8Array
  36755. */
  36756. getByteTimeDomainData(): Uint8Array;
  36757. /**
  36758. * Gets the current frequency data as a float array
  36759. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36760. * @returns a Float32Array
  36761. */
  36762. getFloatFrequencyData(): Float32Array;
  36763. /**
  36764. * Renders the debug canvas
  36765. */
  36766. drawDebugCanvas(): void;
  36767. /**
  36768. * Stops rendering the debug canvas and removes it
  36769. */
  36770. stopDebugCanvas(): void;
  36771. /**
  36772. * Connects two audio nodes
  36773. * @param inputAudioNode defines first node to connect
  36774. * @param outputAudioNode defines second node to connect
  36775. */
  36776. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  36777. /**
  36778. * Releases all associated resources
  36779. */
  36780. dispose(): void;
  36781. }
  36782. }
  36783. declare module BABYLON {
  36784. /**
  36785. * This represents an audio engine and it is responsible
  36786. * to play, synchronize and analyse sounds throughout the application.
  36787. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36788. */
  36789. export interface IAudioEngine extends IDisposable {
  36790. /**
  36791. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36792. */
  36793. readonly canUseWebAudio: boolean;
  36794. /**
  36795. * Gets the current AudioContext if available.
  36796. */
  36797. readonly audioContext: Nullable<AudioContext>;
  36798. /**
  36799. * The master gain node defines the global audio volume of your audio engine.
  36800. */
  36801. readonly masterGain: GainNode;
  36802. /**
  36803. * Gets whether or not mp3 are supported by your browser.
  36804. */
  36805. readonly isMP3supported: boolean;
  36806. /**
  36807. * Gets whether or not ogg are supported by your browser.
  36808. */
  36809. readonly isOGGsupported: boolean;
  36810. /**
  36811. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36812. * @ignoreNaming
  36813. */
  36814. WarnedWebAudioUnsupported: boolean;
  36815. /**
  36816. * Defines if the audio engine relies on a custom unlocked button.
  36817. * In this case, the embedded button will not be displayed.
  36818. */
  36819. useCustomUnlockedButton: boolean;
  36820. /**
  36821. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  36822. */
  36823. readonly unlocked: boolean;
  36824. /**
  36825. * Event raised when audio has been unlocked on the browser.
  36826. */
  36827. onAudioUnlockedObservable: Observable<AudioEngine>;
  36828. /**
  36829. * Event raised when audio has been locked on the browser.
  36830. */
  36831. onAudioLockedObservable: Observable<AudioEngine>;
  36832. /**
  36833. * Flags the audio engine in Locked state.
  36834. * This happens due to new browser policies preventing audio to autoplay.
  36835. */
  36836. lock(): void;
  36837. /**
  36838. * Unlocks the audio engine once a user action has been done on the dom.
  36839. * This is helpful to resume play once browser policies have been satisfied.
  36840. */
  36841. unlock(): void;
  36842. /**
  36843. * Gets the global volume sets on the master gain.
  36844. * @returns the global volume if set or -1 otherwise
  36845. */
  36846. getGlobalVolume(): number;
  36847. /**
  36848. * Sets the global volume of your experience (sets on the master gain).
  36849. * @param newVolume Defines the new global volume of the application
  36850. */
  36851. setGlobalVolume(newVolume: number): void;
  36852. /**
  36853. * Connect the audio engine to an audio analyser allowing some amazing
  36854. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36855. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36856. * @param analyser The analyser to connect to the engine
  36857. */
  36858. connectToAnalyser(analyser: Analyser): void;
  36859. }
  36860. /**
  36861. * This represents the default audio engine used in babylon.
  36862. * It is responsible to play, synchronize and analyse sounds throughout the application.
  36863. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36864. */
  36865. export class AudioEngine implements IAudioEngine {
  36866. private _audioContext;
  36867. private _audioContextInitialized;
  36868. private _muteButton;
  36869. private _hostElement;
  36870. /**
  36871. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36872. */
  36873. canUseWebAudio: boolean;
  36874. /**
  36875. * The master gain node defines the global audio volume of your audio engine.
  36876. */
  36877. masterGain: GainNode;
  36878. /**
  36879. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36880. * @ignoreNaming
  36881. */
  36882. WarnedWebAudioUnsupported: boolean;
  36883. /**
  36884. * Gets whether or not mp3 are supported by your browser.
  36885. */
  36886. isMP3supported: boolean;
  36887. /**
  36888. * Gets whether or not ogg are supported by your browser.
  36889. */
  36890. isOGGsupported: boolean;
  36891. /**
  36892. * Gets whether audio has been unlocked on the device.
  36893. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  36894. * a user interaction has happened.
  36895. */
  36896. unlocked: boolean;
  36897. /**
  36898. * Defines if the audio engine relies on a custom unlocked button.
  36899. * In this case, the embedded button will not be displayed.
  36900. */
  36901. useCustomUnlockedButton: boolean;
  36902. /**
  36903. * Event raised when audio has been unlocked on the browser.
  36904. */
  36905. onAudioUnlockedObservable: Observable<AudioEngine>;
  36906. /**
  36907. * Event raised when audio has been locked on the browser.
  36908. */
  36909. onAudioLockedObservable: Observable<AudioEngine>;
  36910. /**
  36911. * Gets the current AudioContext if available.
  36912. */
  36913. get audioContext(): Nullable<AudioContext>;
  36914. private _connectedAnalyser;
  36915. /**
  36916. * Instantiates a new audio engine.
  36917. *
  36918. * There should be only one per page as some browsers restrict the number
  36919. * of audio contexts you can create.
  36920. * @param hostElement defines the host element where to display the mute icon if necessary
  36921. */
  36922. constructor(hostElement?: Nullable<HTMLElement>);
  36923. /**
  36924. * Flags the audio engine in Locked state.
  36925. * This happens due to new browser policies preventing audio to autoplay.
  36926. */
  36927. lock(): void;
  36928. /**
  36929. * Unlocks the audio engine once a user action has been done on the dom.
  36930. * This is helpful to resume play once browser policies have been satisfied.
  36931. */
  36932. unlock(): void;
  36933. private _resumeAudioContext;
  36934. private _initializeAudioContext;
  36935. private _tryToRun;
  36936. private _triggerRunningState;
  36937. private _triggerSuspendedState;
  36938. private _displayMuteButton;
  36939. private _moveButtonToTopLeft;
  36940. private _onResize;
  36941. private _hideMuteButton;
  36942. /**
  36943. * Destroy and release the resources associated with the audio ccontext.
  36944. */
  36945. dispose(): void;
  36946. /**
  36947. * Gets the global volume sets on the master gain.
  36948. * @returns the global volume if set or -1 otherwise
  36949. */
  36950. getGlobalVolume(): number;
  36951. /**
  36952. * Sets the global volume of your experience (sets on the master gain).
  36953. * @param newVolume Defines the new global volume of the application
  36954. */
  36955. setGlobalVolume(newVolume: number): void;
  36956. /**
  36957. * Connect the audio engine to an audio analyser allowing some amazing
  36958. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36959. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36960. * @param analyser The analyser to connect to the engine
  36961. */
  36962. connectToAnalyser(analyser: Analyser): void;
  36963. }
  36964. }
  36965. declare module BABYLON {
  36966. /**
  36967. * Interface used to present a loading screen while loading a scene
  36968. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36969. */
  36970. export interface ILoadingScreen {
  36971. /**
  36972. * Function called to display the loading screen
  36973. */
  36974. displayLoadingUI: () => void;
  36975. /**
  36976. * Function called to hide the loading screen
  36977. */
  36978. hideLoadingUI: () => void;
  36979. /**
  36980. * Gets or sets the color to use for the background
  36981. */
  36982. loadingUIBackgroundColor: string;
  36983. /**
  36984. * Gets or sets the text to display while loading
  36985. */
  36986. loadingUIText: string;
  36987. }
  36988. /**
  36989. * Class used for the default loading screen
  36990. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36991. */
  36992. export class DefaultLoadingScreen implements ILoadingScreen {
  36993. private _renderingCanvas;
  36994. private _loadingText;
  36995. private _loadingDivBackgroundColor;
  36996. private _loadingDiv;
  36997. private _loadingTextDiv;
  36998. /** Gets or sets the logo url to use for the default loading screen */
  36999. static DefaultLogoUrl: string;
  37000. /** Gets or sets the spinner url to use for the default loading screen */
  37001. static DefaultSpinnerUrl: string;
  37002. /**
  37003. * Creates a new default loading screen
  37004. * @param _renderingCanvas defines the canvas used to render the scene
  37005. * @param _loadingText defines the default text to display
  37006. * @param _loadingDivBackgroundColor defines the default background color
  37007. */
  37008. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  37009. /**
  37010. * Function called to display the loading screen
  37011. */
  37012. displayLoadingUI(): void;
  37013. /**
  37014. * Function called to hide the loading screen
  37015. */
  37016. hideLoadingUI(): void;
  37017. /**
  37018. * Gets or sets the text to display while loading
  37019. */
  37020. set loadingUIText(text: string);
  37021. get loadingUIText(): string;
  37022. /**
  37023. * Gets or sets the color to use for the background
  37024. */
  37025. get loadingUIBackgroundColor(): string;
  37026. set loadingUIBackgroundColor(color: string);
  37027. private _resizeLoadingUI;
  37028. }
  37029. }
  37030. declare module BABYLON {
  37031. /**
  37032. * Interface for any object that can request an animation frame
  37033. */
  37034. export interface ICustomAnimationFrameRequester {
  37035. /**
  37036. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37037. */
  37038. renderFunction?: Function;
  37039. /**
  37040. * Called to request the next frame to render to
  37041. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37042. */
  37043. requestAnimationFrame: Function;
  37044. /**
  37045. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37046. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37047. */
  37048. requestID?: number;
  37049. }
  37050. }
  37051. declare module BABYLON {
  37052. /**
  37053. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37054. */
  37055. export class PerformanceMonitor {
  37056. private _enabled;
  37057. private _rollingFrameTime;
  37058. private _lastFrameTimeMs;
  37059. /**
  37060. * constructor
  37061. * @param frameSampleSize The number of samples required to saturate the sliding window
  37062. */
  37063. constructor(frameSampleSize?: number);
  37064. /**
  37065. * Samples current frame
  37066. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37067. */
  37068. sampleFrame(timeMs?: number): void;
  37069. /**
  37070. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37071. */
  37072. get averageFrameTime(): number;
  37073. /**
  37074. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37075. */
  37076. get averageFrameTimeVariance(): number;
  37077. /**
  37078. * Returns the frame time of the most recent frame
  37079. */
  37080. get instantaneousFrameTime(): number;
  37081. /**
  37082. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37083. */
  37084. get averageFPS(): number;
  37085. /**
  37086. * Returns the average framerate in frames per second using the most recent frame time
  37087. */
  37088. get instantaneousFPS(): number;
  37089. /**
  37090. * Returns true if enough samples have been taken to completely fill the sliding window
  37091. */
  37092. get isSaturated(): boolean;
  37093. /**
  37094. * Enables contributions to the sliding window sample set
  37095. */
  37096. enable(): void;
  37097. /**
  37098. * Disables contributions to the sliding window sample set
  37099. * Samples will not be interpolated over the disabled period
  37100. */
  37101. disable(): void;
  37102. /**
  37103. * Returns true if sampling is enabled
  37104. */
  37105. get isEnabled(): boolean;
  37106. /**
  37107. * Resets performance monitor
  37108. */
  37109. reset(): void;
  37110. }
  37111. /**
  37112. * RollingAverage
  37113. *
  37114. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37115. */
  37116. export class RollingAverage {
  37117. /**
  37118. * Current average
  37119. */
  37120. average: number;
  37121. /**
  37122. * Current variance
  37123. */
  37124. variance: number;
  37125. protected _samples: Array<number>;
  37126. protected _sampleCount: number;
  37127. protected _pos: number;
  37128. protected _m2: number;
  37129. /**
  37130. * constructor
  37131. * @param length The number of samples required to saturate the sliding window
  37132. */
  37133. constructor(length: number);
  37134. /**
  37135. * Adds a sample to the sample set
  37136. * @param v The sample value
  37137. */
  37138. add(v: number): void;
  37139. /**
  37140. * Returns previously added values or null if outside of history or outside the sliding window domain
  37141. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37142. * @return Value previously recorded with add() or null if outside of range
  37143. */
  37144. history(i: number): number;
  37145. /**
  37146. * Returns true if enough samples have been taken to completely fill the sliding window
  37147. * @return true if sample-set saturated
  37148. */
  37149. isSaturated(): boolean;
  37150. /**
  37151. * Resets the rolling average (equivalent to 0 samples taken so far)
  37152. */
  37153. reset(): void;
  37154. /**
  37155. * Wraps a value around the sample range boundaries
  37156. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37157. * @return Wrapped position in sample range
  37158. */
  37159. protected _wrapPosition(i: number): number;
  37160. }
  37161. }
  37162. declare module BABYLON {
  37163. /**
  37164. * This class is used to track a performance counter which is number based.
  37165. * The user has access to many properties which give statistics of different nature.
  37166. *
  37167. * The implementer can track two kinds of Performance Counter: time and count.
  37168. * 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.
  37169. * 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.
  37170. */
  37171. export class PerfCounter {
  37172. /**
  37173. * Gets or sets a global boolean to turn on and off all the counters
  37174. */
  37175. static Enabled: boolean;
  37176. /**
  37177. * Returns the smallest value ever
  37178. */
  37179. get min(): number;
  37180. /**
  37181. * Returns the biggest value ever
  37182. */
  37183. get max(): number;
  37184. /**
  37185. * Returns the average value since the performance counter is running
  37186. */
  37187. get average(): number;
  37188. /**
  37189. * Returns the average value of the last second the counter was monitored
  37190. */
  37191. get lastSecAverage(): number;
  37192. /**
  37193. * Returns the current value
  37194. */
  37195. get current(): number;
  37196. /**
  37197. * Gets the accumulated total
  37198. */
  37199. get total(): number;
  37200. /**
  37201. * Gets the total value count
  37202. */
  37203. get count(): number;
  37204. /**
  37205. * Creates a new counter
  37206. */
  37207. constructor();
  37208. /**
  37209. * Call this method to start monitoring a new frame.
  37210. * 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.
  37211. */
  37212. fetchNewFrame(): void;
  37213. /**
  37214. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37215. * @param newCount the count value to add to the monitored count
  37216. * @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.
  37217. */
  37218. addCount(newCount: number, fetchResult: boolean): void;
  37219. /**
  37220. * Start monitoring this performance counter
  37221. */
  37222. beginMonitoring(): void;
  37223. /**
  37224. * Compute the time lapsed since the previous beginMonitoring() call.
  37225. * @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
  37226. */
  37227. endMonitoring(newFrame?: boolean): void;
  37228. private _fetchResult;
  37229. private _startMonitoringTime;
  37230. private _min;
  37231. private _max;
  37232. private _average;
  37233. private _current;
  37234. private _totalValueCount;
  37235. private _totalAccumulated;
  37236. private _lastSecAverage;
  37237. private _lastSecAccumulated;
  37238. private _lastSecTime;
  37239. private _lastSecValueCount;
  37240. }
  37241. }
  37242. declare module BABYLON {
  37243. interface ThinEngine {
  37244. /** @hidden */
  37245. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37246. }
  37247. }
  37248. declare module BABYLON {
  37249. /**
  37250. * Defines the interface used by display changed events
  37251. */
  37252. export interface IDisplayChangedEventArgs {
  37253. /** Gets the vrDisplay object (if any) */
  37254. vrDisplay: Nullable<any>;
  37255. /** Gets a boolean indicating if webVR is supported */
  37256. vrSupported: boolean;
  37257. }
  37258. /**
  37259. * Defines the interface used by objects containing a viewport (like a camera)
  37260. */
  37261. interface IViewportOwnerLike {
  37262. /**
  37263. * Gets or sets the viewport
  37264. */
  37265. viewport: IViewportLike;
  37266. }
  37267. /**
  37268. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37269. */
  37270. export class Engine extends ThinEngine {
  37271. /** Defines that alpha blending is disabled */
  37272. static readonly ALPHA_DISABLE: number;
  37273. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37274. static readonly ALPHA_ADD: number;
  37275. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37276. static readonly ALPHA_COMBINE: number;
  37277. /** Defines that alpha blending to DEST - SRC * DEST */
  37278. static readonly ALPHA_SUBTRACT: number;
  37279. /** Defines that alpha blending to SRC * DEST */
  37280. static readonly ALPHA_MULTIPLY: number;
  37281. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37282. static readonly ALPHA_MAXIMIZED: number;
  37283. /** Defines that alpha blending to SRC + DEST */
  37284. static readonly ALPHA_ONEONE: number;
  37285. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37286. static readonly ALPHA_PREMULTIPLIED: number;
  37287. /**
  37288. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37289. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37290. */
  37291. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37292. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37293. static readonly ALPHA_INTERPOLATE: number;
  37294. /**
  37295. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37296. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37297. */
  37298. static readonly ALPHA_SCREENMODE: number;
  37299. /** Defines that the ressource is not delayed*/
  37300. static readonly DELAYLOADSTATE_NONE: number;
  37301. /** Defines that the ressource was successfully delay loaded */
  37302. static readonly DELAYLOADSTATE_LOADED: number;
  37303. /** Defines that the ressource is currently delay loading */
  37304. static readonly DELAYLOADSTATE_LOADING: number;
  37305. /** Defines that the ressource is delayed and has not started loading */
  37306. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37307. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37308. static readonly NEVER: number;
  37309. /** 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 */
  37310. static readonly ALWAYS: number;
  37311. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37312. static readonly LESS: number;
  37313. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37314. static readonly EQUAL: number;
  37315. /** 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 */
  37316. static readonly LEQUAL: number;
  37317. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37318. static readonly GREATER: number;
  37319. /** 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 */
  37320. static readonly GEQUAL: number;
  37321. /** 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 */
  37322. static readonly NOTEQUAL: number;
  37323. /** Passed to stencilOperation to specify that stencil value must be kept */
  37324. static readonly KEEP: number;
  37325. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37326. static readonly REPLACE: number;
  37327. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37328. static readonly INCR: number;
  37329. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37330. static readonly DECR: number;
  37331. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37332. static readonly INVERT: number;
  37333. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37334. static readonly INCR_WRAP: number;
  37335. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37336. static readonly DECR_WRAP: number;
  37337. /** Texture is not repeating outside of 0..1 UVs */
  37338. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37339. /** Texture is repeating outside of 0..1 UVs */
  37340. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37341. /** Texture is repeating and mirrored */
  37342. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37343. /** ALPHA */
  37344. static readonly TEXTUREFORMAT_ALPHA: number;
  37345. /** LUMINANCE */
  37346. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37347. /** LUMINANCE_ALPHA */
  37348. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37349. /** RGB */
  37350. static readonly TEXTUREFORMAT_RGB: number;
  37351. /** RGBA */
  37352. static readonly TEXTUREFORMAT_RGBA: number;
  37353. /** RED */
  37354. static readonly TEXTUREFORMAT_RED: number;
  37355. /** RED (2nd reference) */
  37356. static readonly TEXTUREFORMAT_R: number;
  37357. /** RG */
  37358. static readonly TEXTUREFORMAT_RG: number;
  37359. /** RED_INTEGER */
  37360. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37361. /** RED_INTEGER (2nd reference) */
  37362. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37363. /** RG_INTEGER */
  37364. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37365. /** RGB_INTEGER */
  37366. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37367. /** RGBA_INTEGER */
  37368. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37369. /** UNSIGNED_BYTE */
  37370. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37371. /** UNSIGNED_BYTE (2nd reference) */
  37372. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37373. /** FLOAT */
  37374. static readonly TEXTURETYPE_FLOAT: number;
  37375. /** HALF_FLOAT */
  37376. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37377. /** BYTE */
  37378. static readonly TEXTURETYPE_BYTE: number;
  37379. /** SHORT */
  37380. static readonly TEXTURETYPE_SHORT: number;
  37381. /** UNSIGNED_SHORT */
  37382. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37383. /** INT */
  37384. static readonly TEXTURETYPE_INT: number;
  37385. /** UNSIGNED_INT */
  37386. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37387. /** UNSIGNED_SHORT_4_4_4_4 */
  37388. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37389. /** UNSIGNED_SHORT_5_5_5_1 */
  37390. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37391. /** UNSIGNED_SHORT_5_6_5 */
  37392. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37393. /** UNSIGNED_INT_2_10_10_10_REV */
  37394. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37395. /** UNSIGNED_INT_24_8 */
  37396. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37397. /** UNSIGNED_INT_10F_11F_11F_REV */
  37398. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37399. /** UNSIGNED_INT_5_9_9_9_REV */
  37400. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37401. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37402. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37403. /** nearest is mag = nearest and min = nearest and mip = linear */
  37404. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37405. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37406. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37407. /** Trilinear is mag = linear and min = linear and mip = linear */
  37408. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37409. /** nearest is mag = nearest and min = nearest and mip = linear */
  37410. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37411. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37412. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37413. /** Trilinear is mag = linear and min = linear and mip = linear */
  37414. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37415. /** mag = nearest and min = nearest and mip = nearest */
  37416. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37417. /** mag = nearest and min = linear and mip = nearest */
  37418. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37419. /** mag = nearest and min = linear and mip = linear */
  37420. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37421. /** mag = nearest and min = linear and mip = none */
  37422. static readonly TEXTURE_NEAREST_LINEAR: number;
  37423. /** mag = nearest and min = nearest and mip = none */
  37424. static readonly TEXTURE_NEAREST_NEAREST: number;
  37425. /** mag = linear and min = nearest and mip = nearest */
  37426. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37427. /** mag = linear and min = nearest and mip = linear */
  37428. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37429. /** mag = linear and min = linear and mip = none */
  37430. static readonly TEXTURE_LINEAR_LINEAR: number;
  37431. /** mag = linear and min = nearest and mip = none */
  37432. static readonly TEXTURE_LINEAR_NEAREST: number;
  37433. /** Explicit coordinates mode */
  37434. static readonly TEXTURE_EXPLICIT_MODE: number;
  37435. /** Spherical coordinates mode */
  37436. static readonly TEXTURE_SPHERICAL_MODE: number;
  37437. /** Planar coordinates mode */
  37438. static readonly TEXTURE_PLANAR_MODE: number;
  37439. /** Cubic coordinates mode */
  37440. static readonly TEXTURE_CUBIC_MODE: number;
  37441. /** Projection coordinates mode */
  37442. static readonly TEXTURE_PROJECTION_MODE: number;
  37443. /** Skybox coordinates mode */
  37444. static readonly TEXTURE_SKYBOX_MODE: number;
  37445. /** Inverse Cubic coordinates mode */
  37446. static readonly TEXTURE_INVCUBIC_MODE: number;
  37447. /** Equirectangular coordinates mode */
  37448. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37449. /** Equirectangular Fixed coordinates mode */
  37450. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37451. /** Equirectangular Fixed Mirrored coordinates mode */
  37452. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37453. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37454. static readonly SCALEMODE_FLOOR: number;
  37455. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37456. static readonly SCALEMODE_NEAREST: number;
  37457. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37458. static readonly SCALEMODE_CEILING: number;
  37459. /**
  37460. * Returns the current npm package of the sdk
  37461. */
  37462. static get NpmPackage(): string;
  37463. /**
  37464. * Returns the current version of the framework
  37465. */
  37466. static get Version(): string;
  37467. /** Gets the list of created engines */
  37468. static get Instances(): Engine[];
  37469. /**
  37470. * Gets the latest created engine
  37471. */
  37472. static get LastCreatedEngine(): Nullable<Engine>;
  37473. /**
  37474. * Gets the latest created scene
  37475. */
  37476. static get LastCreatedScene(): Nullable<Scene>;
  37477. /**
  37478. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37479. * @param flag defines which part of the materials must be marked as dirty
  37480. * @param predicate defines a predicate used to filter which materials should be affected
  37481. */
  37482. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37483. /**
  37484. * Method called to create the default loading screen.
  37485. * This can be overriden in your own app.
  37486. * @param canvas The rendering canvas element
  37487. * @returns The loading screen
  37488. */
  37489. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37490. /**
  37491. * Method called to create the default rescale post process on each engine.
  37492. */
  37493. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37494. /**
  37495. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37496. **/
  37497. enableOfflineSupport: boolean;
  37498. /**
  37499. * 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)
  37500. **/
  37501. disableManifestCheck: boolean;
  37502. /**
  37503. * Gets the list of created scenes
  37504. */
  37505. scenes: Scene[];
  37506. /**
  37507. * Event raised when a new scene is created
  37508. */
  37509. onNewSceneAddedObservable: Observable<Scene>;
  37510. /**
  37511. * Gets the list of created postprocesses
  37512. */
  37513. postProcesses: PostProcess[];
  37514. /**
  37515. * Gets a boolean indicating if the pointer is currently locked
  37516. */
  37517. isPointerLock: boolean;
  37518. /**
  37519. * Observable event triggered each time the rendering canvas is resized
  37520. */
  37521. onResizeObservable: Observable<Engine>;
  37522. /**
  37523. * Observable event triggered each time the canvas loses focus
  37524. */
  37525. onCanvasBlurObservable: Observable<Engine>;
  37526. /**
  37527. * Observable event triggered each time the canvas gains focus
  37528. */
  37529. onCanvasFocusObservable: Observable<Engine>;
  37530. /**
  37531. * Observable event triggered each time the canvas receives pointerout event
  37532. */
  37533. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37534. /**
  37535. * Observable raised when the engine begins a new frame
  37536. */
  37537. onBeginFrameObservable: Observable<Engine>;
  37538. /**
  37539. * If set, will be used to request the next animation frame for the render loop
  37540. */
  37541. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37542. /**
  37543. * Observable raised when the engine ends the current frame
  37544. */
  37545. onEndFrameObservable: Observable<Engine>;
  37546. /**
  37547. * Observable raised when the engine is about to compile a shader
  37548. */
  37549. onBeforeShaderCompilationObservable: Observable<Engine>;
  37550. /**
  37551. * Observable raised when the engine has jsut compiled a shader
  37552. */
  37553. onAfterShaderCompilationObservable: Observable<Engine>;
  37554. /**
  37555. * Gets the audio engine
  37556. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37557. * @ignorenaming
  37558. */
  37559. static audioEngine: IAudioEngine;
  37560. /**
  37561. * Default AudioEngine factory responsible of creating the Audio Engine.
  37562. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37563. */
  37564. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37565. /**
  37566. * Default offline support factory responsible of creating a tool used to store data locally.
  37567. * By default, this will create a Database object if the workload has been embedded.
  37568. */
  37569. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37570. private _loadingScreen;
  37571. private _pointerLockRequested;
  37572. private _rescalePostProcess;
  37573. private _deterministicLockstep;
  37574. private _lockstepMaxSteps;
  37575. private _timeStep;
  37576. protected get _supportsHardwareTextureRescaling(): boolean;
  37577. private _fps;
  37578. private _deltaTime;
  37579. /** @hidden */
  37580. _drawCalls: PerfCounter;
  37581. /** 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 */
  37582. canvasTabIndex: number;
  37583. /**
  37584. * Turn this value on if you want to pause FPS computation when in background
  37585. */
  37586. disablePerformanceMonitorInBackground: boolean;
  37587. private _performanceMonitor;
  37588. /**
  37589. * Gets the performance monitor attached to this engine
  37590. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37591. */
  37592. get performanceMonitor(): PerformanceMonitor;
  37593. private _onFocus;
  37594. private _onBlur;
  37595. private _onCanvasPointerOut;
  37596. private _onCanvasBlur;
  37597. private _onCanvasFocus;
  37598. private _onFullscreenChange;
  37599. private _onPointerLockChange;
  37600. /**
  37601. * Gets the HTML element used to attach event listeners
  37602. * @returns a HTML element
  37603. */
  37604. getInputElement(): Nullable<HTMLElement>;
  37605. /**
  37606. * Creates a new engine
  37607. * @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
  37608. * @param antialias defines enable antialiasing (default: false)
  37609. * @param options defines further options to be sent to the getContext() function
  37610. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37611. */
  37612. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37613. /**
  37614. * Gets current aspect ratio
  37615. * @param viewportOwner defines the camera to use to get the aspect ratio
  37616. * @param useScreen defines if screen size must be used (or the current render target if any)
  37617. * @returns a number defining the aspect ratio
  37618. */
  37619. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37620. /**
  37621. * Gets current screen aspect ratio
  37622. * @returns a number defining the aspect ratio
  37623. */
  37624. getScreenAspectRatio(): number;
  37625. /**
  37626. * Gets the client rect of the HTML canvas attached with the current webGL context
  37627. * @returns a client rectanglee
  37628. */
  37629. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37630. /**
  37631. * Gets the client rect of the HTML element used for events
  37632. * @returns a client rectanglee
  37633. */
  37634. getInputElementClientRect(): Nullable<ClientRect>;
  37635. /**
  37636. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37637. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37638. * @returns true if engine is in deterministic lock step mode
  37639. */
  37640. isDeterministicLockStep(): boolean;
  37641. /**
  37642. * Gets the max steps when engine is running in deterministic lock step
  37643. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37644. * @returns the max steps
  37645. */
  37646. getLockstepMaxSteps(): number;
  37647. /**
  37648. * Returns the time in ms between steps when using deterministic lock step.
  37649. * @returns time step in (ms)
  37650. */
  37651. getTimeStep(): number;
  37652. /**
  37653. * Force the mipmap generation for the given render target texture
  37654. * @param texture defines the render target texture to use
  37655. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37656. */
  37657. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37658. /** States */
  37659. /**
  37660. * Set various states to the webGL context
  37661. * @param culling defines backface culling state
  37662. * @param zOffset defines the value to apply to zOffset (0 by default)
  37663. * @param force defines if states must be applied even if cache is up to date
  37664. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37665. */
  37666. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37667. /**
  37668. * Set the z offset to apply to current rendering
  37669. * @param value defines the offset to apply
  37670. */
  37671. setZOffset(value: number): void;
  37672. /**
  37673. * Gets the current value of the zOffset
  37674. * @returns the current zOffset state
  37675. */
  37676. getZOffset(): number;
  37677. /**
  37678. * Enable or disable depth buffering
  37679. * @param enable defines the state to set
  37680. */
  37681. setDepthBuffer(enable: boolean): void;
  37682. /**
  37683. * Gets a boolean indicating if depth writing is enabled
  37684. * @returns the current depth writing state
  37685. */
  37686. getDepthWrite(): boolean;
  37687. /**
  37688. * Enable or disable depth writing
  37689. * @param enable defines the state to set
  37690. */
  37691. setDepthWrite(enable: boolean): void;
  37692. /**
  37693. * Gets a boolean indicating if stencil buffer is enabled
  37694. * @returns the current stencil buffer state
  37695. */
  37696. getStencilBuffer(): boolean;
  37697. /**
  37698. * Enable or disable the stencil buffer
  37699. * @param enable defines if the stencil buffer must be enabled or disabled
  37700. */
  37701. setStencilBuffer(enable: boolean): void;
  37702. /**
  37703. * Gets the current stencil mask
  37704. * @returns a number defining the new stencil mask to use
  37705. */
  37706. getStencilMask(): number;
  37707. /**
  37708. * Sets the current stencil mask
  37709. * @param mask defines the new stencil mask to use
  37710. */
  37711. setStencilMask(mask: number): void;
  37712. /**
  37713. * Gets the current stencil function
  37714. * @returns a number defining the stencil function to use
  37715. */
  37716. getStencilFunction(): number;
  37717. /**
  37718. * Gets the current stencil reference value
  37719. * @returns a number defining the stencil reference value to use
  37720. */
  37721. getStencilFunctionReference(): number;
  37722. /**
  37723. * Gets the current stencil mask
  37724. * @returns a number defining the stencil mask to use
  37725. */
  37726. getStencilFunctionMask(): number;
  37727. /**
  37728. * Sets the current stencil function
  37729. * @param stencilFunc defines the new stencil function to use
  37730. */
  37731. setStencilFunction(stencilFunc: number): void;
  37732. /**
  37733. * Sets the current stencil reference
  37734. * @param reference defines the new stencil reference to use
  37735. */
  37736. setStencilFunctionReference(reference: number): void;
  37737. /**
  37738. * Sets the current stencil mask
  37739. * @param mask defines the new stencil mask to use
  37740. */
  37741. setStencilFunctionMask(mask: number): void;
  37742. /**
  37743. * Gets the current stencil operation when stencil fails
  37744. * @returns a number defining stencil operation to use when stencil fails
  37745. */
  37746. getStencilOperationFail(): number;
  37747. /**
  37748. * Gets the current stencil operation when depth fails
  37749. * @returns a number defining stencil operation to use when depth fails
  37750. */
  37751. getStencilOperationDepthFail(): number;
  37752. /**
  37753. * Gets the current stencil operation when stencil passes
  37754. * @returns a number defining stencil operation to use when stencil passes
  37755. */
  37756. getStencilOperationPass(): number;
  37757. /**
  37758. * Sets the stencil operation to use when stencil fails
  37759. * @param operation defines the stencil operation to use when stencil fails
  37760. */
  37761. setStencilOperationFail(operation: number): void;
  37762. /**
  37763. * Sets the stencil operation to use when depth fails
  37764. * @param operation defines the stencil operation to use when depth fails
  37765. */
  37766. setStencilOperationDepthFail(operation: number): void;
  37767. /**
  37768. * Sets the stencil operation to use when stencil passes
  37769. * @param operation defines the stencil operation to use when stencil passes
  37770. */
  37771. setStencilOperationPass(operation: number): void;
  37772. /**
  37773. * Sets a boolean indicating if the dithering state is enabled or disabled
  37774. * @param value defines the dithering state
  37775. */
  37776. setDitheringState(value: boolean): void;
  37777. /**
  37778. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  37779. * @param value defines the rasterizer state
  37780. */
  37781. setRasterizerState(value: boolean): void;
  37782. /**
  37783. * Gets the current depth function
  37784. * @returns a number defining the depth function
  37785. */
  37786. getDepthFunction(): Nullable<number>;
  37787. /**
  37788. * Sets the current depth function
  37789. * @param depthFunc defines the function to use
  37790. */
  37791. setDepthFunction(depthFunc: number): void;
  37792. /**
  37793. * Sets the current depth function to GREATER
  37794. */
  37795. setDepthFunctionToGreater(): void;
  37796. /**
  37797. * Sets the current depth function to GEQUAL
  37798. */
  37799. setDepthFunctionToGreaterOrEqual(): void;
  37800. /**
  37801. * Sets the current depth function to LESS
  37802. */
  37803. setDepthFunctionToLess(): void;
  37804. /**
  37805. * Sets the current depth function to LEQUAL
  37806. */
  37807. setDepthFunctionToLessOrEqual(): void;
  37808. private _cachedStencilBuffer;
  37809. private _cachedStencilFunction;
  37810. private _cachedStencilMask;
  37811. private _cachedStencilOperationPass;
  37812. private _cachedStencilOperationFail;
  37813. private _cachedStencilOperationDepthFail;
  37814. private _cachedStencilReference;
  37815. /**
  37816. * Caches the the state of the stencil buffer
  37817. */
  37818. cacheStencilState(): void;
  37819. /**
  37820. * Restores the state of the stencil buffer
  37821. */
  37822. restoreStencilState(): void;
  37823. /**
  37824. * Directly set the WebGL Viewport
  37825. * @param x defines the x coordinate of the viewport (in screen space)
  37826. * @param y defines the y coordinate of the viewport (in screen space)
  37827. * @param width defines the width of the viewport (in screen space)
  37828. * @param height defines the height of the viewport (in screen space)
  37829. * @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
  37830. */
  37831. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  37832. /**
  37833. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  37834. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37835. * @param y defines the y-coordinate of the corner of the clear rectangle
  37836. * @param width defines the width of the clear rectangle
  37837. * @param height defines the height of the clear rectangle
  37838. * @param clearColor defines the clear color
  37839. */
  37840. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  37841. /**
  37842. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  37843. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37844. * @param y defines the y-coordinate of the corner of the clear rectangle
  37845. * @param width defines the width of the clear rectangle
  37846. * @param height defines the height of the clear rectangle
  37847. */
  37848. enableScissor(x: number, y: number, width: number, height: number): void;
  37849. /**
  37850. * Disable previously set scissor test rectangle
  37851. */
  37852. disableScissor(): void;
  37853. protected _reportDrawCall(): void;
  37854. /**
  37855. * Initializes a webVR display and starts listening to display change events
  37856. * The onVRDisplayChangedObservable will be notified upon these changes
  37857. * @returns The onVRDisplayChangedObservable
  37858. */
  37859. initWebVR(): Observable<IDisplayChangedEventArgs>;
  37860. /** @hidden */
  37861. _prepareVRComponent(): void;
  37862. /** @hidden */
  37863. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  37864. /** @hidden */
  37865. _submitVRFrame(): void;
  37866. /**
  37867. * Call this function to leave webVR mode
  37868. * Will do nothing if webVR is not supported or if there is no webVR device
  37869. * @see https://doc.babylonjs.com/how_to/webvr_camera
  37870. */
  37871. disableVR(): void;
  37872. /**
  37873. * Gets a boolean indicating that the system is in VR mode and is presenting
  37874. * @returns true if VR mode is engaged
  37875. */
  37876. isVRPresenting(): boolean;
  37877. /** @hidden */
  37878. _requestVRFrame(): void;
  37879. /** @hidden */
  37880. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37881. /**
  37882. * Gets the source code of the vertex shader associated with a specific webGL program
  37883. * @param program defines the program to use
  37884. * @returns a string containing the source code of the vertex shader associated with the program
  37885. */
  37886. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  37887. /**
  37888. * Gets the source code of the fragment shader associated with a specific webGL program
  37889. * @param program defines the program to use
  37890. * @returns a string containing the source code of the fragment shader associated with the program
  37891. */
  37892. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  37893. /**
  37894. * Sets a depth stencil texture from a render target to the according uniform.
  37895. * @param channel The texture channel
  37896. * @param uniform The uniform to set
  37897. * @param texture The render target texture containing the depth stencil texture to apply
  37898. */
  37899. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  37900. /**
  37901. * Sets a texture to the webGL context from a postprocess
  37902. * @param channel defines the channel to use
  37903. * @param postProcess defines the source postprocess
  37904. */
  37905. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  37906. /**
  37907. * Binds the output of the passed in post process to the texture channel specified
  37908. * @param channel The channel the texture should be bound to
  37909. * @param postProcess The post process which's output should be bound
  37910. */
  37911. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  37912. protected _rebuildBuffers(): void;
  37913. /** @hidden */
  37914. _renderFrame(): void;
  37915. _renderLoop(): void;
  37916. /** @hidden */
  37917. _renderViews(): boolean;
  37918. /**
  37919. * Toggle full screen mode
  37920. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37921. */
  37922. switchFullscreen(requestPointerLock: boolean): void;
  37923. /**
  37924. * Enters full screen mode
  37925. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37926. */
  37927. enterFullscreen(requestPointerLock: boolean): void;
  37928. /**
  37929. * Exits full screen mode
  37930. */
  37931. exitFullscreen(): void;
  37932. /**
  37933. * Enters Pointerlock mode
  37934. */
  37935. enterPointerlock(): void;
  37936. /**
  37937. * Exits Pointerlock mode
  37938. */
  37939. exitPointerlock(): void;
  37940. /**
  37941. * Begin a new frame
  37942. */
  37943. beginFrame(): void;
  37944. /**
  37945. * Enf the current frame
  37946. */
  37947. endFrame(): void;
  37948. resize(): void;
  37949. /**
  37950. * Force a specific size of the canvas
  37951. * @param width defines the new canvas' width
  37952. * @param height defines the new canvas' height
  37953. * @returns true if the size was changed
  37954. */
  37955. setSize(width: number, height: number): boolean;
  37956. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37957. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37958. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37959. _releaseTexture(texture: InternalTexture): void;
  37960. /**
  37961. * @hidden
  37962. * Rescales a texture
  37963. * @param source input texutre
  37964. * @param destination destination texture
  37965. * @param scene scene to use to render the resize
  37966. * @param internalFormat format to use when resizing
  37967. * @param onComplete callback to be called when resize has completed
  37968. */
  37969. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37970. /**
  37971. * Gets the current framerate
  37972. * @returns a number representing the framerate
  37973. */
  37974. getFps(): number;
  37975. /**
  37976. * Gets the time spent between current and previous frame
  37977. * @returns a number representing the delta time in ms
  37978. */
  37979. getDeltaTime(): number;
  37980. private _measureFps;
  37981. /** @hidden */
  37982. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  37983. /**
  37984. * Updates the sample count of a render target texture
  37985. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  37986. * @param texture defines the texture to update
  37987. * @param samples defines the sample count to set
  37988. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  37989. */
  37990. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  37991. /**
  37992. * Updates a depth texture Comparison Mode and Function.
  37993. * If the comparison Function is equal to 0, the mode will be set to none.
  37994. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  37995. * @param texture The texture to set the comparison function for
  37996. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  37997. */
  37998. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  37999. /**
  38000. * Creates a webGL buffer to use with instanciation
  38001. * @param capacity defines the size of the buffer
  38002. * @returns the webGL buffer
  38003. */
  38004. createInstancesBuffer(capacity: number): DataBuffer;
  38005. /**
  38006. * Delete a webGL buffer used with instanciation
  38007. * @param buffer defines the webGL buffer to delete
  38008. */
  38009. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38010. private _clientWaitAsync;
  38011. /** @hidden */
  38012. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38013. dispose(): void;
  38014. private _disableTouchAction;
  38015. /**
  38016. * Display the loading screen
  38017. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38018. */
  38019. displayLoadingUI(): void;
  38020. /**
  38021. * Hide the loading screen
  38022. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38023. */
  38024. hideLoadingUI(): void;
  38025. /**
  38026. * Gets the current loading screen object
  38027. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38028. */
  38029. get loadingScreen(): ILoadingScreen;
  38030. /**
  38031. * Sets the current loading screen object
  38032. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38033. */
  38034. set loadingScreen(loadingScreen: ILoadingScreen);
  38035. /**
  38036. * Sets the current loading screen text
  38037. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38038. */
  38039. set loadingUIText(text: string);
  38040. /**
  38041. * Sets the current loading screen background color
  38042. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38043. */
  38044. set loadingUIBackgroundColor(color: string);
  38045. /** Pointerlock and fullscreen */
  38046. /**
  38047. * Ask the browser to promote the current element to pointerlock mode
  38048. * @param element defines the DOM element to promote
  38049. */
  38050. static _RequestPointerlock(element: HTMLElement): void;
  38051. /**
  38052. * Asks the browser to exit pointerlock mode
  38053. */
  38054. static _ExitPointerlock(): void;
  38055. /**
  38056. * Ask the browser to promote the current element to fullscreen rendering mode
  38057. * @param element defines the DOM element to promote
  38058. */
  38059. static _RequestFullscreen(element: HTMLElement): void;
  38060. /**
  38061. * Asks the browser to exit fullscreen mode
  38062. */
  38063. static _ExitFullscreen(): void;
  38064. }
  38065. }
  38066. declare module BABYLON {
  38067. /**
  38068. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38069. * during the life time of the application.
  38070. */
  38071. export class EngineStore {
  38072. /** Gets the list of created engines */
  38073. static Instances: Engine[];
  38074. /** @hidden */
  38075. static _LastCreatedScene: Nullable<Scene>;
  38076. /**
  38077. * Gets the latest created engine
  38078. */
  38079. static get LastCreatedEngine(): Nullable<Engine>;
  38080. /**
  38081. * Gets the latest created scene
  38082. */
  38083. static get LastCreatedScene(): Nullable<Scene>;
  38084. /**
  38085. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38086. * @ignorenaming
  38087. */
  38088. static UseFallbackTexture: boolean;
  38089. /**
  38090. * Texture content used if a texture cannot loaded
  38091. * @ignorenaming
  38092. */
  38093. static FallbackTexture: string;
  38094. }
  38095. }
  38096. declare module BABYLON {
  38097. /**
  38098. * Helper class that provides a small promise polyfill
  38099. */
  38100. export class PromisePolyfill {
  38101. /**
  38102. * Static function used to check if the polyfill is required
  38103. * If this is the case then the function will inject the polyfill to window.Promise
  38104. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38105. */
  38106. static Apply(force?: boolean): void;
  38107. }
  38108. }
  38109. declare module BABYLON {
  38110. /**
  38111. * Interface for screenshot methods with describe argument called `size` as object with options
  38112. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38113. */
  38114. export interface IScreenshotSize {
  38115. /**
  38116. * number in pixels for canvas height
  38117. */
  38118. height?: number;
  38119. /**
  38120. * multiplier allowing render at a higher or lower resolution
  38121. * If value is defined then height and width will be ignored and taken from camera
  38122. */
  38123. precision?: number;
  38124. /**
  38125. * number in pixels for canvas width
  38126. */
  38127. width?: number;
  38128. }
  38129. }
  38130. declare module BABYLON {
  38131. interface IColor4Like {
  38132. r: float;
  38133. g: float;
  38134. b: float;
  38135. a: float;
  38136. }
  38137. /**
  38138. * Class containing a set of static utilities functions
  38139. */
  38140. export class Tools {
  38141. /**
  38142. * Gets or sets the base URL to use to load assets
  38143. */
  38144. static get BaseUrl(): string;
  38145. static set BaseUrl(value: string);
  38146. /**
  38147. * Enable/Disable Custom HTTP Request Headers globally.
  38148. * default = false
  38149. * @see CustomRequestHeaders
  38150. */
  38151. static UseCustomRequestHeaders: boolean;
  38152. /**
  38153. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38154. * i.e. when loading files, where the server/service expects an Authorization header
  38155. */
  38156. static CustomRequestHeaders: {
  38157. [key: string]: string;
  38158. };
  38159. /**
  38160. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38161. */
  38162. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38163. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38164. /**
  38165. * Default behaviour for cors in the application.
  38166. * It can be a string if the expected behavior is identical in the entire app.
  38167. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38168. */
  38169. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38170. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38171. /**
  38172. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38173. * @ignorenaming
  38174. */
  38175. static get UseFallbackTexture(): boolean;
  38176. static set UseFallbackTexture(value: boolean);
  38177. /**
  38178. * Use this object to register external classes like custom textures or material
  38179. * to allow the laoders to instantiate them
  38180. */
  38181. static get RegisteredExternalClasses(): {
  38182. [key: string]: Object;
  38183. };
  38184. static set RegisteredExternalClasses(classes: {
  38185. [key: string]: Object;
  38186. });
  38187. /**
  38188. * Texture content used if a texture cannot loaded
  38189. * @ignorenaming
  38190. */
  38191. static get fallbackTexture(): string;
  38192. static set fallbackTexture(value: string);
  38193. /**
  38194. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38195. * @param u defines the coordinate on X axis
  38196. * @param v defines the coordinate on Y axis
  38197. * @param width defines the width of the source data
  38198. * @param height defines the height of the source data
  38199. * @param pixels defines the source byte array
  38200. * @param color defines the output color
  38201. */
  38202. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38203. /**
  38204. * Interpolates between a and b via alpha
  38205. * @param a The lower value (returned when alpha = 0)
  38206. * @param b The upper value (returned when alpha = 1)
  38207. * @param alpha The interpolation-factor
  38208. * @return The mixed value
  38209. */
  38210. static Mix(a: number, b: number, alpha: number): number;
  38211. /**
  38212. * Tries to instantiate a new object from a given class name
  38213. * @param className defines the class name to instantiate
  38214. * @returns the new object or null if the system was not able to do the instantiation
  38215. */
  38216. static Instantiate(className: string): any;
  38217. /**
  38218. * Provides a slice function that will work even on IE
  38219. * @param data defines the array to slice
  38220. * @param start defines the start of the data (optional)
  38221. * @param end defines the end of the data (optional)
  38222. * @returns the new sliced array
  38223. */
  38224. static Slice<T>(data: T, start?: number, end?: number): T;
  38225. /**
  38226. * Polyfill for setImmediate
  38227. * @param action defines the action to execute after the current execution block
  38228. */
  38229. static SetImmediate(action: () => void): void;
  38230. /**
  38231. * Function indicating if a number is an exponent of 2
  38232. * @param value defines the value to test
  38233. * @returns true if the value is an exponent of 2
  38234. */
  38235. static IsExponentOfTwo(value: number): boolean;
  38236. private static _tmpFloatArray;
  38237. /**
  38238. * Returns the nearest 32-bit single precision float representation of a Number
  38239. * @param value A Number. If the parameter is of a different type, it will get converted
  38240. * to a number or to NaN if it cannot be converted
  38241. * @returns number
  38242. */
  38243. static FloatRound(value: number): number;
  38244. /**
  38245. * Extracts the filename from a path
  38246. * @param path defines the path to use
  38247. * @returns the filename
  38248. */
  38249. static GetFilename(path: string): string;
  38250. /**
  38251. * Extracts the "folder" part of a path (everything before the filename).
  38252. * @param uri The URI to extract the info from
  38253. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38254. * @returns The "folder" part of the path
  38255. */
  38256. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38257. /**
  38258. * Extracts text content from a DOM element hierarchy
  38259. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38260. */
  38261. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38262. /**
  38263. * Convert an angle in radians to degrees
  38264. * @param angle defines the angle to convert
  38265. * @returns the angle in degrees
  38266. */
  38267. static ToDegrees(angle: number): number;
  38268. /**
  38269. * Convert an angle in degrees to radians
  38270. * @param angle defines the angle to convert
  38271. * @returns the angle in radians
  38272. */
  38273. static ToRadians(angle: number): number;
  38274. /**
  38275. * Returns an array if obj is not an array
  38276. * @param obj defines the object to evaluate as an array
  38277. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38278. * @returns either obj directly if obj is an array or a new array containing obj
  38279. */
  38280. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38281. /**
  38282. * Gets the pointer prefix to use
  38283. * @param engine defines the engine we are finding the prefix for
  38284. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38285. */
  38286. static GetPointerPrefix(engine: Engine): string;
  38287. /**
  38288. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38289. * @param url define the url we are trying
  38290. * @param element define the dom element where to configure the cors policy
  38291. */
  38292. static SetCorsBehavior(url: string | string[], element: {
  38293. crossOrigin: string | null;
  38294. }): void;
  38295. /**
  38296. * Removes unwanted characters from an url
  38297. * @param url defines the url to clean
  38298. * @returns the cleaned url
  38299. */
  38300. static CleanUrl(url: string): string;
  38301. /**
  38302. * Gets or sets a function used to pre-process url before using them to load assets
  38303. */
  38304. static get PreprocessUrl(): (url: string) => string;
  38305. static set PreprocessUrl(processor: (url: string) => string);
  38306. /**
  38307. * Loads an image as an HTMLImageElement.
  38308. * @param input url string, ArrayBuffer, or Blob to load
  38309. * @param onLoad callback called when the image successfully loads
  38310. * @param onError callback called when the image fails to load
  38311. * @param offlineProvider offline provider for caching
  38312. * @param mimeType optional mime type
  38313. * @returns the HTMLImageElement of the loaded image
  38314. */
  38315. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38316. /**
  38317. * Loads a file from a url
  38318. * @param url url string, ArrayBuffer, or Blob to load
  38319. * @param onSuccess callback called when the file successfully loads
  38320. * @param onProgress callback called while file is loading (if the server supports this mode)
  38321. * @param offlineProvider defines the offline provider for caching
  38322. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38323. * @param onError callback called when the file fails to load
  38324. * @returns a file request object
  38325. */
  38326. 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;
  38327. /**
  38328. * Loads a file from a url
  38329. * @param url the file url to load
  38330. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38331. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38332. */
  38333. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38334. /**
  38335. * Load a script (identified by an url). When the url returns, the
  38336. * content of this file is added into a new script element, attached to the DOM (body element)
  38337. * @param scriptUrl defines the url of the script to laod
  38338. * @param onSuccess defines the callback called when the script is loaded
  38339. * @param onError defines the callback to call if an error occurs
  38340. * @param scriptId defines the id of the script element
  38341. */
  38342. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38343. /**
  38344. * Load an asynchronous script (identified by an url). When the url returns, the
  38345. * content of this file is added into a new script element, attached to the DOM (body element)
  38346. * @param scriptUrl defines the url of the script to laod
  38347. * @param scriptId defines the id of the script element
  38348. * @returns a promise request object
  38349. */
  38350. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38351. /**
  38352. * Loads a file from a blob
  38353. * @param fileToLoad defines the blob to use
  38354. * @param callback defines the callback to call when data is loaded
  38355. * @param progressCallback defines the callback to call during loading process
  38356. * @returns a file request object
  38357. */
  38358. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38359. /**
  38360. * Reads a file from a File object
  38361. * @param file defines the file to load
  38362. * @param onSuccess defines the callback to call when data is loaded
  38363. * @param onProgress defines the callback to call during loading process
  38364. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38365. * @param onError defines the callback to call when an error occurs
  38366. * @returns a file request object
  38367. */
  38368. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38369. /**
  38370. * Creates a data url from a given string content
  38371. * @param content defines the content to convert
  38372. * @returns the new data url link
  38373. */
  38374. static FileAsURL(content: string): string;
  38375. /**
  38376. * Format the given number to a specific decimal format
  38377. * @param value defines the number to format
  38378. * @param decimals defines the number of decimals to use
  38379. * @returns the formatted string
  38380. */
  38381. static Format(value: number, decimals?: number): string;
  38382. /**
  38383. * Tries to copy an object by duplicating every property
  38384. * @param source defines the source object
  38385. * @param destination defines the target object
  38386. * @param doNotCopyList defines a list of properties to avoid
  38387. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38388. */
  38389. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38390. /**
  38391. * Gets a boolean indicating if the given object has no own property
  38392. * @param obj defines the object to test
  38393. * @returns true if object has no own property
  38394. */
  38395. static IsEmpty(obj: any): boolean;
  38396. /**
  38397. * Function used to register events at window level
  38398. * @param windowElement defines the Window object to use
  38399. * @param events defines the events to register
  38400. */
  38401. static RegisterTopRootEvents(windowElement: Window, events: {
  38402. name: string;
  38403. handler: Nullable<(e: FocusEvent) => any>;
  38404. }[]): void;
  38405. /**
  38406. * Function used to unregister events from window level
  38407. * @param windowElement defines the Window object to use
  38408. * @param events defines the events to unregister
  38409. */
  38410. static UnregisterTopRootEvents(windowElement: Window, events: {
  38411. name: string;
  38412. handler: Nullable<(e: FocusEvent) => any>;
  38413. }[]): void;
  38414. /**
  38415. * @ignore
  38416. */
  38417. static _ScreenshotCanvas: HTMLCanvasElement;
  38418. /**
  38419. * Dumps the current bound framebuffer
  38420. * @param width defines the rendering width
  38421. * @param height defines the rendering height
  38422. * @param engine defines the hosting engine
  38423. * @param successCallback defines the callback triggered once the data are available
  38424. * @param mimeType defines the mime type of the result
  38425. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38426. */
  38427. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38428. /**
  38429. * Converts the canvas data to blob.
  38430. * This acts as a polyfill for browsers not supporting the to blob function.
  38431. * @param canvas Defines the canvas to extract the data from
  38432. * @param successCallback Defines the callback triggered once the data are available
  38433. * @param mimeType Defines the mime type of the result
  38434. */
  38435. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38436. /**
  38437. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38438. * @param successCallback defines the callback triggered once the data are available
  38439. * @param mimeType defines the mime type of the result
  38440. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38441. */
  38442. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38443. /**
  38444. * Downloads a blob in the browser
  38445. * @param blob defines the blob to download
  38446. * @param fileName defines the name of the downloaded file
  38447. */
  38448. static Download(blob: Blob, fileName: string): void;
  38449. /**
  38450. * Captures a screenshot of the current rendering
  38451. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38452. * @param engine defines the rendering engine
  38453. * @param camera defines the source camera
  38454. * @param size This parameter can be set to a single number or to an object with the
  38455. * following (optional) properties: precision, width, height. If a single number is passed,
  38456. * it will be used for both width and height. If an object is passed, the screenshot size
  38457. * will be derived from the parameters. The precision property is a multiplier allowing
  38458. * rendering at a higher or lower resolution
  38459. * @param successCallback defines the callback receives a single parameter which contains the
  38460. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38461. * src parameter of an <img> to display it
  38462. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38463. * Check your browser for supported MIME types
  38464. */
  38465. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38466. /**
  38467. * Captures a screenshot of the current rendering
  38468. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38469. * @param engine defines the rendering engine
  38470. * @param camera defines the source camera
  38471. * @param size This parameter can be set to a single number or to an object with the
  38472. * following (optional) properties: precision, width, height. If a single number is passed,
  38473. * it will be used for both width and height. If an object is passed, the screenshot size
  38474. * will be derived from the parameters. The precision property is a multiplier allowing
  38475. * rendering at a higher or lower resolution
  38476. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38477. * Check your browser for supported MIME types
  38478. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38479. * to the src parameter of an <img> to display it
  38480. */
  38481. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38482. /**
  38483. * Generates an image screenshot from the specified camera.
  38484. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38485. * @param engine The engine to use for rendering
  38486. * @param camera The camera to use for rendering
  38487. * @param size This parameter can be set to a single number or to an object with the
  38488. * following (optional) properties: precision, width, height. If a single number is passed,
  38489. * it will be used for both width and height. If an object is passed, the screenshot size
  38490. * will be derived from the parameters. The precision property is a multiplier allowing
  38491. * rendering at a higher or lower resolution
  38492. * @param successCallback The callback receives a single parameter which contains the
  38493. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38494. * src parameter of an <img> to display it
  38495. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38496. * Check your browser for supported MIME types
  38497. * @param samples Texture samples (default: 1)
  38498. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38499. * @param fileName A name for for the downloaded file.
  38500. */
  38501. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38502. /**
  38503. * Generates an image screenshot from the specified camera.
  38504. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38505. * @param engine The engine to use for rendering
  38506. * @param camera The camera to use for rendering
  38507. * @param size This parameter can be set to a single number or to an object with the
  38508. * following (optional) properties: precision, width, height. If a single number is passed,
  38509. * it will be used for both width and height. If an object is passed, the screenshot size
  38510. * will be derived from the parameters. The precision property is a multiplier allowing
  38511. * rendering at a higher or lower resolution
  38512. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38513. * Check your browser for supported MIME types
  38514. * @param samples Texture samples (default: 1)
  38515. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38516. * @param fileName A name for for the downloaded file.
  38517. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38518. * to the src parameter of an <img> to display it
  38519. */
  38520. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38521. /**
  38522. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38523. * Be aware Math.random() could cause collisions, but:
  38524. * "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"
  38525. * @returns a pseudo random id
  38526. */
  38527. static RandomId(): string;
  38528. /**
  38529. * Test if the given uri is a base64 string
  38530. * @param uri The uri to test
  38531. * @return True if the uri is a base64 string or false otherwise
  38532. */
  38533. static IsBase64(uri: string): boolean;
  38534. /**
  38535. * Decode the given base64 uri.
  38536. * @param uri The uri to decode
  38537. * @return The decoded base64 data.
  38538. */
  38539. static DecodeBase64(uri: string): ArrayBuffer;
  38540. /**
  38541. * Gets the absolute url.
  38542. * @param url the input url
  38543. * @return the absolute url
  38544. */
  38545. static GetAbsoluteUrl(url: string): string;
  38546. /**
  38547. * No log
  38548. */
  38549. static readonly NoneLogLevel: number;
  38550. /**
  38551. * Only message logs
  38552. */
  38553. static readonly MessageLogLevel: number;
  38554. /**
  38555. * Only warning logs
  38556. */
  38557. static readonly WarningLogLevel: number;
  38558. /**
  38559. * Only error logs
  38560. */
  38561. static readonly ErrorLogLevel: number;
  38562. /**
  38563. * All logs
  38564. */
  38565. static readonly AllLogLevel: number;
  38566. /**
  38567. * Gets a value indicating the number of loading errors
  38568. * @ignorenaming
  38569. */
  38570. static get errorsCount(): number;
  38571. /**
  38572. * Callback called when a new log is added
  38573. */
  38574. static OnNewCacheEntry: (entry: string) => void;
  38575. /**
  38576. * Log a message to the console
  38577. * @param message defines the message to log
  38578. */
  38579. static Log(message: string): void;
  38580. /**
  38581. * Write a warning message to the console
  38582. * @param message defines the message to log
  38583. */
  38584. static Warn(message: string): void;
  38585. /**
  38586. * Write an error message to the console
  38587. * @param message defines the message to log
  38588. */
  38589. static Error(message: string): void;
  38590. /**
  38591. * Gets current log cache (list of logs)
  38592. */
  38593. static get LogCache(): string;
  38594. /**
  38595. * Clears the log cache
  38596. */
  38597. static ClearLogCache(): void;
  38598. /**
  38599. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38600. */
  38601. static set LogLevels(level: number);
  38602. /**
  38603. * Checks if the window object exists
  38604. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38605. */
  38606. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38607. /**
  38608. * No performance log
  38609. */
  38610. static readonly PerformanceNoneLogLevel: number;
  38611. /**
  38612. * Use user marks to log performance
  38613. */
  38614. static readonly PerformanceUserMarkLogLevel: number;
  38615. /**
  38616. * Log performance to the console
  38617. */
  38618. static readonly PerformanceConsoleLogLevel: number;
  38619. private static _performance;
  38620. /**
  38621. * Sets the current performance log level
  38622. */
  38623. static set PerformanceLogLevel(level: number);
  38624. private static _StartPerformanceCounterDisabled;
  38625. private static _EndPerformanceCounterDisabled;
  38626. private static _StartUserMark;
  38627. private static _EndUserMark;
  38628. private static _StartPerformanceConsole;
  38629. private static _EndPerformanceConsole;
  38630. /**
  38631. * Starts a performance counter
  38632. */
  38633. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38634. /**
  38635. * Ends a specific performance coutner
  38636. */
  38637. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38638. /**
  38639. * Gets either window.performance.now() if supported or Date.now() else
  38640. */
  38641. static get Now(): number;
  38642. /**
  38643. * This method will return the name of the class used to create the instance of the given object.
  38644. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38645. * @param object the object to get the class name from
  38646. * @param isType defines if the object is actually a type
  38647. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38648. */
  38649. static GetClassName(object: any, isType?: boolean): string;
  38650. /**
  38651. * Gets the first element of an array satisfying a given predicate
  38652. * @param array defines the array to browse
  38653. * @param predicate defines the predicate to use
  38654. * @returns null if not found or the element
  38655. */
  38656. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38657. /**
  38658. * This method will return the name of the full name of the class, including its owning module (if any).
  38659. * 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).
  38660. * @param object the object to get the class name from
  38661. * @param isType defines if the object is actually a type
  38662. * @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.
  38663. * @ignorenaming
  38664. */
  38665. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38666. /**
  38667. * Returns a promise that resolves after the given amount of time.
  38668. * @param delay Number of milliseconds to delay
  38669. * @returns Promise that resolves after the given amount of time
  38670. */
  38671. static DelayAsync(delay: number): Promise<void>;
  38672. /**
  38673. * Utility function to detect if the current user agent is Safari
  38674. * @returns whether or not the current user agent is safari
  38675. */
  38676. static IsSafari(): boolean;
  38677. }
  38678. /**
  38679. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38680. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38681. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38682. * @param name The name of the class, case should be preserved
  38683. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38684. */
  38685. export function className(name: string, module?: string): (target: Object) => void;
  38686. /**
  38687. * An implementation of a loop for asynchronous functions.
  38688. */
  38689. export class AsyncLoop {
  38690. /**
  38691. * Defines the number of iterations for the loop
  38692. */
  38693. iterations: number;
  38694. /**
  38695. * Defines the current index of the loop.
  38696. */
  38697. index: number;
  38698. private _done;
  38699. private _fn;
  38700. private _successCallback;
  38701. /**
  38702. * Constructor.
  38703. * @param iterations the number of iterations.
  38704. * @param func the function to run each iteration
  38705. * @param successCallback the callback that will be called upon succesful execution
  38706. * @param offset starting offset.
  38707. */
  38708. constructor(
  38709. /**
  38710. * Defines the number of iterations for the loop
  38711. */
  38712. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  38713. /**
  38714. * Execute the next iteration. Must be called after the last iteration was finished.
  38715. */
  38716. executeNext(): void;
  38717. /**
  38718. * Break the loop and run the success callback.
  38719. */
  38720. breakLoop(): void;
  38721. /**
  38722. * Create and run an async loop.
  38723. * @param iterations the number of iterations.
  38724. * @param fn the function to run each iteration
  38725. * @param successCallback the callback that will be called upon succesful execution
  38726. * @param offset starting offset.
  38727. * @returns the created async loop object
  38728. */
  38729. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  38730. /**
  38731. * A for-loop that will run a given number of iterations synchronous and the rest async.
  38732. * @param iterations total number of iterations
  38733. * @param syncedIterations number of synchronous iterations in each async iteration.
  38734. * @param fn the function to call each iteration.
  38735. * @param callback a success call back that will be called when iterating stops.
  38736. * @param breakFunction a break condition (optional)
  38737. * @param timeout timeout settings for the setTimeout function. default - 0.
  38738. * @returns the created async loop object
  38739. */
  38740. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  38741. }
  38742. }
  38743. declare module BABYLON {
  38744. /**
  38745. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38746. * The underlying implementation relies on an associative array to ensure the best performances.
  38747. * The value can be anything including 'null' but except 'undefined'
  38748. */
  38749. export class StringDictionary<T> {
  38750. /**
  38751. * This will clear this dictionary and copy the content from the 'source' one.
  38752. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38753. * @param source the dictionary to take the content from and copy to this dictionary
  38754. */
  38755. copyFrom(source: StringDictionary<T>): void;
  38756. /**
  38757. * Get a value based from its key
  38758. * @param key the given key to get the matching value from
  38759. * @return the value if found, otherwise undefined is returned
  38760. */
  38761. get(key: string): T | undefined;
  38762. /**
  38763. * Get a value from its key or add it if it doesn't exist.
  38764. * This method will ensure you that a given key/data will be present in the dictionary.
  38765. * @param key the given key to get the matching value from
  38766. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38767. * The factory will only be invoked if there's no data for the given key.
  38768. * @return the value corresponding to the key.
  38769. */
  38770. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38771. /**
  38772. * Get a value from its key if present in the dictionary otherwise add it
  38773. * @param key the key to get the value from
  38774. * @param val if there's no such key/value pair in the dictionary add it with this value
  38775. * @return the value corresponding to the key
  38776. */
  38777. getOrAdd(key: string, val: T): T;
  38778. /**
  38779. * Check if there's a given key in the dictionary
  38780. * @param key the key to check for
  38781. * @return true if the key is present, false otherwise
  38782. */
  38783. contains(key: string): boolean;
  38784. /**
  38785. * Add a new key and its corresponding value
  38786. * @param key the key to add
  38787. * @param value the value corresponding to the key
  38788. * @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
  38789. */
  38790. add(key: string, value: T): boolean;
  38791. /**
  38792. * Update a specific value associated to a key
  38793. * @param key defines the key to use
  38794. * @param value defines the value to store
  38795. * @returns true if the value was updated (or false if the key was not found)
  38796. */
  38797. set(key: string, value: T): boolean;
  38798. /**
  38799. * Get the element of the given key and remove it from the dictionary
  38800. * @param key defines the key to search
  38801. * @returns the value associated with the key or null if not found
  38802. */
  38803. getAndRemove(key: string): Nullable<T>;
  38804. /**
  38805. * Remove a key/value from the dictionary.
  38806. * @param key the key to remove
  38807. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38808. */
  38809. remove(key: string): boolean;
  38810. /**
  38811. * Clear the whole content of the dictionary
  38812. */
  38813. clear(): void;
  38814. /**
  38815. * Gets the current count
  38816. */
  38817. get count(): number;
  38818. /**
  38819. * Execute a callback on each key/val of the dictionary.
  38820. * Note that you can remove any element in this dictionary in the callback implementation
  38821. * @param callback the callback to execute on a given key/value pair
  38822. */
  38823. forEach(callback: (key: string, val: T) => void): void;
  38824. /**
  38825. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38826. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38827. * Note that you can remove any element in this dictionary in the callback implementation
  38828. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38829. * @returns the first item
  38830. */
  38831. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38832. private _count;
  38833. private _data;
  38834. }
  38835. }
  38836. declare module BABYLON {
  38837. /** @hidden */
  38838. export interface ICollisionCoordinator {
  38839. createCollider(): Collider;
  38840. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38841. init(scene: Scene): void;
  38842. }
  38843. /** @hidden */
  38844. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  38845. private _scene;
  38846. private _scaledPosition;
  38847. private _scaledVelocity;
  38848. private _finalPosition;
  38849. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38850. createCollider(): Collider;
  38851. init(scene: Scene): void;
  38852. private _collideWithWorld;
  38853. }
  38854. }
  38855. declare module BABYLON {
  38856. /**
  38857. * Class used to manage all inputs for the scene.
  38858. */
  38859. export class InputManager {
  38860. /** The distance in pixel that you have to move to prevent some events */
  38861. static DragMovementThreshold: number;
  38862. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  38863. static LongPressDelay: number;
  38864. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  38865. static DoubleClickDelay: number;
  38866. /** If you need to check double click without raising a single click at first click, enable this flag */
  38867. static ExclusiveDoubleClickMode: boolean;
  38868. /** 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. */
  38869. private _alreadyAttached;
  38870. private _wheelEventName;
  38871. private _onPointerMove;
  38872. private _onPointerDown;
  38873. private _onPointerUp;
  38874. private _initClickEvent;
  38875. private _initActionManager;
  38876. private _delayedSimpleClick;
  38877. private _delayedSimpleClickTimeout;
  38878. private _previousDelayedSimpleClickTimeout;
  38879. private _meshPickProceed;
  38880. private _previousButtonPressed;
  38881. private _currentPickResult;
  38882. private _previousPickResult;
  38883. private _totalPointersPressed;
  38884. private _doubleClickOccured;
  38885. private _pointerOverMesh;
  38886. private _pickedDownMesh;
  38887. private _pickedUpMesh;
  38888. private _pointerX;
  38889. private _pointerY;
  38890. private _unTranslatedPointerX;
  38891. private _unTranslatedPointerY;
  38892. private _startingPointerPosition;
  38893. private _previousStartingPointerPosition;
  38894. private _startingPointerTime;
  38895. private _previousStartingPointerTime;
  38896. private _pointerCaptures;
  38897. private _onKeyDown;
  38898. private _onKeyUp;
  38899. private _onCanvasFocusObserver;
  38900. private _onCanvasBlurObserver;
  38901. private _scene;
  38902. /**
  38903. * Creates a new InputManager
  38904. * @param scene defines the hosting scene
  38905. */
  38906. constructor(scene: Scene);
  38907. /**
  38908. * Gets the mesh that is currently under the pointer
  38909. */
  38910. get meshUnderPointer(): Nullable<AbstractMesh>;
  38911. /**
  38912. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  38913. */
  38914. get unTranslatedPointer(): Vector2;
  38915. /**
  38916. * Gets or sets the current on-screen X position of the pointer
  38917. */
  38918. get pointerX(): number;
  38919. set pointerX(value: number);
  38920. /**
  38921. * Gets or sets the current on-screen Y position of the pointer
  38922. */
  38923. get pointerY(): number;
  38924. set pointerY(value: number);
  38925. private _updatePointerPosition;
  38926. private _processPointerMove;
  38927. private _setRayOnPointerInfo;
  38928. private _checkPrePointerObservable;
  38929. /**
  38930. * Use this method to simulate a pointer move on a mesh
  38931. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38932. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38933. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38934. */
  38935. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38936. /**
  38937. * Use this method to simulate a pointer down on a mesh
  38938. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38939. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38940. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38941. */
  38942. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38943. private _processPointerDown;
  38944. /** @hidden */
  38945. _isPointerSwiping(): boolean;
  38946. /**
  38947. * Use this method to simulate a pointer up on a mesh
  38948. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38949. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38950. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38951. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  38952. */
  38953. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  38954. private _processPointerUp;
  38955. /**
  38956. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  38957. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  38958. * @returns true if the pointer was captured
  38959. */
  38960. isPointerCaptured(pointerId?: number): boolean;
  38961. /**
  38962. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  38963. * @param attachUp defines if you want to attach events to pointerup
  38964. * @param attachDown defines if you want to attach events to pointerdown
  38965. * @param attachMove defines if you want to attach events to pointermove
  38966. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  38967. */
  38968. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  38969. /**
  38970. * Detaches all event handlers
  38971. */
  38972. detachControl(): void;
  38973. /**
  38974. * Force the value of meshUnderPointer
  38975. * @param mesh defines the mesh to use
  38976. */
  38977. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38978. /**
  38979. * Gets the mesh under the pointer
  38980. * @returns a Mesh or null if no mesh is under the pointer
  38981. */
  38982. getPointerOverMesh(): Nullable<AbstractMesh>;
  38983. }
  38984. }
  38985. declare module BABYLON {
  38986. /**
  38987. * This class defines the direct association between an animation and a target
  38988. */
  38989. export class TargetedAnimation {
  38990. /**
  38991. * Animation to perform
  38992. */
  38993. animation: Animation;
  38994. /**
  38995. * Target to animate
  38996. */
  38997. target: any;
  38998. /**
  38999. * Returns the string "TargetedAnimation"
  39000. * @returns "TargetedAnimation"
  39001. */
  39002. getClassName(): string;
  39003. /**
  39004. * Serialize the object
  39005. * @returns the JSON object representing the current entity
  39006. */
  39007. serialize(): any;
  39008. }
  39009. /**
  39010. * Use this class to create coordinated animations on multiple targets
  39011. */
  39012. export class AnimationGroup implements IDisposable {
  39013. /** The name of the animation group */
  39014. name: string;
  39015. private _scene;
  39016. private _targetedAnimations;
  39017. private _animatables;
  39018. private _from;
  39019. private _to;
  39020. private _isStarted;
  39021. private _isPaused;
  39022. private _speedRatio;
  39023. private _loopAnimation;
  39024. private _isAdditive;
  39025. /**
  39026. * Gets or sets the unique id of the node
  39027. */
  39028. uniqueId: number;
  39029. /**
  39030. * This observable will notify when one animation have ended
  39031. */
  39032. onAnimationEndObservable: Observable<TargetedAnimation>;
  39033. /**
  39034. * Observer raised when one animation loops
  39035. */
  39036. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39037. /**
  39038. * Observer raised when all animations have looped
  39039. */
  39040. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39041. /**
  39042. * This observable will notify when all animations have ended.
  39043. */
  39044. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39045. /**
  39046. * This observable will notify when all animations have paused.
  39047. */
  39048. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39049. /**
  39050. * This observable will notify when all animations are playing.
  39051. */
  39052. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39053. /**
  39054. * Gets the first frame
  39055. */
  39056. get from(): number;
  39057. /**
  39058. * Gets the last frame
  39059. */
  39060. get to(): number;
  39061. /**
  39062. * Define if the animations are started
  39063. */
  39064. get isStarted(): boolean;
  39065. /**
  39066. * Gets a value indicating that the current group is playing
  39067. */
  39068. get isPlaying(): boolean;
  39069. /**
  39070. * Gets or sets the speed ratio to use for all animations
  39071. */
  39072. get speedRatio(): number;
  39073. /**
  39074. * Gets or sets the speed ratio to use for all animations
  39075. */
  39076. set speedRatio(value: number);
  39077. /**
  39078. * Gets or sets if all animations should loop or not
  39079. */
  39080. get loopAnimation(): boolean;
  39081. set loopAnimation(value: boolean);
  39082. /**
  39083. * Gets or sets if all animations should be evaluated additively
  39084. */
  39085. get isAdditive(): boolean;
  39086. set isAdditive(value: boolean);
  39087. /**
  39088. * Gets the targeted animations for this animation group
  39089. */
  39090. get targetedAnimations(): Array<TargetedAnimation>;
  39091. /**
  39092. * returning the list of animatables controlled by this animation group.
  39093. */
  39094. get animatables(): Array<Animatable>;
  39095. /**
  39096. * Gets the list of target animations
  39097. */
  39098. get children(): TargetedAnimation[];
  39099. /**
  39100. * Instantiates a new Animation Group.
  39101. * This helps managing several animations at once.
  39102. * @see https://doc.babylonjs.com/how_to/group
  39103. * @param name Defines the name of the group
  39104. * @param scene Defines the scene the group belongs to
  39105. */
  39106. constructor(
  39107. /** The name of the animation group */
  39108. name: string, scene?: Nullable<Scene>);
  39109. /**
  39110. * Add an animation (with its target) in the group
  39111. * @param animation defines the animation we want to add
  39112. * @param target defines the target of the animation
  39113. * @returns the TargetedAnimation object
  39114. */
  39115. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39116. /**
  39117. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39118. * It can add constant keys at begin or end
  39119. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39120. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39121. * @returns the animation group
  39122. */
  39123. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39124. private _animationLoopCount;
  39125. private _animationLoopFlags;
  39126. private _processLoop;
  39127. /**
  39128. * Start all animations on given targets
  39129. * @param loop defines if animations must loop
  39130. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39131. * @param from defines the from key (optional)
  39132. * @param to defines the to key (optional)
  39133. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39134. * @returns the current animation group
  39135. */
  39136. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39137. /**
  39138. * Pause all animations
  39139. * @returns the animation group
  39140. */
  39141. pause(): AnimationGroup;
  39142. /**
  39143. * Play all animations to initial state
  39144. * This function will start() the animations if they were not started or will restart() them if they were paused
  39145. * @param loop defines if animations must loop
  39146. * @returns the animation group
  39147. */
  39148. play(loop?: boolean): AnimationGroup;
  39149. /**
  39150. * Reset all animations to initial state
  39151. * @returns the animation group
  39152. */
  39153. reset(): AnimationGroup;
  39154. /**
  39155. * Restart animations from key 0
  39156. * @returns the animation group
  39157. */
  39158. restart(): AnimationGroup;
  39159. /**
  39160. * Stop all animations
  39161. * @returns the animation group
  39162. */
  39163. stop(): AnimationGroup;
  39164. /**
  39165. * Set animation weight for all animatables
  39166. * @param weight defines the weight to use
  39167. * @return the animationGroup
  39168. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39169. */
  39170. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39171. /**
  39172. * Synchronize and normalize all animatables with a source animatable
  39173. * @param root defines the root animatable to synchronize with
  39174. * @return the animationGroup
  39175. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39176. */
  39177. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39178. /**
  39179. * Goes to a specific frame in this animation group
  39180. * @param frame the frame number to go to
  39181. * @return the animationGroup
  39182. */
  39183. goToFrame(frame: number): AnimationGroup;
  39184. /**
  39185. * Dispose all associated resources
  39186. */
  39187. dispose(): void;
  39188. private _checkAnimationGroupEnded;
  39189. /**
  39190. * Clone the current animation group and returns a copy
  39191. * @param newName defines the name of the new group
  39192. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39193. * @returns the new aniamtion group
  39194. */
  39195. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39196. /**
  39197. * Serializes the animationGroup to an object
  39198. * @returns Serialized object
  39199. */
  39200. serialize(): any;
  39201. /**
  39202. * Returns a new AnimationGroup object parsed from the source provided.
  39203. * @param parsedAnimationGroup defines the source
  39204. * @param scene defines the scene that will receive the animationGroup
  39205. * @returns a new AnimationGroup
  39206. */
  39207. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39208. /**
  39209. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39210. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39211. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39212. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39213. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39214. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39215. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39216. */
  39217. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39218. /**
  39219. * Returns the string "AnimationGroup"
  39220. * @returns "AnimationGroup"
  39221. */
  39222. getClassName(): string;
  39223. /**
  39224. * Creates a detailled string about the object
  39225. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39226. * @returns a string representing the object
  39227. */
  39228. toString(fullDetails?: boolean): string;
  39229. }
  39230. }
  39231. declare module BABYLON {
  39232. /**
  39233. * Define an interface for all classes that will hold resources
  39234. */
  39235. export interface IDisposable {
  39236. /**
  39237. * Releases all held resources
  39238. */
  39239. dispose(): void;
  39240. }
  39241. /** Interface defining initialization parameters for Scene class */
  39242. export interface SceneOptions {
  39243. /**
  39244. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39245. * It will improve performance when the number of geometries becomes important.
  39246. */
  39247. useGeometryUniqueIdsMap?: boolean;
  39248. /**
  39249. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39250. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39251. */
  39252. useMaterialMeshMap?: boolean;
  39253. /**
  39254. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39255. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39256. */
  39257. useClonedMeshMap?: boolean;
  39258. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39259. virtual?: boolean;
  39260. }
  39261. /**
  39262. * Represents a scene to be rendered by the engine.
  39263. * @see https://doc.babylonjs.com/features/scene
  39264. */
  39265. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  39266. /** The fog is deactivated */
  39267. static readonly FOGMODE_NONE: number;
  39268. /** The fog density is following an exponential function */
  39269. static readonly FOGMODE_EXP: number;
  39270. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39271. static readonly FOGMODE_EXP2: number;
  39272. /** The fog density is following a linear function. */
  39273. static readonly FOGMODE_LINEAR: number;
  39274. /**
  39275. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39276. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39277. */
  39278. static MinDeltaTime: number;
  39279. /**
  39280. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39281. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39282. */
  39283. static MaxDeltaTime: number;
  39284. /**
  39285. * Factory used to create the default material.
  39286. * @param name The name of the material to create
  39287. * @param scene The scene to create the material for
  39288. * @returns The default material
  39289. */
  39290. static DefaultMaterialFactory(scene: Scene): Material;
  39291. /**
  39292. * Factory used to create the a collision coordinator.
  39293. * @returns The collision coordinator
  39294. */
  39295. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39296. /** @hidden */
  39297. _inputManager: InputManager;
  39298. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39299. cameraToUseForPointers: Nullable<Camera>;
  39300. /** @hidden */
  39301. readonly _isScene: boolean;
  39302. /** @hidden */
  39303. _blockEntityCollection: boolean;
  39304. /**
  39305. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39306. */
  39307. autoClear: boolean;
  39308. /**
  39309. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39310. */
  39311. autoClearDepthAndStencil: boolean;
  39312. /**
  39313. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39314. */
  39315. clearColor: Color4;
  39316. /**
  39317. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39318. */
  39319. ambientColor: Color3;
  39320. /**
  39321. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39322. * It should only be one of the following (if not the default embedded one):
  39323. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39324. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39325. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39326. * The material properties need to be setup according to the type of texture in use.
  39327. */
  39328. environmentBRDFTexture: BaseTexture;
  39329. /** @hidden */
  39330. protected _environmentTexture: Nullable<BaseTexture>;
  39331. /**
  39332. * Texture used in all pbr material as the reflection texture.
  39333. * As in the majority of the scene they are the same (exception for multi room and so on),
  39334. * this is easier to reference from here than from all the materials.
  39335. */
  39336. get environmentTexture(): Nullable<BaseTexture>;
  39337. /**
  39338. * Texture used in all pbr material as the reflection texture.
  39339. * As in the majority of the scene they are the same (exception for multi room and so on),
  39340. * this is easier to set here than in all the materials.
  39341. */
  39342. set environmentTexture(value: Nullable<BaseTexture>);
  39343. /** @hidden */
  39344. protected _environmentIntensity: number;
  39345. /**
  39346. * Intensity of the environment in all pbr material.
  39347. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39348. * As in the majority of the scene they are the same (exception for multi room and so on),
  39349. * this is easier to reference from here than from all the materials.
  39350. */
  39351. get environmentIntensity(): number;
  39352. /**
  39353. * Intensity of the environment in all pbr material.
  39354. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39355. * As in the majority of the scene they are the same (exception for multi room and so on),
  39356. * this is easier to set here than in all the materials.
  39357. */
  39358. set environmentIntensity(value: number);
  39359. /** @hidden */
  39360. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39361. /**
  39362. * Default image processing configuration used either in the rendering
  39363. * Forward main pass or through the imageProcessingPostProcess if present.
  39364. * As in the majority of the scene they are the same (exception for multi camera),
  39365. * this is easier to reference from here than from all the materials and post process.
  39366. *
  39367. * No setter as we it is a shared configuration, you can set the values instead.
  39368. */
  39369. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39370. private _forceWireframe;
  39371. /**
  39372. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39373. */
  39374. set forceWireframe(value: boolean);
  39375. get forceWireframe(): boolean;
  39376. private _skipFrustumClipping;
  39377. /**
  39378. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39379. */
  39380. set skipFrustumClipping(value: boolean);
  39381. get skipFrustumClipping(): boolean;
  39382. private _forcePointsCloud;
  39383. /**
  39384. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39385. */
  39386. set forcePointsCloud(value: boolean);
  39387. get forcePointsCloud(): boolean;
  39388. /**
  39389. * Gets or sets the active clipplane 1
  39390. */
  39391. clipPlane: Nullable<Plane>;
  39392. /**
  39393. * Gets or sets the active clipplane 2
  39394. */
  39395. clipPlane2: Nullable<Plane>;
  39396. /**
  39397. * Gets or sets the active clipplane 3
  39398. */
  39399. clipPlane3: Nullable<Plane>;
  39400. /**
  39401. * Gets or sets the active clipplane 4
  39402. */
  39403. clipPlane4: Nullable<Plane>;
  39404. /**
  39405. * Gets or sets the active clipplane 5
  39406. */
  39407. clipPlane5: Nullable<Plane>;
  39408. /**
  39409. * Gets or sets the active clipplane 6
  39410. */
  39411. clipPlane6: Nullable<Plane>;
  39412. /**
  39413. * Gets or sets a boolean indicating if animations are enabled
  39414. */
  39415. animationsEnabled: boolean;
  39416. private _animationPropertiesOverride;
  39417. /**
  39418. * Gets or sets the animation properties override
  39419. */
  39420. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39421. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39422. /**
  39423. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39424. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39425. */
  39426. useConstantAnimationDeltaTime: boolean;
  39427. /**
  39428. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39429. * Please note that it requires to run a ray cast through the scene on every frame
  39430. */
  39431. constantlyUpdateMeshUnderPointer: boolean;
  39432. /**
  39433. * Defines the HTML cursor to use when hovering over interactive elements
  39434. */
  39435. hoverCursor: string;
  39436. /**
  39437. * Defines the HTML default cursor to use (empty by default)
  39438. */
  39439. defaultCursor: string;
  39440. /**
  39441. * Defines whether cursors are handled by the scene.
  39442. */
  39443. doNotHandleCursors: boolean;
  39444. /**
  39445. * This is used to call preventDefault() on pointer down
  39446. * in order to block unwanted artifacts like system double clicks
  39447. */
  39448. preventDefaultOnPointerDown: boolean;
  39449. /**
  39450. * This is used to call preventDefault() on pointer up
  39451. * in order to block unwanted artifacts like system double clicks
  39452. */
  39453. preventDefaultOnPointerUp: boolean;
  39454. /**
  39455. * Gets or sets user defined metadata
  39456. */
  39457. metadata: any;
  39458. /**
  39459. * For internal use only. Please do not use.
  39460. */
  39461. reservedDataStore: any;
  39462. /**
  39463. * Gets the name of the plugin used to load this scene (null by default)
  39464. */
  39465. loadingPluginName: string;
  39466. /**
  39467. * Use this array to add regular expressions used to disable offline support for specific urls
  39468. */
  39469. disableOfflineSupportExceptionRules: RegExp[];
  39470. /**
  39471. * An event triggered when the scene is disposed.
  39472. */
  39473. onDisposeObservable: Observable<Scene>;
  39474. private _onDisposeObserver;
  39475. /** Sets a function to be executed when this scene is disposed. */
  39476. set onDispose(callback: () => void);
  39477. /**
  39478. * An event triggered before rendering the scene (right after animations and physics)
  39479. */
  39480. onBeforeRenderObservable: Observable<Scene>;
  39481. private _onBeforeRenderObserver;
  39482. /** Sets a function to be executed before rendering this scene */
  39483. set beforeRender(callback: Nullable<() => void>);
  39484. /**
  39485. * An event triggered after rendering the scene
  39486. */
  39487. onAfterRenderObservable: Observable<Scene>;
  39488. /**
  39489. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39490. */
  39491. onAfterRenderCameraObservable: Observable<Camera>;
  39492. private _onAfterRenderObserver;
  39493. /** Sets a function to be executed after rendering this scene */
  39494. set afterRender(callback: Nullable<() => void>);
  39495. /**
  39496. * An event triggered before animating the scene
  39497. */
  39498. onBeforeAnimationsObservable: Observable<Scene>;
  39499. /**
  39500. * An event triggered after animations processing
  39501. */
  39502. onAfterAnimationsObservable: Observable<Scene>;
  39503. /**
  39504. * An event triggered before draw calls are ready to be sent
  39505. */
  39506. onBeforeDrawPhaseObservable: Observable<Scene>;
  39507. /**
  39508. * An event triggered after draw calls have been sent
  39509. */
  39510. onAfterDrawPhaseObservable: Observable<Scene>;
  39511. /**
  39512. * An event triggered when the scene is ready
  39513. */
  39514. onReadyObservable: Observable<Scene>;
  39515. /**
  39516. * An event triggered before rendering a camera
  39517. */
  39518. onBeforeCameraRenderObservable: Observable<Camera>;
  39519. private _onBeforeCameraRenderObserver;
  39520. /** Sets a function to be executed before rendering a camera*/
  39521. set beforeCameraRender(callback: () => void);
  39522. /**
  39523. * An event triggered after rendering a camera
  39524. */
  39525. onAfterCameraRenderObservable: Observable<Camera>;
  39526. private _onAfterCameraRenderObserver;
  39527. /** Sets a function to be executed after rendering a camera*/
  39528. set afterCameraRender(callback: () => void);
  39529. /**
  39530. * An event triggered when active meshes evaluation is about to start
  39531. */
  39532. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39533. /**
  39534. * An event triggered when active meshes evaluation is done
  39535. */
  39536. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39537. /**
  39538. * An event triggered when particles rendering is about to start
  39539. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39540. */
  39541. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39542. /**
  39543. * An event triggered when particles rendering is done
  39544. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39545. */
  39546. onAfterParticlesRenderingObservable: Observable<Scene>;
  39547. /**
  39548. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39549. */
  39550. onDataLoadedObservable: Observable<Scene>;
  39551. /**
  39552. * An event triggered when a camera is created
  39553. */
  39554. onNewCameraAddedObservable: Observable<Camera>;
  39555. /**
  39556. * An event triggered when a camera is removed
  39557. */
  39558. onCameraRemovedObservable: Observable<Camera>;
  39559. /**
  39560. * An event triggered when a light is created
  39561. */
  39562. onNewLightAddedObservable: Observable<Light>;
  39563. /**
  39564. * An event triggered when a light is removed
  39565. */
  39566. onLightRemovedObservable: Observable<Light>;
  39567. /**
  39568. * An event triggered when a geometry is created
  39569. */
  39570. onNewGeometryAddedObservable: Observable<Geometry>;
  39571. /**
  39572. * An event triggered when a geometry is removed
  39573. */
  39574. onGeometryRemovedObservable: Observable<Geometry>;
  39575. /**
  39576. * An event triggered when a transform node is created
  39577. */
  39578. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39579. /**
  39580. * An event triggered when a transform node is removed
  39581. */
  39582. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39583. /**
  39584. * An event triggered when a mesh is created
  39585. */
  39586. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39587. /**
  39588. * An event triggered when a mesh is removed
  39589. */
  39590. onMeshRemovedObservable: Observable<AbstractMesh>;
  39591. /**
  39592. * An event triggered when a skeleton is created
  39593. */
  39594. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39595. /**
  39596. * An event triggered when a skeleton is removed
  39597. */
  39598. onSkeletonRemovedObservable: Observable<Skeleton>;
  39599. /**
  39600. * An event triggered when a material is created
  39601. */
  39602. onNewMaterialAddedObservable: Observable<Material>;
  39603. /**
  39604. * An event triggered when a material is removed
  39605. */
  39606. onMaterialRemovedObservable: Observable<Material>;
  39607. /**
  39608. * An event triggered when a texture is created
  39609. */
  39610. onNewTextureAddedObservable: Observable<BaseTexture>;
  39611. /**
  39612. * An event triggered when a texture is removed
  39613. */
  39614. onTextureRemovedObservable: Observable<BaseTexture>;
  39615. /**
  39616. * An event triggered when render targets are about to be rendered
  39617. * Can happen multiple times per frame.
  39618. */
  39619. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39620. /**
  39621. * An event triggered when render targets were rendered.
  39622. * Can happen multiple times per frame.
  39623. */
  39624. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39625. /**
  39626. * An event triggered before calculating deterministic simulation step
  39627. */
  39628. onBeforeStepObservable: Observable<Scene>;
  39629. /**
  39630. * An event triggered after calculating deterministic simulation step
  39631. */
  39632. onAfterStepObservable: Observable<Scene>;
  39633. /**
  39634. * An event triggered when the activeCamera property is updated
  39635. */
  39636. onActiveCameraChanged: Observable<Scene>;
  39637. /**
  39638. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39639. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39640. * 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)
  39641. */
  39642. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39643. /**
  39644. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  39645. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39646. * 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)
  39647. */
  39648. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39649. /**
  39650. * This Observable will when a mesh has been imported into the scene.
  39651. */
  39652. onMeshImportedObservable: Observable<AbstractMesh>;
  39653. /**
  39654. * This Observable will when an animation file has been imported into the scene.
  39655. */
  39656. onAnimationFileImportedObservable: Observable<Scene>;
  39657. /**
  39658. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  39659. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  39660. */
  39661. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  39662. /** @hidden */
  39663. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  39664. /**
  39665. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  39666. */
  39667. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  39668. /**
  39669. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  39670. */
  39671. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  39672. /**
  39673. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  39674. */
  39675. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  39676. /** Callback called when a pointer move is detected */
  39677. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39678. /** Callback called when a pointer down is detected */
  39679. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39680. /** Callback called when a pointer up is detected */
  39681. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  39682. /** Callback called when a pointer pick is detected */
  39683. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  39684. /**
  39685. * 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).
  39686. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  39687. */
  39688. onPrePointerObservable: Observable<PointerInfoPre>;
  39689. /**
  39690. * Observable event triggered each time an input event is received from the rendering canvas
  39691. */
  39692. onPointerObservable: Observable<PointerInfo>;
  39693. /**
  39694. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  39695. */
  39696. get unTranslatedPointer(): Vector2;
  39697. /**
  39698. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  39699. */
  39700. static get DragMovementThreshold(): number;
  39701. static set DragMovementThreshold(value: number);
  39702. /**
  39703. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  39704. */
  39705. static get LongPressDelay(): number;
  39706. static set LongPressDelay(value: number);
  39707. /**
  39708. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  39709. */
  39710. static get DoubleClickDelay(): number;
  39711. static set DoubleClickDelay(value: number);
  39712. /** If you need to check double click without raising a single click at first click, enable this flag */
  39713. static get ExclusiveDoubleClickMode(): boolean;
  39714. static set ExclusiveDoubleClickMode(value: boolean);
  39715. /** @hidden */
  39716. _mirroredCameraPosition: Nullable<Vector3>;
  39717. /**
  39718. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  39719. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  39720. */
  39721. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  39722. /**
  39723. * Observable event triggered each time an keyboard event is received from the hosting window
  39724. */
  39725. onKeyboardObservable: Observable<KeyboardInfo>;
  39726. private _useRightHandedSystem;
  39727. /**
  39728. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  39729. */
  39730. set useRightHandedSystem(value: boolean);
  39731. get useRightHandedSystem(): boolean;
  39732. private _timeAccumulator;
  39733. private _currentStepId;
  39734. private _currentInternalStep;
  39735. /**
  39736. * Sets the step Id used by deterministic lock step
  39737. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39738. * @param newStepId defines the step Id
  39739. */
  39740. setStepId(newStepId: number): void;
  39741. /**
  39742. * Gets the step Id used by deterministic lock step
  39743. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39744. * @returns the step Id
  39745. */
  39746. getStepId(): number;
  39747. /**
  39748. * Gets the internal step used by deterministic lock step
  39749. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39750. * @returns the internal step
  39751. */
  39752. getInternalStep(): number;
  39753. private _fogEnabled;
  39754. /**
  39755. * Gets or sets a boolean indicating if fog is enabled on this scene
  39756. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39757. * (Default is true)
  39758. */
  39759. set fogEnabled(value: boolean);
  39760. get fogEnabled(): boolean;
  39761. private _fogMode;
  39762. /**
  39763. * Gets or sets the fog mode to use
  39764. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39765. * | mode | value |
  39766. * | --- | --- |
  39767. * | FOGMODE_NONE | 0 |
  39768. * | FOGMODE_EXP | 1 |
  39769. * | FOGMODE_EXP2 | 2 |
  39770. * | FOGMODE_LINEAR | 3 |
  39771. */
  39772. set fogMode(value: number);
  39773. get fogMode(): number;
  39774. /**
  39775. * Gets or sets the fog color to use
  39776. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39777. * (Default is Color3(0.2, 0.2, 0.3))
  39778. */
  39779. fogColor: Color3;
  39780. /**
  39781. * Gets or sets the fog density to use
  39782. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39783. * (Default is 0.1)
  39784. */
  39785. fogDensity: number;
  39786. /**
  39787. * Gets or sets the fog start distance to use
  39788. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39789. * (Default is 0)
  39790. */
  39791. fogStart: number;
  39792. /**
  39793. * Gets or sets the fog end distance to use
  39794. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39795. * (Default is 1000)
  39796. */
  39797. fogEnd: number;
  39798. /**
  39799. * Flag indicating that the frame buffer binding is handled by another component
  39800. */
  39801. prePass: boolean;
  39802. private _shadowsEnabled;
  39803. /**
  39804. * Gets or sets a boolean indicating if shadows are enabled on this scene
  39805. */
  39806. set shadowsEnabled(value: boolean);
  39807. get shadowsEnabled(): boolean;
  39808. private _lightsEnabled;
  39809. /**
  39810. * Gets or sets a boolean indicating if lights are enabled on this scene
  39811. */
  39812. set lightsEnabled(value: boolean);
  39813. get lightsEnabled(): boolean;
  39814. /** All of the active cameras added to this scene. */
  39815. activeCameras: Camera[];
  39816. /** @hidden */
  39817. _activeCamera: Nullable<Camera>;
  39818. /** Gets or sets the current active camera */
  39819. get activeCamera(): Nullable<Camera>;
  39820. set activeCamera(value: Nullable<Camera>);
  39821. private _defaultMaterial;
  39822. /** The default material used on meshes when no material is affected */
  39823. get defaultMaterial(): Material;
  39824. /** The default material used on meshes when no material is affected */
  39825. set defaultMaterial(value: Material);
  39826. private _texturesEnabled;
  39827. /**
  39828. * Gets or sets a boolean indicating if textures are enabled on this scene
  39829. */
  39830. set texturesEnabled(value: boolean);
  39831. get texturesEnabled(): boolean;
  39832. /**
  39833. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  39834. */
  39835. physicsEnabled: boolean;
  39836. /**
  39837. * Gets or sets a boolean indicating if particles are enabled on this scene
  39838. */
  39839. particlesEnabled: boolean;
  39840. /**
  39841. * Gets or sets a boolean indicating if sprites are enabled on this scene
  39842. */
  39843. spritesEnabled: boolean;
  39844. private _skeletonsEnabled;
  39845. /**
  39846. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  39847. */
  39848. set skeletonsEnabled(value: boolean);
  39849. get skeletonsEnabled(): boolean;
  39850. /**
  39851. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  39852. */
  39853. lensFlaresEnabled: boolean;
  39854. /**
  39855. * Gets or sets a boolean indicating if collisions are enabled on this scene
  39856. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39857. */
  39858. collisionsEnabled: boolean;
  39859. private _collisionCoordinator;
  39860. /** @hidden */
  39861. get collisionCoordinator(): ICollisionCoordinator;
  39862. /**
  39863. * Defines the gravity applied to this scene (used only for collisions)
  39864. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39865. */
  39866. gravity: Vector3;
  39867. /**
  39868. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  39869. */
  39870. postProcessesEnabled: boolean;
  39871. /**
  39872. * Gets the current postprocess manager
  39873. */
  39874. postProcessManager: PostProcessManager;
  39875. /**
  39876. * Gets or sets a boolean indicating if render targets are enabled on this scene
  39877. */
  39878. renderTargetsEnabled: boolean;
  39879. /**
  39880. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  39881. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  39882. */
  39883. dumpNextRenderTargets: boolean;
  39884. /**
  39885. * The list of user defined render targets added to the scene
  39886. */
  39887. customRenderTargets: RenderTargetTexture[];
  39888. /**
  39889. * Defines if texture loading must be delayed
  39890. * If true, textures will only be loaded when they need to be rendered
  39891. */
  39892. useDelayedTextureLoading: boolean;
  39893. /**
  39894. * Gets the list of meshes imported to the scene through SceneLoader
  39895. */
  39896. importedMeshesFiles: String[];
  39897. /**
  39898. * Gets or sets a boolean indicating if probes are enabled on this scene
  39899. */
  39900. probesEnabled: boolean;
  39901. /**
  39902. * Gets or sets the current offline provider to use to store scene data
  39903. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  39904. */
  39905. offlineProvider: IOfflineProvider;
  39906. /**
  39907. * Gets or sets the action manager associated with the scene
  39908. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  39909. */
  39910. actionManager: AbstractActionManager;
  39911. private _meshesForIntersections;
  39912. /**
  39913. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  39914. */
  39915. proceduralTexturesEnabled: boolean;
  39916. private _engine;
  39917. private _totalVertices;
  39918. /** @hidden */
  39919. _activeIndices: PerfCounter;
  39920. /** @hidden */
  39921. _activeParticles: PerfCounter;
  39922. /** @hidden */
  39923. _activeBones: PerfCounter;
  39924. private _animationRatio;
  39925. /** @hidden */
  39926. _animationTimeLast: number;
  39927. /** @hidden */
  39928. _animationTime: number;
  39929. /**
  39930. * Gets or sets a general scale for animation speed
  39931. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  39932. */
  39933. animationTimeScale: number;
  39934. /** @hidden */
  39935. _cachedMaterial: Nullable<Material>;
  39936. /** @hidden */
  39937. _cachedEffect: Nullable<Effect>;
  39938. /** @hidden */
  39939. _cachedVisibility: Nullable<number>;
  39940. private _renderId;
  39941. private _frameId;
  39942. private _executeWhenReadyTimeoutId;
  39943. private _intermediateRendering;
  39944. private _viewUpdateFlag;
  39945. private _projectionUpdateFlag;
  39946. /** @hidden */
  39947. _toBeDisposed: Nullable<IDisposable>[];
  39948. private _activeRequests;
  39949. /** @hidden */
  39950. _pendingData: any[];
  39951. private _isDisposed;
  39952. /**
  39953. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  39954. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  39955. */
  39956. dispatchAllSubMeshesOfActiveMeshes: boolean;
  39957. private _activeMeshes;
  39958. private _processedMaterials;
  39959. private _renderTargets;
  39960. /** @hidden */
  39961. _activeParticleSystems: SmartArray<IParticleSystem>;
  39962. private _activeSkeletons;
  39963. private _softwareSkinnedMeshes;
  39964. private _renderingManager;
  39965. /** @hidden */
  39966. _activeAnimatables: Animatable[];
  39967. private _transformMatrix;
  39968. private _sceneUbo;
  39969. /** @hidden */
  39970. _viewMatrix: Matrix;
  39971. private _projectionMatrix;
  39972. /** @hidden */
  39973. _forcedViewPosition: Nullable<Vector3>;
  39974. /** @hidden */
  39975. _frustumPlanes: Plane[];
  39976. /**
  39977. * Gets the list of frustum planes (built from the active camera)
  39978. */
  39979. get frustumPlanes(): Plane[];
  39980. /**
  39981. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  39982. * This is useful if there are more lights that the maximum simulteanous authorized
  39983. */
  39984. requireLightSorting: boolean;
  39985. /** @hidden */
  39986. readonly useMaterialMeshMap: boolean;
  39987. /** @hidden */
  39988. readonly useClonedMeshMap: boolean;
  39989. private _externalData;
  39990. private _uid;
  39991. /**
  39992. * @hidden
  39993. * Backing store of defined scene components.
  39994. */
  39995. _components: ISceneComponent[];
  39996. /**
  39997. * @hidden
  39998. * Backing store of defined scene components.
  39999. */
  40000. _serializableComponents: ISceneSerializableComponent[];
  40001. /**
  40002. * List of components to register on the next registration step.
  40003. */
  40004. private _transientComponents;
  40005. /**
  40006. * Registers the transient components if needed.
  40007. */
  40008. private _registerTransientComponents;
  40009. /**
  40010. * @hidden
  40011. * Add a component to the scene.
  40012. * Note that the ccomponent could be registered on th next frame if this is called after
  40013. * the register component stage.
  40014. * @param component Defines the component to add to the scene
  40015. */
  40016. _addComponent(component: ISceneComponent): void;
  40017. /**
  40018. * @hidden
  40019. * Gets a component from the scene.
  40020. * @param name defines the name of the component to retrieve
  40021. * @returns the component or null if not present
  40022. */
  40023. _getComponent(name: string): Nullable<ISceneComponent>;
  40024. /**
  40025. * @hidden
  40026. * Defines the actions happening before camera updates.
  40027. */
  40028. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40029. /**
  40030. * @hidden
  40031. * Defines the actions happening before clear the canvas.
  40032. */
  40033. _beforeClearStage: Stage<SimpleStageAction>;
  40034. /**
  40035. * @hidden
  40036. * Defines the actions when collecting render targets for the frame.
  40037. */
  40038. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40039. /**
  40040. * @hidden
  40041. * Defines the actions happening for one camera in the frame.
  40042. */
  40043. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40044. /**
  40045. * @hidden
  40046. * Defines the actions happening during the per mesh ready checks.
  40047. */
  40048. _isReadyForMeshStage: Stage<MeshStageAction>;
  40049. /**
  40050. * @hidden
  40051. * Defines the actions happening before evaluate active mesh checks.
  40052. */
  40053. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40054. /**
  40055. * @hidden
  40056. * Defines the actions happening during the evaluate sub mesh checks.
  40057. */
  40058. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40059. /**
  40060. * @hidden
  40061. * Defines the actions happening during the active mesh stage.
  40062. */
  40063. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40064. /**
  40065. * @hidden
  40066. * Defines the actions happening during the per camera render target step.
  40067. */
  40068. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40069. /**
  40070. * @hidden
  40071. * Defines the actions happening just before the active camera is drawing.
  40072. */
  40073. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40074. /**
  40075. * @hidden
  40076. * Defines the actions happening just before a render target is drawing.
  40077. */
  40078. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40079. /**
  40080. * @hidden
  40081. * Defines the actions happening just before a rendering group is drawing.
  40082. */
  40083. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40084. /**
  40085. * @hidden
  40086. * Defines the actions happening just before a mesh is drawing.
  40087. */
  40088. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40089. /**
  40090. * @hidden
  40091. * Defines the actions happening just after a mesh has been drawn.
  40092. */
  40093. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40094. /**
  40095. * @hidden
  40096. * Defines the actions happening just after a rendering group has been drawn.
  40097. */
  40098. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40099. /**
  40100. * @hidden
  40101. * Defines the actions happening just after the active camera has been drawn.
  40102. */
  40103. _afterCameraDrawStage: Stage<CameraStageAction>;
  40104. /**
  40105. * @hidden
  40106. * Defines the actions happening just after a render target has been drawn.
  40107. */
  40108. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40109. /**
  40110. * @hidden
  40111. * Defines the actions happening just after rendering all cameras and computing intersections.
  40112. */
  40113. _afterRenderStage: Stage<SimpleStageAction>;
  40114. /**
  40115. * @hidden
  40116. * Defines the actions happening when a pointer move event happens.
  40117. */
  40118. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40119. /**
  40120. * @hidden
  40121. * Defines the actions happening when a pointer down event happens.
  40122. */
  40123. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40124. /**
  40125. * @hidden
  40126. * Defines the actions happening when a pointer up event happens.
  40127. */
  40128. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40129. /**
  40130. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40131. */
  40132. private geometriesByUniqueId;
  40133. /**
  40134. * Creates a new Scene
  40135. * @param engine defines the engine to use to render this scene
  40136. * @param options defines the scene options
  40137. */
  40138. constructor(engine: Engine, options?: SceneOptions);
  40139. /**
  40140. * Gets a string identifying the name of the class
  40141. * @returns "Scene" string
  40142. */
  40143. getClassName(): string;
  40144. private _defaultMeshCandidates;
  40145. /**
  40146. * @hidden
  40147. */
  40148. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40149. private _defaultSubMeshCandidates;
  40150. /**
  40151. * @hidden
  40152. */
  40153. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40154. /**
  40155. * Sets the default candidate providers for the scene.
  40156. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40157. * and getCollidingSubMeshCandidates to their default function
  40158. */
  40159. setDefaultCandidateProviders(): void;
  40160. /**
  40161. * Gets the mesh that is currently under the pointer
  40162. */
  40163. get meshUnderPointer(): Nullable<AbstractMesh>;
  40164. /**
  40165. * Gets or sets the current on-screen X position of the pointer
  40166. */
  40167. get pointerX(): number;
  40168. set pointerX(value: number);
  40169. /**
  40170. * Gets or sets the current on-screen Y position of the pointer
  40171. */
  40172. get pointerY(): number;
  40173. set pointerY(value: number);
  40174. /**
  40175. * Gets the cached material (ie. the latest rendered one)
  40176. * @returns the cached material
  40177. */
  40178. getCachedMaterial(): Nullable<Material>;
  40179. /**
  40180. * Gets the cached effect (ie. the latest rendered one)
  40181. * @returns the cached effect
  40182. */
  40183. getCachedEffect(): Nullable<Effect>;
  40184. /**
  40185. * Gets the cached visibility state (ie. the latest rendered one)
  40186. * @returns the cached visibility state
  40187. */
  40188. getCachedVisibility(): Nullable<number>;
  40189. /**
  40190. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40191. * @param material defines the current material
  40192. * @param effect defines the current effect
  40193. * @param visibility defines the current visibility state
  40194. * @returns true if one parameter is not cached
  40195. */
  40196. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40197. /**
  40198. * Gets the engine associated with the scene
  40199. * @returns an Engine
  40200. */
  40201. getEngine(): Engine;
  40202. /**
  40203. * Gets the total number of vertices rendered per frame
  40204. * @returns the total number of vertices rendered per frame
  40205. */
  40206. getTotalVertices(): number;
  40207. /**
  40208. * Gets the performance counter for total vertices
  40209. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40210. */
  40211. get totalVerticesPerfCounter(): PerfCounter;
  40212. /**
  40213. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40214. * @returns the total number of active indices rendered per frame
  40215. */
  40216. getActiveIndices(): number;
  40217. /**
  40218. * Gets the performance counter for active indices
  40219. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40220. */
  40221. get totalActiveIndicesPerfCounter(): PerfCounter;
  40222. /**
  40223. * Gets the total number of active particles rendered per frame
  40224. * @returns the total number of active particles rendered per frame
  40225. */
  40226. getActiveParticles(): number;
  40227. /**
  40228. * Gets the performance counter for active particles
  40229. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40230. */
  40231. get activeParticlesPerfCounter(): PerfCounter;
  40232. /**
  40233. * Gets the total number of active bones rendered per frame
  40234. * @returns the total number of active bones rendered per frame
  40235. */
  40236. getActiveBones(): number;
  40237. /**
  40238. * Gets the performance counter for active bones
  40239. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40240. */
  40241. get activeBonesPerfCounter(): PerfCounter;
  40242. /**
  40243. * Gets the array of active meshes
  40244. * @returns an array of AbstractMesh
  40245. */
  40246. getActiveMeshes(): SmartArray<AbstractMesh>;
  40247. /**
  40248. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40249. * @returns a number
  40250. */
  40251. getAnimationRatio(): number;
  40252. /**
  40253. * Gets an unique Id for the current render phase
  40254. * @returns a number
  40255. */
  40256. getRenderId(): number;
  40257. /**
  40258. * Gets an unique Id for the current frame
  40259. * @returns a number
  40260. */
  40261. getFrameId(): number;
  40262. /** Call this function if you want to manually increment the render Id*/
  40263. incrementRenderId(): void;
  40264. private _createUbo;
  40265. /**
  40266. * Use this method to simulate a pointer move on a mesh
  40267. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40268. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40269. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40270. * @returns the current scene
  40271. */
  40272. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40273. /**
  40274. * Use this method to simulate a pointer down on a mesh
  40275. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40276. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40277. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40278. * @returns the current scene
  40279. */
  40280. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40281. /**
  40282. * Use this method to simulate a pointer up on a mesh
  40283. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40284. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40285. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40286. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40287. * @returns the current scene
  40288. */
  40289. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40290. /**
  40291. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40292. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40293. * @returns true if the pointer was captured
  40294. */
  40295. isPointerCaptured(pointerId?: number): boolean;
  40296. /**
  40297. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40298. * @param attachUp defines if you want to attach events to pointerup
  40299. * @param attachDown defines if you want to attach events to pointerdown
  40300. * @param attachMove defines if you want to attach events to pointermove
  40301. */
  40302. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40303. /** Detaches all event handlers*/
  40304. detachControl(): void;
  40305. /**
  40306. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40307. * Delay loaded resources are not taking in account
  40308. * @return true if all required resources are ready
  40309. */
  40310. isReady(): boolean;
  40311. /** Resets all cached information relative to material (including effect and visibility) */
  40312. resetCachedMaterial(): void;
  40313. /**
  40314. * Registers a function to be called before every frame render
  40315. * @param func defines the function to register
  40316. */
  40317. registerBeforeRender(func: () => void): void;
  40318. /**
  40319. * Unregisters a function called before every frame render
  40320. * @param func defines the function to unregister
  40321. */
  40322. unregisterBeforeRender(func: () => void): void;
  40323. /**
  40324. * Registers a function to be called after every frame render
  40325. * @param func defines the function to register
  40326. */
  40327. registerAfterRender(func: () => void): void;
  40328. /**
  40329. * Unregisters a function called after every frame render
  40330. * @param func defines the function to unregister
  40331. */
  40332. unregisterAfterRender(func: () => void): void;
  40333. private _executeOnceBeforeRender;
  40334. /**
  40335. * The provided function will run before render once and will be disposed afterwards.
  40336. * A timeout delay can be provided so that the function will be executed in N ms.
  40337. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40338. * @param func The function to be executed.
  40339. * @param timeout optional delay in ms
  40340. */
  40341. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40342. /** @hidden */
  40343. _addPendingData(data: any): void;
  40344. /** @hidden */
  40345. _removePendingData(data: any): void;
  40346. /**
  40347. * Returns the number of items waiting to be loaded
  40348. * @returns the number of items waiting to be loaded
  40349. */
  40350. getWaitingItemsCount(): number;
  40351. /**
  40352. * Returns a boolean indicating if the scene is still loading data
  40353. */
  40354. get isLoading(): boolean;
  40355. /**
  40356. * Registers a function to be executed when the scene is ready
  40357. * @param {Function} func - the function to be executed
  40358. */
  40359. executeWhenReady(func: () => void): void;
  40360. /**
  40361. * Returns a promise that resolves when the scene is ready
  40362. * @returns A promise that resolves when the scene is ready
  40363. */
  40364. whenReadyAsync(): Promise<void>;
  40365. /** @hidden */
  40366. _checkIsReady(): void;
  40367. /**
  40368. * Gets all animatable attached to the scene
  40369. */
  40370. get animatables(): Animatable[];
  40371. /**
  40372. * Resets the last animation time frame.
  40373. * Useful to override when animations start running when loading a scene for the first time.
  40374. */
  40375. resetLastAnimationTimeFrame(): void;
  40376. /**
  40377. * Gets the current view matrix
  40378. * @returns a Matrix
  40379. */
  40380. getViewMatrix(): Matrix;
  40381. /**
  40382. * Gets the current projection matrix
  40383. * @returns a Matrix
  40384. */
  40385. getProjectionMatrix(): Matrix;
  40386. /**
  40387. * Gets the current transform matrix
  40388. * @returns a Matrix made of View * Projection
  40389. */
  40390. getTransformMatrix(): Matrix;
  40391. /**
  40392. * Sets the current transform matrix
  40393. * @param viewL defines the View matrix to use
  40394. * @param projectionL defines the Projection matrix to use
  40395. * @param viewR defines the right View matrix to use (if provided)
  40396. * @param projectionR defines the right Projection matrix to use (if provided)
  40397. */
  40398. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40399. /**
  40400. * Gets the uniform buffer used to store scene data
  40401. * @returns a UniformBuffer
  40402. */
  40403. getSceneUniformBuffer(): UniformBuffer;
  40404. /**
  40405. * Gets an unique (relatively to the current scene) Id
  40406. * @returns an unique number for the scene
  40407. */
  40408. getUniqueId(): number;
  40409. /**
  40410. * Add a mesh to the list of scene's meshes
  40411. * @param newMesh defines the mesh to add
  40412. * @param recursive if all child meshes should also be added to the scene
  40413. */
  40414. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40415. /**
  40416. * Remove a mesh for the list of scene's meshes
  40417. * @param toRemove defines the mesh to remove
  40418. * @param recursive if all child meshes should also be removed from the scene
  40419. * @returns the index where the mesh was in the mesh list
  40420. */
  40421. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40422. /**
  40423. * Add a transform node to the list of scene's transform nodes
  40424. * @param newTransformNode defines the transform node to add
  40425. */
  40426. addTransformNode(newTransformNode: TransformNode): void;
  40427. /**
  40428. * Remove a transform node for the list of scene's transform nodes
  40429. * @param toRemove defines the transform node to remove
  40430. * @returns the index where the transform node was in the transform node list
  40431. */
  40432. removeTransformNode(toRemove: TransformNode): number;
  40433. /**
  40434. * Remove a skeleton for the list of scene's skeletons
  40435. * @param toRemove defines the skeleton to remove
  40436. * @returns the index where the skeleton was in the skeleton list
  40437. */
  40438. removeSkeleton(toRemove: Skeleton): number;
  40439. /**
  40440. * Remove a morph target for the list of scene's morph targets
  40441. * @param toRemove defines the morph target to remove
  40442. * @returns the index where the morph target was in the morph target list
  40443. */
  40444. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40445. /**
  40446. * Remove a light for the list of scene's lights
  40447. * @param toRemove defines the light to remove
  40448. * @returns the index where the light was in the light list
  40449. */
  40450. removeLight(toRemove: Light): number;
  40451. /**
  40452. * Remove a camera for the list of scene's cameras
  40453. * @param toRemove defines the camera to remove
  40454. * @returns the index where the camera was in the camera list
  40455. */
  40456. removeCamera(toRemove: Camera): number;
  40457. /**
  40458. * Remove a particle system for the list of scene's particle systems
  40459. * @param toRemove defines the particle system to remove
  40460. * @returns the index where the particle system was in the particle system list
  40461. */
  40462. removeParticleSystem(toRemove: IParticleSystem): number;
  40463. /**
  40464. * Remove a animation for the list of scene's animations
  40465. * @param toRemove defines the animation to remove
  40466. * @returns the index where the animation was in the animation list
  40467. */
  40468. removeAnimation(toRemove: Animation): number;
  40469. /**
  40470. * Will stop the animation of the given target
  40471. * @param target - the target
  40472. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40473. * @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)
  40474. */
  40475. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40476. /**
  40477. * Removes the given animation group from this scene.
  40478. * @param toRemove The animation group to remove
  40479. * @returns The index of the removed animation group
  40480. */
  40481. removeAnimationGroup(toRemove: AnimationGroup): number;
  40482. /**
  40483. * Removes the given multi-material from this scene.
  40484. * @param toRemove The multi-material to remove
  40485. * @returns The index of the removed multi-material
  40486. */
  40487. removeMultiMaterial(toRemove: MultiMaterial): number;
  40488. /**
  40489. * Removes the given material from this scene.
  40490. * @param toRemove The material to remove
  40491. * @returns The index of the removed material
  40492. */
  40493. removeMaterial(toRemove: Material): number;
  40494. /**
  40495. * Removes the given action manager from this scene.
  40496. * @param toRemove The action manager to remove
  40497. * @returns The index of the removed action manager
  40498. */
  40499. removeActionManager(toRemove: AbstractActionManager): number;
  40500. /**
  40501. * Removes the given texture from this scene.
  40502. * @param toRemove The texture to remove
  40503. * @returns The index of the removed texture
  40504. */
  40505. removeTexture(toRemove: BaseTexture): number;
  40506. /**
  40507. * Adds the given light to this scene
  40508. * @param newLight The light to add
  40509. */
  40510. addLight(newLight: Light): void;
  40511. /**
  40512. * Sorts the list list based on light priorities
  40513. */
  40514. sortLightsByPriority(): void;
  40515. /**
  40516. * Adds the given camera to this scene
  40517. * @param newCamera The camera to add
  40518. */
  40519. addCamera(newCamera: Camera): void;
  40520. /**
  40521. * Adds the given skeleton to this scene
  40522. * @param newSkeleton The skeleton to add
  40523. */
  40524. addSkeleton(newSkeleton: Skeleton): void;
  40525. /**
  40526. * Adds the given particle system to this scene
  40527. * @param newParticleSystem The particle system to add
  40528. */
  40529. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40530. /**
  40531. * Adds the given animation to this scene
  40532. * @param newAnimation The animation to add
  40533. */
  40534. addAnimation(newAnimation: Animation): void;
  40535. /**
  40536. * Adds the given animation group to this scene.
  40537. * @param newAnimationGroup The animation group to add
  40538. */
  40539. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40540. /**
  40541. * Adds the given multi-material to this scene
  40542. * @param newMultiMaterial The multi-material to add
  40543. */
  40544. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40545. /**
  40546. * Adds the given material to this scene
  40547. * @param newMaterial The material to add
  40548. */
  40549. addMaterial(newMaterial: Material): void;
  40550. /**
  40551. * Adds the given morph target to this scene
  40552. * @param newMorphTargetManager The morph target to add
  40553. */
  40554. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40555. /**
  40556. * Adds the given geometry to this scene
  40557. * @param newGeometry The geometry to add
  40558. */
  40559. addGeometry(newGeometry: Geometry): void;
  40560. /**
  40561. * Adds the given action manager to this scene
  40562. * @param newActionManager The action manager to add
  40563. */
  40564. addActionManager(newActionManager: AbstractActionManager): void;
  40565. /**
  40566. * Adds the given texture to this scene.
  40567. * @param newTexture The texture to add
  40568. */
  40569. addTexture(newTexture: BaseTexture): void;
  40570. /**
  40571. * Switch active camera
  40572. * @param newCamera defines the new active camera
  40573. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40574. */
  40575. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40576. /**
  40577. * sets the active camera of the scene using its ID
  40578. * @param id defines the camera's ID
  40579. * @return the new active camera or null if none found.
  40580. */
  40581. setActiveCameraByID(id: string): Nullable<Camera>;
  40582. /**
  40583. * sets the active camera of the scene using its name
  40584. * @param name defines the camera's name
  40585. * @returns the new active camera or null if none found.
  40586. */
  40587. setActiveCameraByName(name: string): Nullable<Camera>;
  40588. /**
  40589. * get an animation group using its name
  40590. * @param name defines the material's name
  40591. * @return the animation group or null if none found.
  40592. */
  40593. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40594. /**
  40595. * Get a material using its unique id
  40596. * @param uniqueId defines the material's unique id
  40597. * @return the material or null if none found.
  40598. */
  40599. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40600. /**
  40601. * get a material using its id
  40602. * @param id defines the material's ID
  40603. * @return the material or null if none found.
  40604. */
  40605. getMaterialByID(id: string): Nullable<Material>;
  40606. /**
  40607. * Gets a the last added material using a given id
  40608. * @param id defines the material's ID
  40609. * @return the last material with the given id or null if none found.
  40610. */
  40611. getLastMaterialByID(id: string): Nullable<Material>;
  40612. /**
  40613. * Gets a material using its name
  40614. * @param name defines the material's name
  40615. * @return the material or null if none found.
  40616. */
  40617. getMaterialByName(name: string): Nullable<Material>;
  40618. /**
  40619. * Get a texture using its unique id
  40620. * @param uniqueId defines the texture's unique id
  40621. * @return the texture or null if none found.
  40622. */
  40623. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40624. /**
  40625. * Gets a camera using its id
  40626. * @param id defines the id to look for
  40627. * @returns the camera or null if not found
  40628. */
  40629. getCameraByID(id: string): Nullable<Camera>;
  40630. /**
  40631. * Gets a camera using its unique id
  40632. * @param uniqueId defines the unique id to look for
  40633. * @returns the camera or null if not found
  40634. */
  40635. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40636. /**
  40637. * Gets a camera using its name
  40638. * @param name defines the camera's name
  40639. * @return the camera or null if none found.
  40640. */
  40641. getCameraByName(name: string): Nullable<Camera>;
  40642. /**
  40643. * Gets a bone using its id
  40644. * @param id defines the bone's id
  40645. * @return the bone or null if not found
  40646. */
  40647. getBoneByID(id: string): Nullable<Bone>;
  40648. /**
  40649. * Gets a bone using its id
  40650. * @param name defines the bone's name
  40651. * @return the bone or null if not found
  40652. */
  40653. getBoneByName(name: string): Nullable<Bone>;
  40654. /**
  40655. * Gets a light node using its name
  40656. * @param name defines the the light's name
  40657. * @return the light or null if none found.
  40658. */
  40659. getLightByName(name: string): Nullable<Light>;
  40660. /**
  40661. * Gets a light node using its id
  40662. * @param id defines the light's id
  40663. * @return the light or null if none found.
  40664. */
  40665. getLightByID(id: string): Nullable<Light>;
  40666. /**
  40667. * Gets a light node using its scene-generated unique ID
  40668. * @param uniqueId defines the light's unique id
  40669. * @return the light or null if none found.
  40670. */
  40671. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  40672. /**
  40673. * Gets a particle system by id
  40674. * @param id defines the particle system id
  40675. * @return the corresponding system or null if none found
  40676. */
  40677. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  40678. /**
  40679. * Gets a geometry using its ID
  40680. * @param id defines the geometry's id
  40681. * @return the geometry or null if none found.
  40682. */
  40683. getGeometryByID(id: string): Nullable<Geometry>;
  40684. private _getGeometryByUniqueID;
  40685. /**
  40686. * Add a new geometry to this scene
  40687. * @param geometry defines the geometry to be added to the scene.
  40688. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  40689. * @return a boolean defining if the geometry was added or not
  40690. */
  40691. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  40692. /**
  40693. * Removes an existing geometry
  40694. * @param geometry defines the geometry to be removed from the scene
  40695. * @return a boolean defining if the geometry was removed or not
  40696. */
  40697. removeGeometry(geometry: Geometry): boolean;
  40698. /**
  40699. * Gets the list of geometries attached to the scene
  40700. * @returns an array of Geometry
  40701. */
  40702. getGeometries(): Geometry[];
  40703. /**
  40704. * Gets the first added mesh found of a given ID
  40705. * @param id defines the id to search for
  40706. * @return the mesh found or null if not found at all
  40707. */
  40708. getMeshByID(id: string): Nullable<AbstractMesh>;
  40709. /**
  40710. * Gets a list of meshes using their id
  40711. * @param id defines the id to search for
  40712. * @returns a list of meshes
  40713. */
  40714. getMeshesByID(id: string): Array<AbstractMesh>;
  40715. /**
  40716. * Gets the first added transform node found of a given ID
  40717. * @param id defines the id to search for
  40718. * @return the found transform node or null if not found at all.
  40719. */
  40720. getTransformNodeByID(id: string): Nullable<TransformNode>;
  40721. /**
  40722. * Gets a transform node with its auto-generated unique id
  40723. * @param uniqueId efines the unique id to search for
  40724. * @return the found transform node or null if not found at all.
  40725. */
  40726. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  40727. /**
  40728. * Gets a list of transform nodes using their id
  40729. * @param id defines the id to search for
  40730. * @returns a list of transform nodes
  40731. */
  40732. getTransformNodesByID(id: string): Array<TransformNode>;
  40733. /**
  40734. * Gets a mesh with its auto-generated unique id
  40735. * @param uniqueId defines the unique id to search for
  40736. * @return the found mesh or null if not found at all.
  40737. */
  40738. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  40739. /**
  40740. * Gets a the last added mesh using a given id
  40741. * @param id defines the id to search for
  40742. * @return the found mesh or null if not found at all.
  40743. */
  40744. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  40745. /**
  40746. * Gets a the last added node (Mesh, Camera, Light) using a given id
  40747. * @param id defines the id to search for
  40748. * @return the found node or null if not found at all
  40749. */
  40750. getLastEntryByID(id: string): Nullable<Node>;
  40751. /**
  40752. * Gets a node (Mesh, Camera, Light) using a given id
  40753. * @param id defines the id to search for
  40754. * @return the found node or null if not found at all
  40755. */
  40756. getNodeByID(id: string): Nullable<Node>;
  40757. /**
  40758. * Gets a node (Mesh, Camera, Light) using a given name
  40759. * @param name defines the name to search for
  40760. * @return the found node or null if not found at all.
  40761. */
  40762. getNodeByName(name: string): Nullable<Node>;
  40763. /**
  40764. * Gets a mesh using a given name
  40765. * @param name defines the name to search for
  40766. * @return the found mesh or null if not found at all.
  40767. */
  40768. getMeshByName(name: string): Nullable<AbstractMesh>;
  40769. /**
  40770. * Gets a transform node using a given name
  40771. * @param name defines the name to search for
  40772. * @return the found transform node or null if not found at all.
  40773. */
  40774. getTransformNodeByName(name: string): Nullable<TransformNode>;
  40775. /**
  40776. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  40777. * @param id defines the id to search for
  40778. * @return the found skeleton or null if not found at all.
  40779. */
  40780. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  40781. /**
  40782. * Gets a skeleton using a given auto generated unique id
  40783. * @param uniqueId defines the unique id to search for
  40784. * @return the found skeleton or null if not found at all.
  40785. */
  40786. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  40787. /**
  40788. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  40789. * @param id defines the id to search for
  40790. * @return the found skeleton or null if not found at all.
  40791. */
  40792. getSkeletonById(id: string): Nullable<Skeleton>;
  40793. /**
  40794. * Gets a skeleton using a given name
  40795. * @param name defines the name to search for
  40796. * @return the found skeleton or null if not found at all.
  40797. */
  40798. getSkeletonByName(name: string): Nullable<Skeleton>;
  40799. /**
  40800. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  40801. * @param id defines the id to search for
  40802. * @return the found morph target manager or null if not found at all.
  40803. */
  40804. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  40805. /**
  40806. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  40807. * @param id defines the id to search for
  40808. * @return the found morph target or null if not found at all.
  40809. */
  40810. getMorphTargetById(id: string): Nullable<MorphTarget>;
  40811. /**
  40812. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  40813. * @param name defines the name to search for
  40814. * @return the found morph target or null if not found at all.
  40815. */
  40816. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  40817. /**
  40818. * Gets a post process using a given name (if many are found, this function will pick the first one)
  40819. * @param name defines the name to search for
  40820. * @return the found post process or null if not found at all.
  40821. */
  40822. getPostProcessByName(name: string): Nullable<PostProcess>;
  40823. /**
  40824. * Gets a boolean indicating if the given mesh is active
  40825. * @param mesh defines the mesh to look for
  40826. * @returns true if the mesh is in the active list
  40827. */
  40828. isActiveMesh(mesh: AbstractMesh): boolean;
  40829. /**
  40830. * Return a unique id as a string which can serve as an identifier for the scene
  40831. */
  40832. get uid(): string;
  40833. /**
  40834. * Add an externaly attached data from its key.
  40835. * This method call will fail and return false, if such key already exists.
  40836. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  40837. * @param key the unique key that identifies the data
  40838. * @param data the data object to associate to the key for this Engine instance
  40839. * @return true if no such key were already present and the data was added successfully, false otherwise
  40840. */
  40841. addExternalData<T>(key: string, data: T): boolean;
  40842. /**
  40843. * Get an externaly attached data from its key
  40844. * @param key the unique key that identifies the data
  40845. * @return the associated data, if present (can be null), or undefined if not present
  40846. */
  40847. getExternalData<T>(key: string): Nullable<T>;
  40848. /**
  40849. * Get an externaly attached data from its key, create it using a factory if it's not already present
  40850. * @param key the unique key that identifies the data
  40851. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  40852. * @return the associated data, can be null if the factory returned null.
  40853. */
  40854. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  40855. /**
  40856. * Remove an externaly attached data from the Engine instance
  40857. * @param key the unique key that identifies the data
  40858. * @return true if the data was successfully removed, false if it doesn't exist
  40859. */
  40860. removeExternalData(key: string): boolean;
  40861. private _evaluateSubMesh;
  40862. /**
  40863. * Clear the processed materials smart array preventing retention point in material dispose.
  40864. */
  40865. freeProcessedMaterials(): void;
  40866. private _preventFreeActiveMeshesAndRenderingGroups;
  40867. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  40868. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  40869. * when disposing several meshes in a row or a hierarchy of meshes.
  40870. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  40871. */
  40872. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  40873. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  40874. /**
  40875. * Clear the active meshes smart array preventing retention point in mesh dispose.
  40876. */
  40877. freeActiveMeshes(): void;
  40878. /**
  40879. * Clear the info related to rendering groups preventing retention points during dispose.
  40880. */
  40881. freeRenderingGroups(): void;
  40882. /** @hidden */
  40883. _isInIntermediateRendering(): boolean;
  40884. /**
  40885. * Lambda returning the list of potentially active meshes.
  40886. */
  40887. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  40888. /**
  40889. * Lambda returning the list of potentially active sub meshes.
  40890. */
  40891. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  40892. /**
  40893. * Lambda returning the list of potentially intersecting sub meshes.
  40894. */
  40895. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  40896. /**
  40897. * Lambda returning the list of potentially colliding sub meshes.
  40898. */
  40899. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  40900. private _activeMeshesFrozen;
  40901. private _skipEvaluateActiveMeshesCompletely;
  40902. /**
  40903. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  40904. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  40905. * @returns the current scene
  40906. */
  40907. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  40908. /**
  40909. * Use this function to restart evaluating active meshes on every frame
  40910. * @returns the current scene
  40911. */
  40912. unfreezeActiveMeshes(): Scene;
  40913. private _evaluateActiveMeshes;
  40914. private _activeMesh;
  40915. /**
  40916. * Update the transform matrix to update from the current active camera
  40917. * @param force defines a boolean used to force the update even if cache is up to date
  40918. */
  40919. updateTransformMatrix(force?: boolean): void;
  40920. private _bindFrameBuffer;
  40921. /** @hidden */
  40922. _allowPostProcessClearColor: boolean;
  40923. /** @hidden */
  40924. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  40925. private _processSubCameras;
  40926. private _checkIntersections;
  40927. /** @hidden */
  40928. _advancePhysicsEngineStep(step: number): void;
  40929. /**
  40930. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  40931. */
  40932. getDeterministicFrameTime: () => number;
  40933. /** @hidden */
  40934. _animate(): void;
  40935. /** Execute all animations (for a frame) */
  40936. animate(): void;
  40937. /**
  40938. * Render the scene
  40939. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  40940. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  40941. */
  40942. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  40943. /**
  40944. * Freeze all materials
  40945. * A frozen material will not be updatable but should be faster to render
  40946. */
  40947. freezeMaterials(): void;
  40948. /**
  40949. * Unfreeze all materials
  40950. * A frozen material will not be updatable but should be faster to render
  40951. */
  40952. unfreezeMaterials(): void;
  40953. /**
  40954. * Releases all held ressources
  40955. */
  40956. dispose(): void;
  40957. /**
  40958. * Gets if the scene is already disposed
  40959. */
  40960. get isDisposed(): boolean;
  40961. /**
  40962. * Call this function to reduce memory footprint of the scene.
  40963. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  40964. */
  40965. clearCachedVertexData(): void;
  40966. /**
  40967. * This function will remove the local cached buffer data from texture.
  40968. * It will save memory but will prevent the texture from being rebuilt
  40969. */
  40970. cleanCachedTextureBuffer(): void;
  40971. /**
  40972. * Get the world extend vectors with an optional filter
  40973. *
  40974. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  40975. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  40976. */
  40977. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  40978. min: Vector3;
  40979. max: Vector3;
  40980. };
  40981. /**
  40982. * Creates a ray that can be used to pick in the scene
  40983. * @param x defines the x coordinate of the origin (on-screen)
  40984. * @param y defines the y coordinate of the origin (on-screen)
  40985. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40986. * @param camera defines the camera to use for the picking
  40987. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40988. * @returns a Ray
  40989. */
  40990. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  40991. /**
  40992. * Creates a ray that can be used to pick in the scene
  40993. * @param x defines the x coordinate of the origin (on-screen)
  40994. * @param y defines the y coordinate of the origin (on-screen)
  40995. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40996. * @param result defines the ray where to store the picking ray
  40997. * @param camera defines the camera to use for the picking
  40998. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40999. * @returns the current scene
  41000. */
  41001. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41002. /**
  41003. * Creates a ray that can be used to pick in the scene
  41004. * @param x defines the x coordinate of the origin (on-screen)
  41005. * @param y defines the y coordinate of the origin (on-screen)
  41006. * @param camera defines the camera to use for the picking
  41007. * @returns a Ray
  41008. */
  41009. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41010. /**
  41011. * Creates a ray that can be used to pick in the scene
  41012. * @param x defines the x coordinate of the origin (on-screen)
  41013. * @param y defines the y coordinate of the origin (on-screen)
  41014. * @param result defines the ray where to store the picking ray
  41015. * @param camera defines the camera to use for the picking
  41016. * @returns the current scene
  41017. */
  41018. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41019. /** Launch a ray to try to pick a mesh in the scene
  41020. * @param x position on screen
  41021. * @param y position on screen
  41022. * @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
  41023. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41024. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41025. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41026. * @returns a PickingInfo
  41027. */
  41028. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41029. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41030. * @param x position on screen
  41031. * @param y position on screen
  41032. * @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
  41033. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41034. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41035. * @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)
  41036. */
  41037. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41038. /** Use the given ray to pick a mesh in the scene
  41039. * @param ray The ray to use to pick meshes
  41040. * @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
  41041. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41042. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41043. * @returns a PickingInfo
  41044. */
  41045. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41046. /**
  41047. * Launch a ray to try to pick a mesh in the scene
  41048. * @param x X position on screen
  41049. * @param y Y position on screen
  41050. * @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
  41051. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41052. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41053. * @returns an array of PickingInfo
  41054. */
  41055. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41056. /**
  41057. * Launch a ray to try to pick a mesh in the scene
  41058. * @param ray Ray to use
  41059. * @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
  41060. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41061. * @returns an array of PickingInfo
  41062. */
  41063. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41064. /**
  41065. * Force the value of meshUnderPointer
  41066. * @param mesh defines the mesh to use
  41067. */
  41068. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  41069. /**
  41070. * Gets the mesh under the pointer
  41071. * @returns a Mesh or null if no mesh is under the pointer
  41072. */
  41073. getPointerOverMesh(): Nullable<AbstractMesh>;
  41074. /** @hidden */
  41075. _rebuildGeometries(): void;
  41076. /** @hidden */
  41077. _rebuildTextures(): void;
  41078. private _getByTags;
  41079. /**
  41080. * Get a list of meshes by tags
  41081. * @param tagsQuery defines the tags query to use
  41082. * @param forEach defines a predicate used to filter results
  41083. * @returns an array of Mesh
  41084. */
  41085. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41086. /**
  41087. * Get a list of cameras by tags
  41088. * @param tagsQuery defines the tags query to use
  41089. * @param forEach defines a predicate used to filter results
  41090. * @returns an array of Camera
  41091. */
  41092. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41093. /**
  41094. * Get a list of lights by tags
  41095. * @param tagsQuery defines the tags query to use
  41096. * @param forEach defines a predicate used to filter results
  41097. * @returns an array of Light
  41098. */
  41099. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41100. /**
  41101. * Get a list of materials by tags
  41102. * @param tagsQuery defines the tags query to use
  41103. * @param forEach defines a predicate used to filter results
  41104. * @returns an array of Material
  41105. */
  41106. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41107. /**
  41108. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41109. * This allowed control for front to back rendering or reversly depending of the special needs.
  41110. *
  41111. * @param renderingGroupId The rendering group id corresponding to its index
  41112. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41113. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41114. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41115. */
  41116. 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;
  41117. /**
  41118. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41119. *
  41120. * @param renderingGroupId The rendering group id corresponding to its index
  41121. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41122. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41123. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41124. */
  41125. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41126. /**
  41127. * Gets the current auto clear configuration for one rendering group of the rendering
  41128. * manager.
  41129. * @param index the rendering group index to get the information for
  41130. * @returns The auto clear setup for the requested rendering group
  41131. */
  41132. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41133. private _blockMaterialDirtyMechanism;
  41134. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41135. get blockMaterialDirtyMechanism(): boolean;
  41136. set blockMaterialDirtyMechanism(value: boolean);
  41137. /**
  41138. * Will flag all materials as dirty to trigger new shader compilation
  41139. * @param flag defines the flag used to specify which material part must be marked as dirty
  41140. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41141. */
  41142. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41143. /** @hidden */
  41144. _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;
  41145. /** @hidden */
  41146. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41147. /** @hidden */
  41148. _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;
  41149. /** @hidden */
  41150. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41151. /** @hidden */
  41152. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41153. /** @hidden */
  41154. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41155. }
  41156. }
  41157. declare module BABYLON {
  41158. /**
  41159. * Set of assets to keep when moving a scene into an asset container.
  41160. */
  41161. export class KeepAssets extends AbstractScene {
  41162. }
  41163. /**
  41164. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41165. */
  41166. export class InstantiatedEntries {
  41167. /**
  41168. * List of new root nodes (eg. nodes with no parent)
  41169. */
  41170. rootNodes: TransformNode[];
  41171. /**
  41172. * List of new skeletons
  41173. */
  41174. skeletons: Skeleton[];
  41175. /**
  41176. * List of new animation groups
  41177. */
  41178. animationGroups: AnimationGroup[];
  41179. }
  41180. /**
  41181. * Container with a set of assets that can be added or removed from a scene.
  41182. */
  41183. export class AssetContainer extends AbstractScene {
  41184. private _wasAddedToScene;
  41185. /**
  41186. * The scene the AssetContainer belongs to.
  41187. */
  41188. scene: Scene;
  41189. /**
  41190. * Instantiates an AssetContainer.
  41191. * @param scene The scene the AssetContainer belongs to.
  41192. */
  41193. constructor(scene: Scene);
  41194. /**
  41195. * Instantiate or clone all meshes and add the new ones to the scene.
  41196. * Skeletons and animation groups will all be cloned
  41197. * @param nameFunction defines an optional function used to get new names for clones
  41198. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41199. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41200. */
  41201. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41202. /**
  41203. * Adds all the assets from the container to the scene.
  41204. */
  41205. addAllToScene(): void;
  41206. /**
  41207. * Removes all the assets in the container from the scene
  41208. */
  41209. removeAllFromScene(): void;
  41210. /**
  41211. * Disposes all the assets in the container
  41212. */
  41213. dispose(): void;
  41214. private _moveAssets;
  41215. /**
  41216. * Removes all the assets contained in the scene and adds them to the container.
  41217. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41218. */
  41219. moveAllFromScene(keepAssets?: KeepAssets): void;
  41220. /**
  41221. * 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.
  41222. * @returns the root mesh
  41223. */
  41224. createRootMesh(): Mesh;
  41225. /**
  41226. * Merge animations (direct and animation groups) from this asset container into a scene
  41227. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41228. * @param animatables set of animatables to retarget to a node from the scene
  41229. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41230. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41231. */
  41232. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41233. }
  41234. }
  41235. declare module BABYLON {
  41236. /**
  41237. * Defines how the parser contract is defined.
  41238. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41239. */
  41240. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41241. /**
  41242. * Defines how the individual parser contract is defined.
  41243. * These parser can parse an individual asset
  41244. */
  41245. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41246. /**
  41247. * Base class of the scene acting as a container for the different elements composing a scene.
  41248. * This class is dynamically extended by the different components of the scene increasing
  41249. * flexibility and reducing coupling
  41250. */
  41251. export abstract class AbstractScene {
  41252. /**
  41253. * Stores the list of available parsers in the application.
  41254. */
  41255. private static _BabylonFileParsers;
  41256. /**
  41257. * Stores the list of available individual parsers in the application.
  41258. */
  41259. private static _IndividualBabylonFileParsers;
  41260. /**
  41261. * Adds a parser in the list of available ones
  41262. * @param name Defines the name of the parser
  41263. * @param parser Defines the parser to add
  41264. */
  41265. static AddParser(name: string, parser: BabylonFileParser): void;
  41266. /**
  41267. * Gets a general parser from the list of avaialble ones
  41268. * @param name Defines the name of the parser
  41269. * @returns the requested parser or null
  41270. */
  41271. static GetParser(name: string): Nullable<BabylonFileParser>;
  41272. /**
  41273. * Adds n individual parser in the list of available ones
  41274. * @param name Defines the name of the parser
  41275. * @param parser Defines the parser to add
  41276. */
  41277. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41278. /**
  41279. * Gets an individual parser from the list of avaialble ones
  41280. * @param name Defines the name of the parser
  41281. * @returns the requested parser or null
  41282. */
  41283. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41284. /**
  41285. * Parser json data and populate both a scene and its associated container object
  41286. * @param jsonData Defines the data to parse
  41287. * @param scene Defines the scene to parse the data for
  41288. * @param container Defines the container attached to the parsing sequence
  41289. * @param rootUrl Defines the root url of the data
  41290. */
  41291. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41292. /**
  41293. * Gets the list of root nodes (ie. nodes with no parent)
  41294. */
  41295. rootNodes: Node[];
  41296. /** All of the cameras added to this scene
  41297. * @see https://doc.babylonjs.com/babylon101/cameras
  41298. */
  41299. cameras: Camera[];
  41300. /**
  41301. * All of the lights added to this scene
  41302. * @see https://doc.babylonjs.com/babylon101/lights
  41303. */
  41304. lights: Light[];
  41305. /**
  41306. * All of the (abstract) meshes added to this scene
  41307. */
  41308. meshes: AbstractMesh[];
  41309. /**
  41310. * The list of skeletons added to the scene
  41311. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41312. */
  41313. skeletons: Skeleton[];
  41314. /**
  41315. * All of the particle systems added to this scene
  41316. * @see https://doc.babylonjs.com/babylon101/particles
  41317. */
  41318. particleSystems: IParticleSystem[];
  41319. /**
  41320. * Gets a list of Animations associated with the scene
  41321. */
  41322. animations: Animation[];
  41323. /**
  41324. * All of the animation groups added to this scene
  41325. * @see https://doc.babylonjs.com/how_to/group
  41326. */
  41327. animationGroups: AnimationGroup[];
  41328. /**
  41329. * All of the multi-materials added to this scene
  41330. * @see https://doc.babylonjs.com/how_to/multi_materials
  41331. */
  41332. multiMaterials: MultiMaterial[];
  41333. /**
  41334. * All of the materials added to this scene
  41335. * In the context of a Scene, it is not supposed to be modified manually.
  41336. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41337. * Note also that the order of the Material within the array is not significant and might change.
  41338. * @see https://doc.babylonjs.com/babylon101/materials
  41339. */
  41340. materials: Material[];
  41341. /**
  41342. * The list of morph target managers added to the scene
  41343. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41344. */
  41345. morphTargetManagers: MorphTargetManager[];
  41346. /**
  41347. * The list of geometries used in the scene.
  41348. */
  41349. geometries: Geometry[];
  41350. /**
  41351. * All of the tranform nodes added to this scene
  41352. * In the context of a Scene, it is not supposed to be modified manually.
  41353. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41354. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41355. * @see https://doc.babylonjs.com/how_to/transformnode
  41356. */
  41357. transformNodes: TransformNode[];
  41358. /**
  41359. * ActionManagers available on the scene.
  41360. */
  41361. actionManagers: AbstractActionManager[];
  41362. /**
  41363. * Textures to keep.
  41364. */
  41365. textures: BaseTexture[];
  41366. /**
  41367. * Environment texture for the scene
  41368. */
  41369. environmentTexture: Nullable<BaseTexture>;
  41370. /**
  41371. * The list of postprocesses added to the scene
  41372. */
  41373. postProcesses: PostProcess[];
  41374. /**
  41375. * @returns all meshes, lights, cameras, transformNodes and bones
  41376. */
  41377. getNodes(): Array<Node>;
  41378. }
  41379. }
  41380. declare module BABYLON {
  41381. /**
  41382. * Interface used to define options for Sound class
  41383. */
  41384. export interface ISoundOptions {
  41385. /**
  41386. * Does the sound autoplay once loaded.
  41387. */
  41388. autoplay?: boolean;
  41389. /**
  41390. * Does the sound loop after it finishes playing once.
  41391. */
  41392. loop?: boolean;
  41393. /**
  41394. * Sound's volume
  41395. */
  41396. volume?: number;
  41397. /**
  41398. * Is it a spatial sound?
  41399. */
  41400. spatialSound?: boolean;
  41401. /**
  41402. * Maximum distance to hear that sound
  41403. */
  41404. maxDistance?: number;
  41405. /**
  41406. * Uses user defined attenuation function
  41407. */
  41408. useCustomAttenuation?: boolean;
  41409. /**
  41410. * Define the roll off factor of spatial sounds.
  41411. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41412. */
  41413. rolloffFactor?: number;
  41414. /**
  41415. * Define the reference distance the sound should be heard perfectly.
  41416. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41417. */
  41418. refDistance?: number;
  41419. /**
  41420. * Define the distance attenuation model the sound will follow.
  41421. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41422. */
  41423. distanceModel?: string;
  41424. /**
  41425. * Defines the playback speed (1 by default)
  41426. */
  41427. playbackRate?: number;
  41428. /**
  41429. * Defines if the sound is from a streaming source
  41430. */
  41431. streaming?: boolean;
  41432. /**
  41433. * Defines an optional length (in seconds) inside the sound file
  41434. */
  41435. length?: number;
  41436. /**
  41437. * Defines an optional offset (in seconds) inside the sound file
  41438. */
  41439. offset?: number;
  41440. /**
  41441. * If true, URLs will not be required to state the audio file codec to use.
  41442. */
  41443. skipCodecCheck?: boolean;
  41444. }
  41445. /**
  41446. * Defines a sound that can be played in the application.
  41447. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41448. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41449. */
  41450. export class Sound {
  41451. /**
  41452. * The name of the sound in the scene.
  41453. */
  41454. name: string;
  41455. /**
  41456. * Does the sound autoplay once loaded.
  41457. */
  41458. autoplay: boolean;
  41459. /**
  41460. * Does the sound loop after it finishes playing once.
  41461. */
  41462. loop: boolean;
  41463. /**
  41464. * Does the sound use a custom attenuation curve to simulate the falloff
  41465. * happening when the source gets further away from the camera.
  41466. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41467. */
  41468. useCustomAttenuation: boolean;
  41469. /**
  41470. * The sound track id this sound belongs to.
  41471. */
  41472. soundTrackId: number;
  41473. /**
  41474. * Is this sound currently played.
  41475. */
  41476. isPlaying: boolean;
  41477. /**
  41478. * Is this sound currently paused.
  41479. */
  41480. isPaused: boolean;
  41481. /**
  41482. * Does this sound enables spatial sound.
  41483. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41484. */
  41485. spatialSound: boolean;
  41486. /**
  41487. * Define the reference distance the sound should be heard perfectly.
  41488. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41489. */
  41490. refDistance: number;
  41491. /**
  41492. * Define the roll off factor of spatial sounds.
  41493. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41494. */
  41495. rolloffFactor: number;
  41496. /**
  41497. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41498. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41499. */
  41500. maxDistance: number;
  41501. /**
  41502. * Define the distance attenuation model the sound will follow.
  41503. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41504. */
  41505. distanceModel: string;
  41506. /**
  41507. * @hidden
  41508. * Back Compat
  41509. **/
  41510. onended: () => any;
  41511. /**
  41512. * Gets or sets an object used to store user defined information for the sound.
  41513. */
  41514. metadata: any;
  41515. /**
  41516. * Observable event when the current playing sound finishes.
  41517. */
  41518. onEndedObservable: Observable<Sound>;
  41519. private _panningModel;
  41520. private _playbackRate;
  41521. private _streaming;
  41522. private _startTime;
  41523. private _startOffset;
  41524. private _position;
  41525. /** @hidden */
  41526. _positionInEmitterSpace: boolean;
  41527. private _localDirection;
  41528. private _volume;
  41529. private _isReadyToPlay;
  41530. private _isDirectional;
  41531. private _readyToPlayCallback;
  41532. private _audioBuffer;
  41533. private _soundSource;
  41534. private _streamingSource;
  41535. private _soundPanner;
  41536. private _soundGain;
  41537. private _inputAudioNode;
  41538. private _outputAudioNode;
  41539. private _coneInnerAngle;
  41540. private _coneOuterAngle;
  41541. private _coneOuterGain;
  41542. private _scene;
  41543. private _connectedTransformNode;
  41544. private _customAttenuationFunction;
  41545. private _registerFunc;
  41546. private _isOutputConnected;
  41547. private _htmlAudioElement;
  41548. private _urlType;
  41549. private _length?;
  41550. private _offset?;
  41551. /** @hidden */
  41552. static _SceneComponentInitialization: (scene: Scene) => void;
  41553. /**
  41554. * Create a sound and attach it to a scene
  41555. * @param name Name of your sound
  41556. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41557. * @param scene defines the scene the sound belongs to
  41558. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41559. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41560. */
  41561. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41562. /**
  41563. * Release the sound and its associated resources
  41564. */
  41565. dispose(): void;
  41566. /**
  41567. * Gets if the sounds is ready to be played or not.
  41568. * @returns true if ready, otherwise false
  41569. */
  41570. isReady(): boolean;
  41571. private _soundLoaded;
  41572. /**
  41573. * Sets the data of the sound from an audiobuffer
  41574. * @param audioBuffer The audioBuffer containing the data
  41575. */
  41576. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41577. /**
  41578. * Updates the current sounds options such as maxdistance, loop...
  41579. * @param options A JSON object containing values named as the object properties
  41580. */
  41581. updateOptions(options: ISoundOptions): void;
  41582. private _createSpatialParameters;
  41583. private _updateSpatialParameters;
  41584. /**
  41585. * Switch the panning model to HRTF:
  41586. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41587. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41588. */
  41589. switchPanningModelToHRTF(): void;
  41590. /**
  41591. * Switch the panning model to Equal Power:
  41592. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41593. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41594. */
  41595. switchPanningModelToEqualPower(): void;
  41596. private _switchPanningModel;
  41597. /**
  41598. * Connect this sound to a sound track audio node like gain...
  41599. * @param soundTrackAudioNode the sound track audio node to connect to
  41600. */
  41601. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41602. /**
  41603. * Transform this sound into a directional source
  41604. * @param coneInnerAngle Size of the inner cone in degree
  41605. * @param coneOuterAngle Size of the outer cone in degree
  41606. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41607. */
  41608. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41609. /**
  41610. * Gets or sets the inner angle for the directional cone.
  41611. */
  41612. get directionalConeInnerAngle(): number;
  41613. /**
  41614. * Gets or sets the inner angle for the directional cone.
  41615. */
  41616. set directionalConeInnerAngle(value: number);
  41617. /**
  41618. * Gets or sets the outer angle for the directional cone.
  41619. */
  41620. get directionalConeOuterAngle(): number;
  41621. /**
  41622. * Gets or sets the outer angle for the directional cone.
  41623. */
  41624. set directionalConeOuterAngle(value: number);
  41625. /**
  41626. * Sets the position of the emitter if spatial sound is enabled
  41627. * @param newPosition Defines the new posisiton
  41628. */
  41629. setPosition(newPosition: Vector3): void;
  41630. /**
  41631. * Sets the local direction of the emitter if spatial sound is enabled
  41632. * @param newLocalDirection Defines the new local direction
  41633. */
  41634. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  41635. private _updateDirection;
  41636. /** @hidden */
  41637. updateDistanceFromListener(): void;
  41638. /**
  41639. * Sets a new custom attenuation function for the sound.
  41640. * @param callback Defines the function used for the attenuation
  41641. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41642. */
  41643. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  41644. /**
  41645. * Play the sound
  41646. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  41647. * @param offset (optional) Start the sound at a specific time in seconds
  41648. * @param length (optional) Sound duration (in seconds)
  41649. */
  41650. play(time?: number, offset?: number, length?: number): void;
  41651. private _onended;
  41652. /**
  41653. * Stop the sound
  41654. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  41655. */
  41656. stop(time?: number): void;
  41657. /**
  41658. * Put the sound in pause
  41659. */
  41660. pause(): void;
  41661. /**
  41662. * Sets a dedicated volume for this sounds
  41663. * @param newVolume Define the new volume of the sound
  41664. * @param time Define time for gradual change to new volume
  41665. */
  41666. setVolume(newVolume: number, time?: number): void;
  41667. /**
  41668. * Set the sound play back rate
  41669. * @param newPlaybackRate Define the playback rate the sound should be played at
  41670. */
  41671. setPlaybackRate(newPlaybackRate: number): void;
  41672. /**
  41673. * Gets the volume of the sound.
  41674. * @returns the volume of the sound
  41675. */
  41676. getVolume(): number;
  41677. /**
  41678. * Attach the sound to a dedicated mesh
  41679. * @param transformNode The transform node to connect the sound with
  41680. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41681. */
  41682. attachToMesh(transformNode: TransformNode): void;
  41683. /**
  41684. * Detach the sound from the previously attached mesh
  41685. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41686. */
  41687. detachFromMesh(): void;
  41688. private _onRegisterAfterWorldMatrixUpdate;
  41689. /**
  41690. * Clone the current sound in the scene.
  41691. * @returns the new sound clone
  41692. */
  41693. clone(): Nullable<Sound>;
  41694. /**
  41695. * Gets the current underlying audio buffer containing the data
  41696. * @returns the audio buffer
  41697. */
  41698. getAudioBuffer(): Nullable<AudioBuffer>;
  41699. /**
  41700. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  41701. * @returns the source node
  41702. */
  41703. getSoundSource(): Nullable<AudioBufferSourceNode>;
  41704. /**
  41705. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  41706. * @returns the gain node
  41707. */
  41708. getSoundGain(): Nullable<GainNode>;
  41709. /**
  41710. * Serializes the Sound in a JSON representation
  41711. * @returns the JSON representation of the sound
  41712. */
  41713. serialize(): any;
  41714. /**
  41715. * Parse a JSON representation of a sound to innstantiate in a given scene
  41716. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  41717. * @param scene Define the scene the new parsed sound should be created in
  41718. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  41719. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  41720. * @returns the newly parsed sound
  41721. */
  41722. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  41723. }
  41724. }
  41725. declare module BABYLON {
  41726. /**
  41727. * This defines an action helpful to play a defined sound on a triggered action.
  41728. */
  41729. export class PlaySoundAction extends Action {
  41730. private _sound;
  41731. /**
  41732. * Instantiate the action
  41733. * @param triggerOptions defines the trigger options
  41734. * @param sound defines the sound to play
  41735. * @param condition defines the trigger related conditions
  41736. */
  41737. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41738. /** @hidden */
  41739. _prepare(): void;
  41740. /**
  41741. * Execute the action and play the sound.
  41742. */
  41743. execute(): void;
  41744. /**
  41745. * Serializes the actions and its related information.
  41746. * @param parent defines the object to serialize in
  41747. * @returns the serialized object
  41748. */
  41749. serialize(parent: any): any;
  41750. }
  41751. /**
  41752. * This defines an action helpful to stop a defined sound on a triggered action.
  41753. */
  41754. export class StopSoundAction extends Action {
  41755. private _sound;
  41756. /**
  41757. * Instantiate the action
  41758. * @param triggerOptions defines the trigger options
  41759. * @param sound defines the sound to stop
  41760. * @param condition defines the trigger related conditions
  41761. */
  41762. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41763. /** @hidden */
  41764. _prepare(): void;
  41765. /**
  41766. * Execute the action and stop the sound.
  41767. */
  41768. execute(): void;
  41769. /**
  41770. * Serializes the actions and its related information.
  41771. * @param parent defines the object to serialize in
  41772. * @returns the serialized object
  41773. */
  41774. serialize(parent: any): any;
  41775. }
  41776. }
  41777. declare module BABYLON {
  41778. /**
  41779. * This defines an action responsible to change the value of a property
  41780. * by interpolating between its current value and the newly set one once triggered.
  41781. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41782. */
  41783. export class InterpolateValueAction extends Action {
  41784. /**
  41785. * Defines the path of the property where the value should be interpolated
  41786. */
  41787. propertyPath: string;
  41788. /**
  41789. * Defines the target value at the end of the interpolation.
  41790. */
  41791. value: any;
  41792. /**
  41793. * Defines the time it will take for the property to interpolate to the value.
  41794. */
  41795. duration: number;
  41796. /**
  41797. * Defines if the other scene animations should be stopped when the action has been triggered
  41798. */
  41799. stopOtherAnimations?: boolean;
  41800. /**
  41801. * Defines a callback raised once the interpolation animation has been done.
  41802. */
  41803. onInterpolationDone?: () => void;
  41804. /**
  41805. * Observable triggered once the interpolation animation has been done.
  41806. */
  41807. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  41808. private _target;
  41809. private _effectiveTarget;
  41810. private _property;
  41811. /**
  41812. * Instantiate the action
  41813. * @param triggerOptions defines the trigger options
  41814. * @param target defines the object containing the value to interpolate
  41815. * @param propertyPath defines the path to the property in the target object
  41816. * @param value defines the target value at the end of the interpolation
  41817. * @param duration deines the time it will take for the property to interpolate to the value.
  41818. * @param condition defines the trigger related conditions
  41819. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  41820. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  41821. */
  41822. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  41823. /** @hidden */
  41824. _prepare(): void;
  41825. /**
  41826. * Execute the action starts the value interpolation.
  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. * Options allowed during the creation of a sound track.
  41840. */
  41841. export interface ISoundTrackOptions {
  41842. /**
  41843. * The volume the sound track should take during creation
  41844. */
  41845. volume?: number;
  41846. /**
  41847. * Define if the sound track is the main sound track of the scene
  41848. */
  41849. mainTrack?: boolean;
  41850. }
  41851. /**
  41852. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  41853. * It will be also used in a future release to apply effects on a specific track.
  41854. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41855. */
  41856. export class SoundTrack {
  41857. /**
  41858. * The unique identifier of the sound track in the scene.
  41859. */
  41860. id: number;
  41861. /**
  41862. * The list of sounds included in the sound track.
  41863. */
  41864. soundCollection: Array<Sound>;
  41865. private _outputAudioNode;
  41866. private _scene;
  41867. private _connectedAnalyser;
  41868. private _options;
  41869. private _isInitialized;
  41870. /**
  41871. * Creates a new sound track.
  41872. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41873. * @param scene Define the scene the sound track belongs to
  41874. * @param options
  41875. */
  41876. constructor(scene: Scene, options?: ISoundTrackOptions);
  41877. private _initializeSoundTrackAudioGraph;
  41878. /**
  41879. * Release the sound track and its associated resources
  41880. */
  41881. dispose(): void;
  41882. /**
  41883. * Adds a sound to this sound track
  41884. * @param sound define the cound to add
  41885. * @ignoreNaming
  41886. */
  41887. AddSound(sound: Sound): void;
  41888. /**
  41889. * Removes a sound to this sound track
  41890. * @param sound define the cound to remove
  41891. * @ignoreNaming
  41892. */
  41893. RemoveSound(sound: Sound): void;
  41894. /**
  41895. * Set a global volume for the full sound track.
  41896. * @param newVolume Define the new volume of the sound track
  41897. */
  41898. setVolume(newVolume: number): void;
  41899. /**
  41900. * Switch the panning model to HRTF:
  41901. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41902. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41903. */
  41904. switchPanningModelToHRTF(): void;
  41905. /**
  41906. * Switch the panning model to Equal Power:
  41907. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41908. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41909. */
  41910. switchPanningModelToEqualPower(): void;
  41911. /**
  41912. * Connect the sound track to an audio analyser allowing some amazing
  41913. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41914. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41915. * @param analyser The analyser to connect to the engine
  41916. */
  41917. connectToAnalyser(analyser: Analyser): void;
  41918. }
  41919. }
  41920. declare module BABYLON {
  41921. interface AbstractScene {
  41922. /**
  41923. * The list of sounds used in the scene.
  41924. */
  41925. sounds: Nullable<Array<Sound>>;
  41926. }
  41927. interface Scene {
  41928. /**
  41929. * @hidden
  41930. * Backing field
  41931. */
  41932. _mainSoundTrack: SoundTrack;
  41933. /**
  41934. * The main sound track played by the scene.
  41935. * It cotains your primary collection of sounds.
  41936. */
  41937. mainSoundTrack: SoundTrack;
  41938. /**
  41939. * The list of sound tracks added to the scene
  41940. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41941. */
  41942. soundTracks: Nullable<Array<SoundTrack>>;
  41943. /**
  41944. * Gets a sound using a given name
  41945. * @param name defines the name to search for
  41946. * @return the found sound or null if not found at all.
  41947. */
  41948. getSoundByName(name: string): Nullable<Sound>;
  41949. /**
  41950. * Gets or sets if audio support is enabled
  41951. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41952. */
  41953. audioEnabled: boolean;
  41954. /**
  41955. * Gets or sets if audio will be output to headphones
  41956. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41957. */
  41958. headphone: boolean;
  41959. /**
  41960. * Gets or sets custom audio listener position provider
  41961. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41962. */
  41963. audioListenerPositionProvider: Nullable<() => Vector3>;
  41964. /**
  41965. * Gets or sets a refresh rate when using 3D audio positioning
  41966. */
  41967. audioPositioningRefreshRate: number;
  41968. }
  41969. /**
  41970. * Defines the sound scene component responsible to manage any sounds
  41971. * in a given scene.
  41972. */
  41973. export class AudioSceneComponent implements ISceneSerializableComponent {
  41974. /**
  41975. * The component name helpfull to identify the component in the list of scene components.
  41976. */
  41977. readonly name: string;
  41978. /**
  41979. * The scene the component belongs to.
  41980. */
  41981. scene: Scene;
  41982. private _audioEnabled;
  41983. /**
  41984. * Gets whether audio is enabled or not.
  41985. * Please use related enable/disable method to switch state.
  41986. */
  41987. get audioEnabled(): boolean;
  41988. private _headphone;
  41989. /**
  41990. * Gets whether audio is outputing to headphone or not.
  41991. * Please use the according Switch methods to change output.
  41992. */
  41993. get headphone(): boolean;
  41994. /**
  41995. * Gets or sets a refresh rate when using 3D audio positioning
  41996. */
  41997. audioPositioningRefreshRate: number;
  41998. private _audioListenerPositionProvider;
  41999. /**
  42000. * Gets the current audio listener position provider
  42001. */
  42002. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42003. /**
  42004. * Sets a custom listener position for all sounds in the scene
  42005. * By default, this is the position of the first active camera
  42006. */
  42007. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42008. /**
  42009. * Creates a new instance of the component for the given scene
  42010. * @param scene Defines the scene to register the component in
  42011. */
  42012. constructor(scene: Scene);
  42013. /**
  42014. * Registers the component in a given scene
  42015. */
  42016. register(): void;
  42017. /**
  42018. * Rebuilds the elements related to this component in case of
  42019. * context lost for instance.
  42020. */
  42021. rebuild(): void;
  42022. /**
  42023. * Serializes the component data to the specified json object
  42024. * @param serializationObject The object to serialize to
  42025. */
  42026. serialize(serializationObject: any): void;
  42027. /**
  42028. * Adds all the elements from the container to the scene
  42029. * @param container the container holding the elements
  42030. */
  42031. addFromContainer(container: AbstractScene): void;
  42032. /**
  42033. * Removes all the elements in the container from the scene
  42034. * @param container contains the elements to remove
  42035. * @param dispose if the removed element should be disposed (default: false)
  42036. */
  42037. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42038. /**
  42039. * Disposes the component and the associated ressources.
  42040. */
  42041. dispose(): void;
  42042. /**
  42043. * Disables audio in the associated scene.
  42044. */
  42045. disableAudio(): void;
  42046. /**
  42047. * Enables audio in the associated scene.
  42048. */
  42049. enableAudio(): void;
  42050. /**
  42051. * Switch audio to headphone output.
  42052. */
  42053. switchAudioModeForHeadphones(): void;
  42054. /**
  42055. * Switch audio to normal speakers.
  42056. */
  42057. switchAudioModeForNormalSpeakers(): void;
  42058. private _cachedCameraDirection;
  42059. private _cachedCameraPosition;
  42060. private _lastCheck;
  42061. private _afterRender;
  42062. }
  42063. }
  42064. declare module BABYLON {
  42065. /**
  42066. * Wraps one or more Sound objects and selects one with random weight for playback.
  42067. */
  42068. export class WeightedSound {
  42069. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42070. loop: boolean;
  42071. private _coneInnerAngle;
  42072. private _coneOuterAngle;
  42073. private _volume;
  42074. /** A Sound is currently playing. */
  42075. isPlaying: boolean;
  42076. /** A Sound is currently paused. */
  42077. isPaused: boolean;
  42078. private _sounds;
  42079. private _weights;
  42080. private _currentIndex?;
  42081. /**
  42082. * Creates a new WeightedSound from the list of sounds given.
  42083. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42084. * @param sounds Array of Sounds that will be selected from.
  42085. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42086. */
  42087. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42088. /**
  42089. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42090. */
  42091. get directionalConeInnerAngle(): number;
  42092. /**
  42093. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42094. */
  42095. set directionalConeInnerAngle(value: number);
  42096. /**
  42097. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42098. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42099. */
  42100. get directionalConeOuterAngle(): number;
  42101. /**
  42102. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42103. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42104. */
  42105. set directionalConeOuterAngle(value: number);
  42106. /**
  42107. * Playback volume.
  42108. */
  42109. get volume(): number;
  42110. /**
  42111. * Playback volume.
  42112. */
  42113. set volume(value: number);
  42114. private _onended;
  42115. /**
  42116. * Suspend playback
  42117. */
  42118. pause(): void;
  42119. /**
  42120. * Stop playback
  42121. */
  42122. stop(): void;
  42123. /**
  42124. * Start playback.
  42125. * @param startOffset Position the clip head at a specific time in seconds.
  42126. */
  42127. play(startOffset?: number): void;
  42128. }
  42129. }
  42130. declare module BABYLON {
  42131. /**
  42132. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42133. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42134. */
  42135. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42136. /**
  42137. * Gets the name of the behavior.
  42138. */
  42139. get name(): string;
  42140. /**
  42141. * The easing function used by animations
  42142. */
  42143. static EasingFunction: BackEase;
  42144. /**
  42145. * The easing mode used by animations
  42146. */
  42147. static EasingMode: number;
  42148. /**
  42149. * The duration of the animation, in milliseconds
  42150. */
  42151. transitionDuration: number;
  42152. /**
  42153. * Length of the distance animated by the transition when lower radius is reached
  42154. */
  42155. lowerRadiusTransitionRange: number;
  42156. /**
  42157. * Length of the distance animated by the transition when upper radius is reached
  42158. */
  42159. upperRadiusTransitionRange: number;
  42160. private _autoTransitionRange;
  42161. /**
  42162. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42163. */
  42164. get autoTransitionRange(): boolean;
  42165. /**
  42166. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42167. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42168. */
  42169. set autoTransitionRange(value: boolean);
  42170. private _attachedCamera;
  42171. private _onAfterCheckInputsObserver;
  42172. private _onMeshTargetChangedObserver;
  42173. /**
  42174. * Initializes the behavior.
  42175. */
  42176. init(): void;
  42177. /**
  42178. * Attaches the behavior to its arc rotate camera.
  42179. * @param camera Defines the camera to attach the behavior to
  42180. */
  42181. attach(camera: ArcRotateCamera): void;
  42182. /**
  42183. * Detaches the behavior from its current arc rotate camera.
  42184. */
  42185. detach(): void;
  42186. private _radiusIsAnimating;
  42187. private _radiusBounceTransition;
  42188. private _animatables;
  42189. private _cachedWheelPrecision;
  42190. /**
  42191. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42192. * @param radiusLimit The limit to check against.
  42193. * @return Bool to indicate if at limit.
  42194. */
  42195. private _isRadiusAtLimit;
  42196. /**
  42197. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42198. * @param radiusDelta The delta by which to animate to. Can be negative.
  42199. */
  42200. private _applyBoundRadiusAnimation;
  42201. /**
  42202. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42203. */
  42204. protected _clearAnimationLocks(): void;
  42205. /**
  42206. * Stops and removes all animations that have been applied to the camera
  42207. */
  42208. stopAllAnimations(): void;
  42209. }
  42210. }
  42211. declare module BABYLON {
  42212. /**
  42213. * 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.
  42214. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42215. */
  42216. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42217. /**
  42218. * Gets the name of the behavior.
  42219. */
  42220. get name(): string;
  42221. private _mode;
  42222. private _radiusScale;
  42223. private _positionScale;
  42224. private _defaultElevation;
  42225. private _elevationReturnTime;
  42226. private _elevationReturnWaitTime;
  42227. private _zoomStopsAnimation;
  42228. private _framingTime;
  42229. /**
  42230. * The easing function used by animations
  42231. */
  42232. static EasingFunction: ExponentialEase;
  42233. /**
  42234. * The easing mode used by animations
  42235. */
  42236. static EasingMode: number;
  42237. /**
  42238. * Sets the current mode used by the behavior
  42239. */
  42240. set mode(mode: number);
  42241. /**
  42242. * Gets current mode used by the behavior.
  42243. */
  42244. get mode(): number;
  42245. /**
  42246. * Sets the scale applied to the radius (1 by default)
  42247. */
  42248. set radiusScale(radius: number);
  42249. /**
  42250. * Gets the scale applied to the radius
  42251. */
  42252. get radiusScale(): number;
  42253. /**
  42254. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42255. */
  42256. set positionScale(scale: number);
  42257. /**
  42258. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42259. */
  42260. get positionScale(): number;
  42261. /**
  42262. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42263. * behaviour is triggered, in radians.
  42264. */
  42265. set defaultElevation(elevation: number);
  42266. /**
  42267. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42268. * behaviour is triggered, in radians.
  42269. */
  42270. get defaultElevation(): number;
  42271. /**
  42272. * Sets the time (in milliseconds) taken to return to the default beta position.
  42273. * Negative value indicates camera should not return to default.
  42274. */
  42275. set elevationReturnTime(speed: number);
  42276. /**
  42277. * Gets the time (in milliseconds) taken to return to the default beta position.
  42278. * Negative value indicates camera should not return to default.
  42279. */
  42280. get elevationReturnTime(): number;
  42281. /**
  42282. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42283. */
  42284. set elevationReturnWaitTime(time: number);
  42285. /**
  42286. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42287. */
  42288. get elevationReturnWaitTime(): number;
  42289. /**
  42290. * Sets the flag that indicates if user zooming should stop animation.
  42291. */
  42292. set zoomStopsAnimation(flag: boolean);
  42293. /**
  42294. * Gets the flag that indicates if user zooming should stop animation.
  42295. */
  42296. get zoomStopsAnimation(): boolean;
  42297. /**
  42298. * Sets the transition time when framing the mesh, in milliseconds
  42299. */
  42300. set framingTime(time: number);
  42301. /**
  42302. * Gets the transition time when framing the mesh, in milliseconds
  42303. */
  42304. get framingTime(): number;
  42305. /**
  42306. * Define if the behavior should automatically change the configured
  42307. * camera limits and sensibilities.
  42308. */
  42309. autoCorrectCameraLimitsAndSensibility: boolean;
  42310. private _onPrePointerObservableObserver;
  42311. private _onAfterCheckInputsObserver;
  42312. private _onMeshTargetChangedObserver;
  42313. private _attachedCamera;
  42314. private _isPointerDown;
  42315. private _lastInteractionTime;
  42316. /**
  42317. * Initializes the behavior.
  42318. */
  42319. init(): void;
  42320. /**
  42321. * Attaches the behavior to its arc rotate camera.
  42322. * @param camera Defines the camera to attach the behavior to
  42323. */
  42324. attach(camera: ArcRotateCamera): void;
  42325. /**
  42326. * Detaches the behavior from its current arc rotate camera.
  42327. */
  42328. detach(): void;
  42329. private _animatables;
  42330. private _betaIsAnimating;
  42331. private _betaTransition;
  42332. private _radiusTransition;
  42333. private _vectorTransition;
  42334. /**
  42335. * Targets the given mesh and updates zoom level accordingly.
  42336. * @param mesh The mesh to target.
  42337. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42338. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42339. */
  42340. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42341. /**
  42342. * Targets the given mesh with its children and updates zoom level accordingly.
  42343. * @param mesh The mesh to target.
  42344. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42345. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42346. */
  42347. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42348. /**
  42349. * Targets the given meshes with their children and updates zoom level accordingly.
  42350. * @param meshes The mesh to target.
  42351. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42352. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42353. */
  42354. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42355. /**
  42356. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42357. * @param minimumWorld Determines the smaller position of the bounding box extend
  42358. * @param maximumWorld Determines the bigger position of the bounding box extend
  42359. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42360. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42361. */
  42362. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42363. /**
  42364. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42365. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42366. * frustum width.
  42367. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42368. * to fully enclose the mesh in the viewing frustum.
  42369. */
  42370. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42371. /**
  42372. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42373. * is automatically returned to its default position (expected to be above ground plane).
  42374. */
  42375. private _maintainCameraAboveGround;
  42376. /**
  42377. * Returns the frustum slope based on the canvas ratio and camera FOV
  42378. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42379. */
  42380. private _getFrustumSlope;
  42381. /**
  42382. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42383. */
  42384. private _clearAnimationLocks;
  42385. /**
  42386. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42387. */
  42388. private _applyUserInteraction;
  42389. /**
  42390. * Stops and removes all animations that have been applied to the camera
  42391. */
  42392. stopAllAnimations(): void;
  42393. /**
  42394. * Gets a value indicating if the user is moving the camera
  42395. */
  42396. get isUserIsMoving(): boolean;
  42397. /**
  42398. * The camera can move all the way towards the mesh.
  42399. */
  42400. static IgnoreBoundsSizeMode: number;
  42401. /**
  42402. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42403. */
  42404. static FitFrustumSidesMode: number;
  42405. }
  42406. }
  42407. declare module BABYLON {
  42408. /**
  42409. * Base class for Camera Pointer Inputs.
  42410. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42411. * for example usage.
  42412. */
  42413. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42414. /**
  42415. * Defines the camera the input is attached to.
  42416. */
  42417. abstract camera: Camera;
  42418. /**
  42419. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42420. */
  42421. protected _altKey: boolean;
  42422. protected _ctrlKey: boolean;
  42423. protected _metaKey: boolean;
  42424. protected _shiftKey: boolean;
  42425. /**
  42426. * Which mouse buttons were pressed at time of last mouse event.
  42427. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42428. */
  42429. protected _buttonsPressed: number;
  42430. /**
  42431. * Defines the buttons associated with the input to handle camera move.
  42432. */
  42433. buttons: number[];
  42434. /**
  42435. * Attach the input controls to a specific dom element to get the input from.
  42436. * @param element Defines the element the controls should be listened from
  42437. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42438. */
  42439. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42440. /**
  42441. * Detach the current controls from the specified dom element.
  42442. * @param element Defines the element to stop listening the inputs from
  42443. */
  42444. detachControl(element: Nullable<HTMLElement>): void;
  42445. /**
  42446. * Gets the class name of the current input.
  42447. * @returns the class name
  42448. */
  42449. getClassName(): string;
  42450. /**
  42451. * Get the friendly name associated with the input class.
  42452. * @returns the input friendly name
  42453. */
  42454. getSimpleName(): string;
  42455. /**
  42456. * Called on pointer POINTERDOUBLETAP event.
  42457. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42458. */
  42459. protected onDoubleTap(type: string): void;
  42460. /**
  42461. * Called on pointer POINTERMOVE event if only a single touch is active.
  42462. * Override this method to provide functionality.
  42463. */
  42464. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42465. /**
  42466. * Called on pointer POINTERMOVE event if multiple touches are active.
  42467. * Override this method to provide functionality.
  42468. */
  42469. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42470. /**
  42471. * Called on JS contextmenu event.
  42472. * Override this method to provide functionality.
  42473. */
  42474. protected onContextMenu(evt: PointerEvent): void;
  42475. /**
  42476. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42477. * press.
  42478. * Override this method to provide functionality.
  42479. */
  42480. protected onButtonDown(evt: PointerEvent): void;
  42481. /**
  42482. * Called each time a new POINTERUP event occurs. Ie, for each button
  42483. * release.
  42484. * Override this method to provide functionality.
  42485. */
  42486. protected onButtonUp(evt: PointerEvent): void;
  42487. /**
  42488. * Called when window becomes inactive.
  42489. * Override this method to provide functionality.
  42490. */
  42491. protected onLostFocus(): void;
  42492. private _pointerInput;
  42493. private _observer;
  42494. private _onLostFocus;
  42495. private pointA;
  42496. private pointB;
  42497. }
  42498. }
  42499. declare module BABYLON {
  42500. /**
  42501. * Manage the pointers inputs to control an arc rotate camera.
  42502. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42503. */
  42504. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42505. /**
  42506. * Defines the camera the input is attached to.
  42507. */
  42508. camera: ArcRotateCamera;
  42509. /**
  42510. * Gets the class name of the current input.
  42511. * @returns the class name
  42512. */
  42513. getClassName(): string;
  42514. /**
  42515. * Defines the buttons associated with the input to handle camera move.
  42516. */
  42517. buttons: number[];
  42518. /**
  42519. * Defines the pointer angular sensibility along the X axis or how fast is
  42520. * the camera rotating.
  42521. */
  42522. angularSensibilityX: number;
  42523. /**
  42524. * Defines the pointer angular sensibility along the Y axis or how fast is
  42525. * the camera rotating.
  42526. */
  42527. angularSensibilityY: number;
  42528. /**
  42529. * Defines the pointer pinch precision or how fast is the camera zooming.
  42530. */
  42531. pinchPrecision: number;
  42532. /**
  42533. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42534. * from 0.
  42535. * It defines the percentage of current camera.radius to use as delta when
  42536. * pinch zoom is used.
  42537. */
  42538. pinchDeltaPercentage: number;
  42539. /**
  42540. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42541. * that any object in the plane at the camera's target point will scale
  42542. * perfectly with finger motion.
  42543. * Overrides pinchDeltaPercentage and pinchPrecision.
  42544. */
  42545. useNaturalPinchZoom: boolean;
  42546. /**
  42547. * Defines the pointer panning sensibility or how fast is the camera moving.
  42548. */
  42549. panningSensibility: number;
  42550. /**
  42551. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42552. */
  42553. multiTouchPanning: boolean;
  42554. /**
  42555. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  42556. * zoom (pinch) through multitouch.
  42557. */
  42558. multiTouchPanAndZoom: boolean;
  42559. /**
  42560. * Revers pinch action direction.
  42561. */
  42562. pinchInwards: boolean;
  42563. private _isPanClick;
  42564. private _twoFingerActivityCount;
  42565. private _isPinching;
  42566. /**
  42567. * Called on pointer POINTERMOVE event if only a single touch is active.
  42568. */
  42569. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42570. /**
  42571. * Called on pointer POINTERDOUBLETAP event.
  42572. */
  42573. protected onDoubleTap(type: string): void;
  42574. /**
  42575. * Called on pointer POINTERMOVE event if multiple touches are active.
  42576. */
  42577. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42578. /**
  42579. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42580. * press.
  42581. */
  42582. protected onButtonDown(evt: PointerEvent): void;
  42583. /**
  42584. * Called each time a new POINTERUP event occurs. Ie, for each button
  42585. * release.
  42586. */
  42587. protected onButtonUp(evt: PointerEvent): void;
  42588. /**
  42589. * Called when window becomes inactive.
  42590. */
  42591. protected onLostFocus(): void;
  42592. }
  42593. }
  42594. declare module BABYLON {
  42595. /**
  42596. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42597. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42598. */
  42599. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42600. /**
  42601. * Defines the camera the input is attached to.
  42602. */
  42603. camera: ArcRotateCamera;
  42604. /**
  42605. * Defines the list of key codes associated with the up action (increase alpha)
  42606. */
  42607. keysUp: number[];
  42608. /**
  42609. * Defines the list of key codes associated with the down action (decrease alpha)
  42610. */
  42611. keysDown: number[];
  42612. /**
  42613. * Defines the list of key codes associated with the left action (increase beta)
  42614. */
  42615. keysLeft: number[];
  42616. /**
  42617. * Defines the list of key codes associated with the right action (decrease beta)
  42618. */
  42619. keysRight: number[];
  42620. /**
  42621. * Defines the list of key codes associated with the reset action.
  42622. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42623. */
  42624. keysReset: number[];
  42625. /**
  42626. * Defines the panning sensibility of the inputs.
  42627. * (How fast is the camera panning)
  42628. */
  42629. panningSensibility: number;
  42630. /**
  42631. * Defines the zooming sensibility of the inputs.
  42632. * (How fast is the camera zooming)
  42633. */
  42634. zoomingSensibility: number;
  42635. /**
  42636. * Defines whether maintaining the alt key down switch the movement mode from
  42637. * orientation to zoom.
  42638. */
  42639. useAltToZoom: boolean;
  42640. /**
  42641. * Rotation speed of the camera
  42642. */
  42643. angularSpeed: number;
  42644. private _keys;
  42645. private _ctrlPressed;
  42646. private _altPressed;
  42647. private _onCanvasBlurObserver;
  42648. private _onKeyboardObserver;
  42649. private _engine;
  42650. private _scene;
  42651. /**
  42652. * Attach the input controls to a specific dom element to get the input from.
  42653. * @param element Defines the element the controls should be listened from
  42654. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42655. */
  42656. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42657. /**
  42658. * Detach the current controls from the specified dom element.
  42659. * @param element Defines the element to stop listening the inputs from
  42660. */
  42661. detachControl(element: Nullable<HTMLElement>): void;
  42662. /**
  42663. * Update the current camera state depending on the inputs that have been used this frame.
  42664. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42665. */
  42666. checkInputs(): void;
  42667. /**
  42668. * Gets the class name of the current intput.
  42669. * @returns the class name
  42670. */
  42671. getClassName(): string;
  42672. /**
  42673. * Get the friendly name associated with the input class.
  42674. * @returns the input friendly name
  42675. */
  42676. getSimpleName(): string;
  42677. }
  42678. }
  42679. declare module BABYLON {
  42680. /**
  42681. * Manage the mouse wheel inputs to control an arc rotate camera.
  42682. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42683. */
  42684. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42685. /**
  42686. * Defines the camera the input is attached to.
  42687. */
  42688. camera: ArcRotateCamera;
  42689. /**
  42690. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42691. */
  42692. wheelPrecision: number;
  42693. /**
  42694. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42695. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42696. */
  42697. wheelDeltaPercentage: number;
  42698. private _wheel;
  42699. private _observer;
  42700. private computeDeltaFromMouseWheelLegacyEvent;
  42701. /**
  42702. * Attach the input controls to a specific dom element to get the input from.
  42703. * @param element Defines the element the controls should be listened from
  42704. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42705. */
  42706. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42707. /**
  42708. * Detach the current controls from the specified dom element.
  42709. * @param element Defines the element to stop listening the inputs from
  42710. */
  42711. detachControl(element: Nullable<HTMLElement>): void;
  42712. /**
  42713. * Gets the class name of the current intput.
  42714. * @returns the class name
  42715. */
  42716. getClassName(): string;
  42717. /**
  42718. * Get the friendly name associated with the input class.
  42719. * @returns the input friendly name
  42720. */
  42721. getSimpleName(): string;
  42722. }
  42723. }
  42724. declare module BABYLON {
  42725. /**
  42726. * Default Inputs manager for the ArcRotateCamera.
  42727. * It groups all the default supported inputs for ease of use.
  42728. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42729. */
  42730. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  42731. /**
  42732. * Instantiates a new ArcRotateCameraInputsManager.
  42733. * @param camera Defines the camera the inputs belong to
  42734. */
  42735. constructor(camera: ArcRotateCamera);
  42736. /**
  42737. * Add mouse wheel input support to the input manager.
  42738. * @returns the current input manager
  42739. */
  42740. addMouseWheel(): ArcRotateCameraInputsManager;
  42741. /**
  42742. * Add pointers input support to the input manager.
  42743. * @returns the current input manager
  42744. */
  42745. addPointers(): ArcRotateCameraInputsManager;
  42746. /**
  42747. * Add keyboard input support to the input manager.
  42748. * @returns the current input manager
  42749. */
  42750. addKeyboard(): ArcRotateCameraInputsManager;
  42751. }
  42752. }
  42753. declare module BABYLON {
  42754. /**
  42755. * This represents an orbital type of camera.
  42756. *
  42757. * 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.
  42758. * 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.
  42759. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  42760. */
  42761. export class ArcRotateCamera extends TargetCamera {
  42762. /**
  42763. * Defines the rotation angle of the camera along the longitudinal axis.
  42764. */
  42765. alpha: number;
  42766. /**
  42767. * Defines the rotation angle of the camera along the latitudinal axis.
  42768. */
  42769. beta: number;
  42770. /**
  42771. * Defines the radius of the camera from it s target point.
  42772. */
  42773. radius: number;
  42774. protected _target: Vector3;
  42775. protected _targetHost: Nullable<AbstractMesh>;
  42776. /**
  42777. * Defines the target point of the camera.
  42778. * The camera looks towards it form the radius distance.
  42779. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  42780. */
  42781. get target(): Vector3;
  42782. set target(value: Vector3);
  42783. /**
  42784. * Define the current local position of the camera in the scene
  42785. */
  42786. get position(): Vector3;
  42787. set position(newPosition: Vector3);
  42788. protected _upVector: Vector3;
  42789. protected _upToYMatrix: Matrix;
  42790. protected _YToUpMatrix: Matrix;
  42791. /**
  42792. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  42793. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  42794. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  42795. */
  42796. set upVector(vec: Vector3);
  42797. get upVector(): Vector3;
  42798. /**
  42799. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  42800. */
  42801. setMatUp(): void;
  42802. /**
  42803. * Current inertia value on the longitudinal axis.
  42804. * The bigger this number the longer it will take for the camera to stop.
  42805. */
  42806. inertialAlphaOffset: number;
  42807. /**
  42808. * Current inertia value on the latitudinal axis.
  42809. * The bigger this number the longer it will take for the camera to stop.
  42810. */
  42811. inertialBetaOffset: number;
  42812. /**
  42813. * Current inertia value on the radius axis.
  42814. * The bigger this number the longer it will take for the camera to stop.
  42815. */
  42816. inertialRadiusOffset: number;
  42817. /**
  42818. * Minimum allowed angle on the longitudinal axis.
  42819. * This can help limiting how the Camera is able to move in the scene.
  42820. */
  42821. lowerAlphaLimit: Nullable<number>;
  42822. /**
  42823. * Maximum allowed angle on the longitudinal axis.
  42824. * This can help limiting how the Camera is able to move in the scene.
  42825. */
  42826. upperAlphaLimit: Nullable<number>;
  42827. /**
  42828. * Minimum allowed angle on the latitudinal axis.
  42829. * This can help limiting how the Camera is able to move in the scene.
  42830. */
  42831. lowerBetaLimit: number;
  42832. /**
  42833. * Maximum allowed angle on the latitudinal axis.
  42834. * This can help limiting how the Camera is able to move in the scene.
  42835. */
  42836. upperBetaLimit: number;
  42837. /**
  42838. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  42839. * This can help limiting how the Camera is able to move in the scene.
  42840. */
  42841. lowerRadiusLimit: Nullable<number>;
  42842. /**
  42843. * Maximum allowed distance of the camera to the target (The camera can not get further).
  42844. * This can help limiting how the Camera is able to move in the scene.
  42845. */
  42846. upperRadiusLimit: Nullable<number>;
  42847. /**
  42848. * Defines the current inertia value used during panning of the camera along the X axis.
  42849. */
  42850. inertialPanningX: number;
  42851. /**
  42852. * Defines the current inertia value used during panning of the camera along the Y axis.
  42853. */
  42854. inertialPanningY: number;
  42855. /**
  42856. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  42857. * Basically if your fingers moves away from more than this distance you will be considered
  42858. * in pinch mode.
  42859. */
  42860. pinchToPanMaxDistance: number;
  42861. /**
  42862. * Defines the maximum distance the camera can pan.
  42863. * This could help keeping the cammera always in your scene.
  42864. */
  42865. panningDistanceLimit: Nullable<number>;
  42866. /**
  42867. * Defines the target of the camera before paning.
  42868. */
  42869. panningOriginTarget: Vector3;
  42870. /**
  42871. * Defines the value of the inertia used during panning.
  42872. * 0 would mean stop inertia and one would mean no decelleration at all.
  42873. */
  42874. panningInertia: number;
  42875. /**
  42876. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  42877. */
  42878. get angularSensibilityX(): number;
  42879. set angularSensibilityX(value: number);
  42880. /**
  42881. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  42882. */
  42883. get angularSensibilityY(): number;
  42884. set angularSensibilityY(value: number);
  42885. /**
  42886. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  42887. */
  42888. get pinchPrecision(): number;
  42889. set pinchPrecision(value: number);
  42890. /**
  42891. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  42892. * It will be used instead of pinchDeltaPrecision if different from 0.
  42893. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42894. */
  42895. get pinchDeltaPercentage(): number;
  42896. set pinchDeltaPercentage(value: number);
  42897. /**
  42898. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  42899. * and pinch delta percentage.
  42900. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42901. * that any object in the plane at the camera's target point will scale
  42902. * perfectly with finger motion.
  42903. */
  42904. get useNaturalPinchZoom(): boolean;
  42905. set useNaturalPinchZoom(value: boolean);
  42906. /**
  42907. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  42908. */
  42909. get panningSensibility(): number;
  42910. set panningSensibility(value: number);
  42911. /**
  42912. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  42913. */
  42914. get keysUp(): number[];
  42915. set keysUp(value: number[]);
  42916. /**
  42917. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  42918. */
  42919. get keysDown(): number[];
  42920. set keysDown(value: number[]);
  42921. /**
  42922. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  42923. */
  42924. get keysLeft(): number[];
  42925. set keysLeft(value: number[]);
  42926. /**
  42927. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  42928. */
  42929. get keysRight(): number[];
  42930. set keysRight(value: number[]);
  42931. /**
  42932. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42933. */
  42934. get wheelPrecision(): number;
  42935. set wheelPrecision(value: number);
  42936. /**
  42937. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  42938. * It will be used instead of pinchDeltaPrecision if different from 0.
  42939. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42940. */
  42941. get wheelDeltaPercentage(): number;
  42942. set wheelDeltaPercentage(value: number);
  42943. /**
  42944. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  42945. */
  42946. zoomOnFactor: number;
  42947. /**
  42948. * Defines a screen offset for the camera position.
  42949. */
  42950. targetScreenOffset: Vector2;
  42951. /**
  42952. * Allows the camera to be completely reversed.
  42953. * If false the camera can not arrive upside down.
  42954. */
  42955. allowUpsideDown: boolean;
  42956. /**
  42957. * Define if double tap/click is used to restore the previously saved state of the camera.
  42958. */
  42959. useInputToRestoreState: boolean;
  42960. /** @hidden */
  42961. _viewMatrix: Matrix;
  42962. /** @hidden */
  42963. _useCtrlForPanning: boolean;
  42964. /** @hidden */
  42965. _panningMouseButton: number;
  42966. /**
  42967. * Defines the input associated to the camera.
  42968. */
  42969. inputs: ArcRotateCameraInputsManager;
  42970. /** @hidden */
  42971. _reset: () => void;
  42972. /**
  42973. * Defines the allowed panning axis.
  42974. */
  42975. panningAxis: Vector3;
  42976. protected _localDirection: Vector3;
  42977. protected _transformedDirection: Vector3;
  42978. private _bouncingBehavior;
  42979. /**
  42980. * Gets the bouncing behavior of the camera if it has been enabled.
  42981. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42982. */
  42983. get bouncingBehavior(): Nullable<BouncingBehavior>;
  42984. /**
  42985. * Defines if the bouncing behavior of the camera is enabled on the camera.
  42986. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42987. */
  42988. get useBouncingBehavior(): boolean;
  42989. set useBouncingBehavior(value: boolean);
  42990. private _framingBehavior;
  42991. /**
  42992. * Gets the framing behavior of the camera if it has been enabled.
  42993. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42994. */
  42995. get framingBehavior(): Nullable<FramingBehavior>;
  42996. /**
  42997. * Defines if the framing behavior of the camera is enabled on the camera.
  42998. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42999. */
  43000. get useFramingBehavior(): boolean;
  43001. set useFramingBehavior(value: boolean);
  43002. private _autoRotationBehavior;
  43003. /**
  43004. * Gets the auto rotation behavior of the camera if it has been enabled.
  43005. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43006. */
  43007. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43008. /**
  43009. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43010. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43011. */
  43012. get useAutoRotationBehavior(): boolean;
  43013. set useAutoRotationBehavior(value: boolean);
  43014. /**
  43015. * Observable triggered when the mesh target has been changed on the camera.
  43016. */
  43017. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43018. /**
  43019. * Event raised when the camera is colliding with a mesh.
  43020. */
  43021. onCollide: (collidedMesh: AbstractMesh) => void;
  43022. /**
  43023. * Defines whether the camera should check collision with the objects oh the scene.
  43024. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43025. */
  43026. checkCollisions: boolean;
  43027. /**
  43028. * Defines the collision radius of the camera.
  43029. * This simulates a sphere around the camera.
  43030. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43031. */
  43032. collisionRadius: Vector3;
  43033. protected _collider: Collider;
  43034. protected _previousPosition: Vector3;
  43035. protected _collisionVelocity: Vector3;
  43036. protected _newPosition: Vector3;
  43037. protected _previousAlpha: number;
  43038. protected _previousBeta: number;
  43039. protected _previousRadius: number;
  43040. protected _collisionTriggered: boolean;
  43041. protected _targetBoundingCenter: Nullable<Vector3>;
  43042. private _computationVector;
  43043. /**
  43044. * Instantiates a new ArcRotateCamera in a given scene
  43045. * @param name Defines the name of the camera
  43046. * @param alpha Defines the camera rotation along the logitudinal axis
  43047. * @param beta Defines the camera rotation along the latitudinal axis
  43048. * @param radius Defines the camera distance from its target
  43049. * @param target Defines the camera target
  43050. * @param scene Defines the scene the camera belongs to
  43051. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43052. */
  43053. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43054. /** @hidden */
  43055. _initCache(): void;
  43056. /** @hidden */
  43057. _updateCache(ignoreParentClass?: boolean): void;
  43058. protected _getTargetPosition(): Vector3;
  43059. private _storedAlpha;
  43060. private _storedBeta;
  43061. private _storedRadius;
  43062. private _storedTarget;
  43063. private _storedTargetScreenOffset;
  43064. /**
  43065. * Stores the current state of the camera (alpha, beta, radius and target)
  43066. * @returns the camera itself
  43067. */
  43068. storeState(): Camera;
  43069. /**
  43070. * @hidden
  43071. * Restored camera state. You must call storeState() first
  43072. */
  43073. _restoreStateValues(): boolean;
  43074. /** @hidden */
  43075. _isSynchronizedViewMatrix(): boolean;
  43076. /**
  43077. * Attached controls to the current camera.
  43078. * @param element Defines the element the controls should be listened from
  43079. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43080. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43081. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43082. */
  43083. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43084. /**
  43085. * Detach the current controls from the camera.
  43086. * The camera will stop reacting to inputs.
  43087. * @param element Defines the element to stop listening the inputs from
  43088. */
  43089. detachControl(element: HTMLElement): void;
  43090. /** @hidden */
  43091. _checkInputs(): void;
  43092. protected _checkLimits(): void;
  43093. /**
  43094. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43095. */
  43096. rebuildAnglesAndRadius(): void;
  43097. /**
  43098. * Use a position to define the current camera related information like alpha, beta and radius
  43099. * @param position Defines the position to set the camera at
  43100. */
  43101. setPosition(position: Vector3): void;
  43102. /**
  43103. * Defines the target the camera should look at.
  43104. * This will automatically adapt alpha beta and radius to fit within the new target.
  43105. * @param target Defines the new target as a Vector or a mesh
  43106. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43107. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43108. */
  43109. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43110. /** @hidden */
  43111. _getViewMatrix(): Matrix;
  43112. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43113. /**
  43114. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43115. * @param meshes Defines the mesh to zoom on
  43116. * @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)
  43117. */
  43118. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43119. /**
  43120. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43121. * The target will be changed but the radius
  43122. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43123. * @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)
  43124. */
  43125. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43126. min: Vector3;
  43127. max: Vector3;
  43128. distance: number;
  43129. }, doNotUpdateMaxZ?: boolean): void;
  43130. /**
  43131. * @override
  43132. * Override Camera.createRigCamera
  43133. */
  43134. createRigCamera(name: string, cameraIndex: number): Camera;
  43135. /**
  43136. * @hidden
  43137. * @override
  43138. * Override Camera._updateRigCameras
  43139. */
  43140. _updateRigCameras(): void;
  43141. /**
  43142. * Destroy the camera and release the current resources hold by it.
  43143. */
  43144. dispose(): void;
  43145. /**
  43146. * Gets the current object class name.
  43147. * @return the class name
  43148. */
  43149. getClassName(): string;
  43150. }
  43151. }
  43152. declare module BABYLON {
  43153. /**
  43154. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43155. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43156. */
  43157. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43158. /**
  43159. * Gets the name of the behavior.
  43160. */
  43161. get name(): string;
  43162. private _zoomStopsAnimation;
  43163. private _idleRotationSpeed;
  43164. private _idleRotationWaitTime;
  43165. private _idleRotationSpinupTime;
  43166. /**
  43167. * Sets the flag that indicates if user zooming should stop animation.
  43168. */
  43169. set zoomStopsAnimation(flag: boolean);
  43170. /**
  43171. * Gets the flag that indicates if user zooming should stop animation.
  43172. */
  43173. get zoomStopsAnimation(): boolean;
  43174. /**
  43175. * Sets the default speed at which the camera rotates around the model.
  43176. */
  43177. set idleRotationSpeed(speed: number);
  43178. /**
  43179. * Gets the default speed at which the camera rotates around the model.
  43180. */
  43181. get idleRotationSpeed(): number;
  43182. /**
  43183. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43184. */
  43185. set idleRotationWaitTime(time: number);
  43186. /**
  43187. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43188. */
  43189. get idleRotationWaitTime(): number;
  43190. /**
  43191. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43192. */
  43193. set idleRotationSpinupTime(time: number);
  43194. /**
  43195. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43196. */
  43197. get idleRotationSpinupTime(): number;
  43198. /**
  43199. * Gets a value indicating if the camera is currently rotating because of this behavior
  43200. */
  43201. get rotationInProgress(): boolean;
  43202. private _onPrePointerObservableObserver;
  43203. private _onAfterCheckInputsObserver;
  43204. private _attachedCamera;
  43205. private _isPointerDown;
  43206. private _lastFrameTime;
  43207. private _lastInteractionTime;
  43208. private _cameraRotationSpeed;
  43209. /**
  43210. * Initializes the behavior.
  43211. */
  43212. init(): void;
  43213. /**
  43214. * Attaches the behavior to its arc rotate camera.
  43215. * @param camera Defines the camera to attach the behavior to
  43216. */
  43217. attach(camera: ArcRotateCamera): void;
  43218. /**
  43219. * Detaches the behavior from its current arc rotate camera.
  43220. */
  43221. detach(): void;
  43222. /**
  43223. * Returns true if user is scrolling.
  43224. * @return true if user is scrolling.
  43225. */
  43226. private _userIsZooming;
  43227. private _lastFrameRadius;
  43228. private _shouldAnimationStopForInteraction;
  43229. /**
  43230. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43231. */
  43232. private _applyUserInteraction;
  43233. private _userIsMoving;
  43234. }
  43235. }
  43236. declare module BABYLON {
  43237. /**
  43238. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43239. */
  43240. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43241. private ui;
  43242. /**
  43243. * The name of the behavior
  43244. */
  43245. name: string;
  43246. /**
  43247. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43248. */
  43249. distanceAwayFromFace: number;
  43250. /**
  43251. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43252. */
  43253. distanceAwayFromBottomOfFace: number;
  43254. private _faceVectors;
  43255. private _target;
  43256. private _scene;
  43257. private _onRenderObserver;
  43258. private _tmpMatrix;
  43259. private _tmpVector;
  43260. /**
  43261. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43262. * @param ui The transform node that should be attched to the mesh
  43263. */
  43264. constructor(ui: TransformNode);
  43265. /**
  43266. * Initializes the behavior
  43267. */
  43268. init(): void;
  43269. private _closestFace;
  43270. private _zeroVector;
  43271. private _lookAtTmpMatrix;
  43272. private _lookAtToRef;
  43273. /**
  43274. * Attaches the AttachToBoxBehavior to the passed in mesh
  43275. * @param target The mesh that the specified node will be attached to
  43276. */
  43277. attach(target: Mesh): void;
  43278. /**
  43279. * Detaches the behavior from the mesh
  43280. */
  43281. detach(): void;
  43282. }
  43283. }
  43284. declare module BABYLON {
  43285. /**
  43286. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43287. */
  43288. export class FadeInOutBehavior implements Behavior<Mesh> {
  43289. /**
  43290. * Time in milliseconds to delay before fading in (Default: 0)
  43291. */
  43292. delay: number;
  43293. /**
  43294. * Time in milliseconds for the mesh to fade in (Default: 300)
  43295. */
  43296. fadeInTime: number;
  43297. private _millisecondsPerFrame;
  43298. private _hovered;
  43299. private _hoverValue;
  43300. private _ownerNode;
  43301. /**
  43302. * Instatiates the FadeInOutBehavior
  43303. */
  43304. constructor();
  43305. /**
  43306. * The name of the behavior
  43307. */
  43308. get name(): string;
  43309. /**
  43310. * Initializes the behavior
  43311. */
  43312. init(): void;
  43313. /**
  43314. * Attaches the fade behavior on the passed in mesh
  43315. * @param ownerNode The mesh that will be faded in/out once attached
  43316. */
  43317. attach(ownerNode: Mesh): void;
  43318. /**
  43319. * Detaches the behavior from the mesh
  43320. */
  43321. detach(): void;
  43322. /**
  43323. * Triggers the mesh to begin fading in or out
  43324. * @param value if the object should fade in or out (true to fade in)
  43325. */
  43326. fadeIn(value: boolean): void;
  43327. private _update;
  43328. private _setAllVisibility;
  43329. }
  43330. }
  43331. declare module BABYLON {
  43332. /**
  43333. * Class containing a set of static utilities functions for managing Pivots
  43334. * @hidden
  43335. */
  43336. export class PivotTools {
  43337. private static _PivotCached;
  43338. private static _OldPivotPoint;
  43339. private static _PivotTranslation;
  43340. private static _PivotTmpVector;
  43341. /** @hidden */
  43342. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43343. /** @hidden */
  43344. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43345. }
  43346. }
  43347. declare module BABYLON {
  43348. /**
  43349. * Class containing static functions to help procedurally build meshes
  43350. */
  43351. export class PlaneBuilder {
  43352. /**
  43353. * Creates a plane mesh
  43354. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43355. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43356. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43357. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43358. * * 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
  43359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43360. * @param name defines the name of the mesh
  43361. * @param options defines the options used to create the mesh
  43362. * @param scene defines the hosting scene
  43363. * @returns the plane mesh
  43364. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43365. */
  43366. static CreatePlane(name: string, options: {
  43367. size?: number;
  43368. width?: number;
  43369. height?: number;
  43370. sideOrientation?: number;
  43371. frontUVs?: Vector4;
  43372. backUVs?: Vector4;
  43373. updatable?: boolean;
  43374. sourcePlane?: Plane;
  43375. }, scene?: Nullable<Scene>): Mesh;
  43376. }
  43377. }
  43378. declare module BABYLON {
  43379. /**
  43380. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43381. */
  43382. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43383. private static _AnyMouseID;
  43384. /**
  43385. * Abstract mesh the behavior is set on
  43386. */
  43387. attachedNode: AbstractMesh;
  43388. private _dragPlane;
  43389. private _scene;
  43390. private _pointerObserver;
  43391. private _beforeRenderObserver;
  43392. private static _planeScene;
  43393. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43394. /**
  43395. * 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)
  43396. */
  43397. maxDragAngle: number;
  43398. /**
  43399. * @hidden
  43400. */
  43401. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43402. /**
  43403. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43404. */
  43405. currentDraggingPointerID: number;
  43406. /**
  43407. * The last position where the pointer hit the drag plane in world space
  43408. */
  43409. lastDragPosition: Vector3;
  43410. /**
  43411. * If the behavior is currently in a dragging state
  43412. */
  43413. dragging: boolean;
  43414. /**
  43415. * 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)
  43416. */
  43417. dragDeltaRatio: number;
  43418. /**
  43419. * If the drag plane orientation should be updated during the dragging (Default: true)
  43420. */
  43421. updateDragPlane: boolean;
  43422. private _debugMode;
  43423. private _moving;
  43424. /**
  43425. * Fires each time the attached mesh is dragged with the pointer
  43426. * * delta between last drag position and current drag position in world space
  43427. * * dragDistance along the drag axis
  43428. * * dragPlaneNormal normal of the current drag plane used during the drag
  43429. * * dragPlanePoint in world space where the drag intersects the drag plane
  43430. */
  43431. onDragObservable: Observable<{
  43432. delta: Vector3;
  43433. dragPlanePoint: Vector3;
  43434. dragPlaneNormal: Vector3;
  43435. dragDistance: number;
  43436. pointerId: number;
  43437. }>;
  43438. /**
  43439. * Fires each time a drag begins (eg. mouse down on mesh)
  43440. */
  43441. onDragStartObservable: Observable<{
  43442. dragPlanePoint: Vector3;
  43443. pointerId: number;
  43444. }>;
  43445. /**
  43446. * Fires each time a drag ends (eg. mouse release after drag)
  43447. */
  43448. onDragEndObservable: Observable<{
  43449. dragPlanePoint: Vector3;
  43450. pointerId: number;
  43451. }>;
  43452. /**
  43453. * If the attached mesh should be moved when dragged
  43454. */
  43455. moveAttached: boolean;
  43456. /**
  43457. * If the drag behavior will react to drag events (Default: true)
  43458. */
  43459. enabled: boolean;
  43460. /**
  43461. * If pointer events should start and release the drag (Default: true)
  43462. */
  43463. startAndReleaseDragOnPointerEvents: boolean;
  43464. /**
  43465. * If camera controls should be detached during the drag
  43466. */
  43467. detachCameraControls: boolean;
  43468. /**
  43469. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43470. */
  43471. useObjectOrientationForDragging: boolean;
  43472. private _options;
  43473. /**
  43474. * Gets the options used by the behavior
  43475. */
  43476. get options(): {
  43477. dragAxis?: Vector3;
  43478. dragPlaneNormal?: Vector3;
  43479. };
  43480. /**
  43481. * Sets the options used by the behavior
  43482. */
  43483. set options(options: {
  43484. dragAxis?: Vector3;
  43485. dragPlaneNormal?: Vector3;
  43486. });
  43487. /**
  43488. * Creates a pointer drag behavior that can be attached to a mesh
  43489. * @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)
  43490. */
  43491. constructor(options?: {
  43492. dragAxis?: Vector3;
  43493. dragPlaneNormal?: Vector3;
  43494. });
  43495. /**
  43496. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43497. */
  43498. validateDrag: (targetPosition: Vector3) => boolean;
  43499. /**
  43500. * The name of the behavior
  43501. */
  43502. get name(): string;
  43503. /**
  43504. * Initializes the behavior
  43505. */
  43506. init(): void;
  43507. private _tmpVector;
  43508. private _alternatePickedPoint;
  43509. private _worldDragAxis;
  43510. private _targetPosition;
  43511. private _attachedElement;
  43512. /**
  43513. * Attaches the drag behavior the passed in mesh
  43514. * @param ownerNode The mesh that will be dragged around once attached
  43515. * @param predicate Predicate to use for pick filtering
  43516. */
  43517. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  43518. /**
  43519. * Force relase the drag action by code.
  43520. */
  43521. releaseDrag(): void;
  43522. private _startDragRay;
  43523. private _lastPointerRay;
  43524. /**
  43525. * Simulates the start of a pointer drag event on the behavior
  43526. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  43527. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  43528. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  43529. */
  43530. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43531. private _startDrag;
  43532. private _dragDelta;
  43533. private _moveDrag;
  43534. private _pickWithRayOnDragPlane;
  43535. private _pointA;
  43536. private _pointC;
  43537. private _localAxis;
  43538. private _lookAt;
  43539. private _updateDragPlanePosition;
  43540. /**
  43541. * Detaches the behavior from the mesh
  43542. */
  43543. detach(): void;
  43544. }
  43545. }
  43546. declare module BABYLON {
  43547. /**
  43548. * A behavior that when attached to a mesh will allow the mesh to be scaled
  43549. */
  43550. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  43551. private _dragBehaviorA;
  43552. private _dragBehaviorB;
  43553. private _startDistance;
  43554. private _initialScale;
  43555. private _targetScale;
  43556. private _ownerNode;
  43557. private _sceneRenderObserver;
  43558. /**
  43559. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  43560. */
  43561. constructor();
  43562. /**
  43563. * The name of the behavior
  43564. */
  43565. get name(): string;
  43566. /**
  43567. * Initializes the behavior
  43568. */
  43569. init(): void;
  43570. private _getCurrentDistance;
  43571. /**
  43572. * Attaches the scale behavior the passed in mesh
  43573. * @param ownerNode The mesh that will be scaled around once attached
  43574. */
  43575. attach(ownerNode: Mesh): void;
  43576. /**
  43577. * Detaches the behavior from the mesh
  43578. */
  43579. detach(): void;
  43580. }
  43581. }
  43582. declare module BABYLON {
  43583. /**
  43584. * 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
  43585. */
  43586. export class SixDofDragBehavior implements Behavior<Mesh> {
  43587. private static _virtualScene;
  43588. private _ownerNode;
  43589. private _sceneRenderObserver;
  43590. private _scene;
  43591. private _targetPosition;
  43592. private _virtualOriginMesh;
  43593. private _virtualDragMesh;
  43594. private _pointerObserver;
  43595. private _moving;
  43596. private _startingOrientation;
  43597. private _attachedElement;
  43598. /**
  43599. * 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)
  43600. */
  43601. private zDragFactor;
  43602. /**
  43603. * If the object should rotate to face the drag origin
  43604. */
  43605. rotateDraggedObject: boolean;
  43606. /**
  43607. * If the behavior is currently in a dragging state
  43608. */
  43609. dragging: boolean;
  43610. /**
  43611. * 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)
  43612. */
  43613. dragDeltaRatio: number;
  43614. /**
  43615. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43616. */
  43617. currentDraggingPointerID: number;
  43618. /**
  43619. * If camera controls should be detached during the drag
  43620. */
  43621. detachCameraControls: boolean;
  43622. /**
  43623. * Fires each time a drag starts
  43624. */
  43625. onDragStartObservable: Observable<{}>;
  43626. /**
  43627. * Fires each time a drag ends (eg. mouse release after drag)
  43628. */
  43629. onDragEndObservable: Observable<{}>;
  43630. /**
  43631. * 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
  43632. */
  43633. constructor();
  43634. /**
  43635. * The name of the behavior
  43636. */
  43637. get name(): string;
  43638. /**
  43639. * Initializes the behavior
  43640. */
  43641. init(): void;
  43642. /**
  43643. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  43644. */
  43645. private get _pointerCamera();
  43646. /**
  43647. * Attaches the scale behavior the passed in mesh
  43648. * @param ownerNode The mesh that will be scaled around once attached
  43649. */
  43650. attach(ownerNode: Mesh): void;
  43651. /**
  43652. * Detaches the behavior from the mesh
  43653. */
  43654. detach(): void;
  43655. }
  43656. }
  43657. declare module BABYLON {
  43658. /**
  43659. * Class used to apply inverse kinematics to bones
  43660. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  43661. */
  43662. export class BoneIKController {
  43663. private static _tmpVecs;
  43664. private static _tmpQuat;
  43665. private static _tmpMats;
  43666. /**
  43667. * Gets or sets the target mesh
  43668. */
  43669. targetMesh: AbstractMesh;
  43670. /** Gets or sets the mesh used as pole */
  43671. poleTargetMesh: AbstractMesh;
  43672. /**
  43673. * Gets or sets the bone used as pole
  43674. */
  43675. poleTargetBone: Nullable<Bone>;
  43676. /**
  43677. * Gets or sets the target position
  43678. */
  43679. targetPosition: Vector3;
  43680. /**
  43681. * Gets or sets the pole target position
  43682. */
  43683. poleTargetPosition: Vector3;
  43684. /**
  43685. * Gets or sets the pole target local offset
  43686. */
  43687. poleTargetLocalOffset: Vector3;
  43688. /**
  43689. * Gets or sets the pole angle
  43690. */
  43691. poleAngle: number;
  43692. /**
  43693. * Gets or sets the mesh associated with the controller
  43694. */
  43695. mesh: AbstractMesh;
  43696. /**
  43697. * 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)
  43698. */
  43699. slerpAmount: number;
  43700. private _bone1Quat;
  43701. private _bone1Mat;
  43702. private _bone2Ang;
  43703. private _bone1;
  43704. private _bone2;
  43705. private _bone1Length;
  43706. private _bone2Length;
  43707. private _maxAngle;
  43708. private _maxReach;
  43709. private _rightHandedSystem;
  43710. private _bendAxis;
  43711. private _slerping;
  43712. private _adjustRoll;
  43713. /**
  43714. * Gets or sets maximum allowed angle
  43715. */
  43716. get maxAngle(): number;
  43717. set maxAngle(value: number);
  43718. /**
  43719. * Creates a new BoneIKController
  43720. * @param mesh defines the mesh to control
  43721. * @param bone defines the bone to control
  43722. * @param options defines options to set up the controller
  43723. */
  43724. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  43725. targetMesh?: AbstractMesh;
  43726. poleTargetMesh?: AbstractMesh;
  43727. poleTargetBone?: Bone;
  43728. poleTargetLocalOffset?: Vector3;
  43729. poleAngle?: number;
  43730. bendAxis?: Vector3;
  43731. maxAngle?: number;
  43732. slerpAmount?: number;
  43733. });
  43734. private _setMaxAngle;
  43735. /**
  43736. * Force the controller to update the bones
  43737. */
  43738. update(): void;
  43739. }
  43740. }
  43741. declare module BABYLON {
  43742. /**
  43743. * Class used to make a bone look toward a point in space
  43744. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  43745. */
  43746. export class BoneLookController {
  43747. private static _tmpVecs;
  43748. private static _tmpQuat;
  43749. private static _tmpMats;
  43750. /**
  43751. * The target Vector3 that the bone will look at
  43752. */
  43753. target: Vector3;
  43754. /**
  43755. * The mesh that the bone is attached to
  43756. */
  43757. mesh: AbstractMesh;
  43758. /**
  43759. * The bone that will be looking to the target
  43760. */
  43761. bone: Bone;
  43762. /**
  43763. * The up axis of the coordinate system that is used when the bone is rotated
  43764. */
  43765. upAxis: Vector3;
  43766. /**
  43767. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  43768. */
  43769. upAxisSpace: Space;
  43770. /**
  43771. * Used to make an adjustment to the yaw of the bone
  43772. */
  43773. adjustYaw: number;
  43774. /**
  43775. * Used to make an adjustment to the pitch of the bone
  43776. */
  43777. adjustPitch: number;
  43778. /**
  43779. * Used to make an adjustment to the roll of the bone
  43780. */
  43781. adjustRoll: number;
  43782. /**
  43783. * 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)
  43784. */
  43785. slerpAmount: number;
  43786. private _minYaw;
  43787. private _maxYaw;
  43788. private _minPitch;
  43789. private _maxPitch;
  43790. private _minYawSin;
  43791. private _minYawCos;
  43792. private _maxYawSin;
  43793. private _maxYawCos;
  43794. private _midYawConstraint;
  43795. private _minPitchTan;
  43796. private _maxPitchTan;
  43797. private _boneQuat;
  43798. private _slerping;
  43799. private _transformYawPitch;
  43800. private _transformYawPitchInv;
  43801. private _firstFrameSkipped;
  43802. private _yawRange;
  43803. private _fowardAxis;
  43804. /**
  43805. * Gets or sets the minimum yaw angle that the bone can look to
  43806. */
  43807. get minYaw(): number;
  43808. set minYaw(value: number);
  43809. /**
  43810. * Gets or sets the maximum yaw angle that the bone can look to
  43811. */
  43812. get maxYaw(): number;
  43813. set maxYaw(value: number);
  43814. /**
  43815. * Gets or sets the minimum pitch angle that the bone can look to
  43816. */
  43817. get minPitch(): number;
  43818. set minPitch(value: number);
  43819. /**
  43820. * Gets or sets the maximum pitch angle that the bone can look to
  43821. */
  43822. get maxPitch(): number;
  43823. set maxPitch(value: number);
  43824. /**
  43825. * Create a BoneLookController
  43826. * @param mesh the mesh that the bone belongs to
  43827. * @param bone the bone that will be looking to the target
  43828. * @param target the target Vector3 to look at
  43829. * @param options optional settings:
  43830. * * maxYaw: the maximum angle the bone will yaw to
  43831. * * minYaw: the minimum angle the bone will yaw to
  43832. * * maxPitch: the maximum angle the bone will pitch to
  43833. * * minPitch: the minimum angle the bone will yaw to
  43834. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  43835. * * upAxis: the up axis of the coordinate system
  43836. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  43837. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  43838. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  43839. * * adjustYaw: used to make an adjustment to the yaw of the bone
  43840. * * adjustPitch: used to make an adjustment to the pitch of the bone
  43841. * * adjustRoll: used to make an adjustment to the roll of the bone
  43842. **/
  43843. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  43844. maxYaw?: number;
  43845. minYaw?: number;
  43846. maxPitch?: number;
  43847. minPitch?: number;
  43848. slerpAmount?: number;
  43849. upAxis?: Vector3;
  43850. upAxisSpace?: Space;
  43851. yawAxis?: Vector3;
  43852. pitchAxis?: Vector3;
  43853. adjustYaw?: number;
  43854. adjustPitch?: number;
  43855. adjustRoll?: number;
  43856. });
  43857. /**
  43858. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  43859. */
  43860. update(): void;
  43861. private _getAngleDiff;
  43862. private _getAngleBetween;
  43863. private _isAngleBetween;
  43864. }
  43865. }
  43866. declare module BABYLON {
  43867. /**
  43868. * Manage the gamepad inputs to control an arc rotate camera.
  43869. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43870. */
  43871. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  43872. /**
  43873. * Defines the camera the input is attached to.
  43874. */
  43875. camera: ArcRotateCamera;
  43876. /**
  43877. * Defines the gamepad the input is gathering event from.
  43878. */
  43879. gamepad: Nullable<Gamepad>;
  43880. /**
  43881. * Defines the gamepad rotation sensiblity.
  43882. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43883. */
  43884. gamepadRotationSensibility: number;
  43885. /**
  43886. * Defines the gamepad move sensiblity.
  43887. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43888. */
  43889. gamepadMoveSensibility: number;
  43890. private _yAxisScale;
  43891. /**
  43892. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43893. */
  43894. get invertYAxis(): boolean;
  43895. set invertYAxis(value: boolean);
  43896. private _onGamepadConnectedObserver;
  43897. private _onGamepadDisconnectedObserver;
  43898. /**
  43899. * Attach the input controls to a specific dom element to get the input from.
  43900. * @param element Defines the element the controls should be listened from
  43901. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43902. */
  43903. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43904. /**
  43905. * Detach the current controls from the specified dom element.
  43906. * @param element Defines the element to stop listening the inputs from
  43907. */
  43908. detachControl(element: Nullable<HTMLElement>): void;
  43909. /**
  43910. * Update the current camera state depending on the inputs that have been used this frame.
  43911. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43912. */
  43913. checkInputs(): void;
  43914. /**
  43915. * Gets the class name of the current intput.
  43916. * @returns the class name
  43917. */
  43918. getClassName(): string;
  43919. /**
  43920. * Get the friendly name associated with the input class.
  43921. * @returns the input friendly name
  43922. */
  43923. getSimpleName(): string;
  43924. }
  43925. }
  43926. declare module BABYLON {
  43927. interface ArcRotateCameraInputsManager {
  43928. /**
  43929. * Add orientation input support to the input manager.
  43930. * @returns the current input manager
  43931. */
  43932. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  43933. }
  43934. /**
  43935. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  43936. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43937. */
  43938. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  43939. /**
  43940. * Defines the camera the input is attached to.
  43941. */
  43942. camera: ArcRotateCamera;
  43943. /**
  43944. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  43945. */
  43946. alphaCorrection: number;
  43947. /**
  43948. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  43949. */
  43950. gammaCorrection: number;
  43951. private _alpha;
  43952. private _gamma;
  43953. private _dirty;
  43954. private _deviceOrientationHandler;
  43955. /**
  43956. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  43957. */
  43958. constructor();
  43959. /**
  43960. * Attach the input controls to a specific dom element to get the input from.
  43961. * @param element Defines the element the controls should be listened from
  43962. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43963. */
  43964. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43965. /** @hidden */
  43966. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  43967. /**
  43968. * Update the current camera state depending on the inputs that have been used this frame.
  43969. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43970. */
  43971. checkInputs(): void;
  43972. /**
  43973. * Detach the current controls from the specified dom element.
  43974. * @param element Defines the element to stop listening the inputs from
  43975. */
  43976. detachControl(element: Nullable<HTMLElement>): void;
  43977. /**
  43978. * Gets the class name of the current intput.
  43979. * @returns the class name
  43980. */
  43981. getClassName(): string;
  43982. /**
  43983. * Get the friendly name associated with the input class.
  43984. * @returns the input friendly name
  43985. */
  43986. getSimpleName(): string;
  43987. }
  43988. }
  43989. declare module BABYLON {
  43990. /**
  43991. * Listen to mouse events to control the camera.
  43992. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43993. */
  43994. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  43995. /**
  43996. * Defines the camera the input is attached to.
  43997. */
  43998. camera: FlyCamera;
  43999. /**
  44000. * Defines if touch is enabled. (Default is true.)
  44001. */
  44002. touchEnabled: boolean;
  44003. /**
  44004. * Defines the buttons associated with the input to handle camera rotation.
  44005. */
  44006. buttons: number[];
  44007. /**
  44008. * Assign buttons for Yaw control.
  44009. */
  44010. buttonsYaw: number[];
  44011. /**
  44012. * Assign buttons for Pitch control.
  44013. */
  44014. buttonsPitch: number[];
  44015. /**
  44016. * Assign buttons for Roll control.
  44017. */
  44018. buttonsRoll: number[];
  44019. /**
  44020. * Detect if any button is being pressed while mouse is moved.
  44021. * -1 = Mouse locked.
  44022. * 0 = Left button.
  44023. * 1 = Middle Button.
  44024. * 2 = Right Button.
  44025. */
  44026. activeButton: number;
  44027. /**
  44028. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44029. * Higher values reduce its sensitivity.
  44030. */
  44031. angularSensibility: number;
  44032. private _mousemoveCallback;
  44033. private _observer;
  44034. private _rollObserver;
  44035. private previousPosition;
  44036. private noPreventDefault;
  44037. private element;
  44038. /**
  44039. * Listen to mouse events to control the camera.
  44040. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44041. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44042. */
  44043. constructor(touchEnabled?: boolean);
  44044. /**
  44045. * Attach the mouse control to the HTML DOM element.
  44046. * @param element Defines the element that listens to the input events.
  44047. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44048. */
  44049. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44050. /**
  44051. * Detach the current controls from the specified dom element.
  44052. * @param element Defines the element to stop listening the inputs from
  44053. */
  44054. detachControl(element: Nullable<HTMLElement>): void;
  44055. /**
  44056. * Gets the class name of the current input.
  44057. * @returns the class name.
  44058. */
  44059. getClassName(): string;
  44060. /**
  44061. * Get the friendly name associated with the input class.
  44062. * @returns the input's friendly name.
  44063. */
  44064. getSimpleName(): string;
  44065. private _pointerInput;
  44066. private _onMouseMove;
  44067. /**
  44068. * Rotate camera by mouse offset.
  44069. */
  44070. private rotateCamera;
  44071. }
  44072. }
  44073. declare module BABYLON {
  44074. /**
  44075. * Default Inputs manager for the FlyCamera.
  44076. * It groups all the default supported inputs for ease of use.
  44077. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44078. */
  44079. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44080. /**
  44081. * Instantiates a new FlyCameraInputsManager.
  44082. * @param camera Defines the camera the inputs belong to.
  44083. */
  44084. constructor(camera: FlyCamera);
  44085. /**
  44086. * Add keyboard input support to the input manager.
  44087. * @returns the new FlyCameraKeyboardMoveInput().
  44088. */
  44089. addKeyboard(): FlyCameraInputsManager;
  44090. /**
  44091. * Add mouse input support to the input manager.
  44092. * @param touchEnabled Enable touch screen support.
  44093. * @returns the new FlyCameraMouseInput().
  44094. */
  44095. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44096. }
  44097. }
  44098. declare module BABYLON {
  44099. /**
  44100. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44101. * such as in a 3D Space Shooter or a Flight Simulator.
  44102. */
  44103. export class FlyCamera extends TargetCamera {
  44104. /**
  44105. * Define the collision ellipsoid of the camera.
  44106. * This is helpful for simulating a camera body, like a player's body.
  44107. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44108. */
  44109. ellipsoid: Vector3;
  44110. /**
  44111. * Define an offset for the position of the ellipsoid around the camera.
  44112. * This can be helpful if the camera is attached away from the player's body center,
  44113. * such as at its head.
  44114. */
  44115. ellipsoidOffset: Vector3;
  44116. /**
  44117. * Enable or disable collisions of the camera with the rest of the scene objects.
  44118. */
  44119. checkCollisions: boolean;
  44120. /**
  44121. * Enable or disable gravity on the camera.
  44122. */
  44123. applyGravity: boolean;
  44124. /**
  44125. * Define the current direction the camera is moving to.
  44126. */
  44127. cameraDirection: Vector3;
  44128. /**
  44129. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44130. * This overrides and empties cameraRotation.
  44131. */
  44132. rotationQuaternion: Quaternion;
  44133. /**
  44134. * Track Roll to maintain the wanted Rolling when looking around.
  44135. */
  44136. _trackRoll: number;
  44137. /**
  44138. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44139. */
  44140. rollCorrect: number;
  44141. /**
  44142. * Mimic a banked turn, Rolling the camera when Yawing.
  44143. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44144. */
  44145. bankedTurn: boolean;
  44146. /**
  44147. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44148. */
  44149. bankedTurnLimit: number;
  44150. /**
  44151. * Value of 0 disables the banked Roll.
  44152. * Value of 1 is equal to the Yaw angle in radians.
  44153. */
  44154. bankedTurnMultiplier: number;
  44155. /**
  44156. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44157. */
  44158. inputs: FlyCameraInputsManager;
  44159. /**
  44160. * Gets the input sensibility for mouse input.
  44161. * Higher values reduce sensitivity.
  44162. */
  44163. get angularSensibility(): number;
  44164. /**
  44165. * Sets the input sensibility for a mouse input.
  44166. * Higher values reduce sensitivity.
  44167. */
  44168. set angularSensibility(value: number);
  44169. /**
  44170. * Get the keys for camera movement forward.
  44171. */
  44172. get keysForward(): number[];
  44173. /**
  44174. * Set the keys for camera movement forward.
  44175. */
  44176. set keysForward(value: number[]);
  44177. /**
  44178. * Get the keys for camera movement backward.
  44179. */
  44180. get keysBackward(): number[];
  44181. set keysBackward(value: number[]);
  44182. /**
  44183. * Get the keys for camera movement up.
  44184. */
  44185. get keysUp(): number[];
  44186. /**
  44187. * Set the keys for camera movement up.
  44188. */
  44189. set keysUp(value: number[]);
  44190. /**
  44191. * Get the keys for camera movement down.
  44192. */
  44193. get keysDown(): number[];
  44194. /**
  44195. * Set the keys for camera movement down.
  44196. */
  44197. set keysDown(value: number[]);
  44198. /**
  44199. * Get the keys for camera movement left.
  44200. */
  44201. get keysLeft(): number[];
  44202. /**
  44203. * Set the keys for camera movement left.
  44204. */
  44205. set keysLeft(value: number[]);
  44206. /**
  44207. * Set the keys for camera movement right.
  44208. */
  44209. get keysRight(): number[];
  44210. /**
  44211. * Set the keys for camera movement right.
  44212. */
  44213. set keysRight(value: number[]);
  44214. /**
  44215. * Event raised when the camera collides with a mesh in the scene.
  44216. */
  44217. onCollide: (collidedMesh: AbstractMesh) => void;
  44218. private _collider;
  44219. private _needMoveForGravity;
  44220. private _oldPosition;
  44221. private _diffPosition;
  44222. private _newPosition;
  44223. /** @hidden */
  44224. _localDirection: Vector3;
  44225. /** @hidden */
  44226. _transformedDirection: Vector3;
  44227. /**
  44228. * Instantiates a FlyCamera.
  44229. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44230. * such as in a 3D Space Shooter or a Flight Simulator.
  44231. * @param name Define the name of the camera in the scene.
  44232. * @param position Define the starting position of the camera in the scene.
  44233. * @param scene Define the scene the camera belongs to.
  44234. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44235. */
  44236. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44237. /**
  44238. * Attach a control to the HTML DOM element.
  44239. * @param element Defines the element that listens to the input events.
  44240. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44241. */
  44242. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44243. /**
  44244. * Detach a control from the HTML DOM element.
  44245. * The camera will stop reacting to that input.
  44246. * @param element Defines the element that listens to the input events.
  44247. */
  44248. detachControl(element: HTMLElement): void;
  44249. private _collisionMask;
  44250. /**
  44251. * Get the mask that the camera ignores in collision events.
  44252. */
  44253. get collisionMask(): number;
  44254. /**
  44255. * Set the mask that the camera ignores in collision events.
  44256. */
  44257. set collisionMask(mask: number);
  44258. /** @hidden */
  44259. _collideWithWorld(displacement: Vector3): void;
  44260. /** @hidden */
  44261. private _onCollisionPositionChange;
  44262. /** @hidden */
  44263. _checkInputs(): void;
  44264. /** @hidden */
  44265. _decideIfNeedsToMove(): boolean;
  44266. /** @hidden */
  44267. _updatePosition(): void;
  44268. /**
  44269. * Restore the Roll to its target value at the rate specified.
  44270. * @param rate - Higher means slower restoring.
  44271. * @hidden
  44272. */
  44273. restoreRoll(rate: number): void;
  44274. /**
  44275. * Destroy the camera and release the current resources held by it.
  44276. */
  44277. dispose(): void;
  44278. /**
  44279. * Get the current object class name.
  44280. * @returns the class name.
  44281. */
  44282. getClassName(): string;
  44283. }
  44284. }
  44285. declare module BABYLON {
  44286. /**
  44287. * Listen to keyboard events to control the camera.
  44288. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44289. */
  44290. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44291. /**
  44292. * Defines the camera the input is attached to.
  44293. */
  44294. camera: FlyCamera;
  44295. /**
  44296. * The list of keyboard keys used to control the forward move of the camera.
  44297. */
  44298. keysForward: number[];
  44299. /**
  44300. * The list of keyboard keys used to control the backward move of the camera.
  44301. */
  44302. keysBackward: number[];
  44303. /**
  44304. * The list of keyboard keys used to control the forward move of the camera.
  44305. */
  44306. keysUp: number[];
  44307. /**
  44308. * The list of keyboard keys used to control the backward move of the camera.
  44309. */
  44310. keysDown: number[];
  44311. /**
  44312. * The list of keyboard keys used to control the right strafe move of the camera.
  44313. */
  44314. keysRight: number[];
  44315. /**
  44316. * The list of keyboard keys used to control the left strafe move of the camera.
  44317. */
  44318. keysLeft: number[];
  44319. private _keys;
  44320. private _onCanvasBlurObserver;
  44321. private _onKeyboardObserver;
  44322. private _engine;
  44323. private _scene;
  44324. /**
  44325. * Attach the input controls to a specific dom element to get the input from.
  44326. * @param element Defines the element the controls should be listened from
  44327. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44328. */
  44329. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44330. /**
  44331. * Detach the current controls from the specified dom element.
  44332. * @param element Defines the element to stop listening the inputs from
  44333. */
  44334. detachControl(element: Nullable<HTMLElement>): void;
  44335. /**
  44336. * Gets the class name of the current intput.
  44337. * @returns the class name
  44338. */
  44339. getClassName(): string;
  44340. /** @hidden */
  44341. _onLostFocus(e: FocusEvent): void;
  44342. /**
  44343. * Get the friendly name associated with the input class.
  44344. * @returns the input friendly name
  44345. */
  44346. getSimpleName(): string;
  44347. /**
  44348. * Update the current camera state depending on the inputs that have been used this frame.
  44349. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44350. */
  44351. checkInputs(): void;
  44352. }
  44353. }
  44354. declare module BABYLON {
  44355. /**
  44356. * Manage the mouse wheel inputs to control a follow camera.
  44357. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44358. */
  44359. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44360. /**
  44361. * Defines the camera the input is attached to.
  44362. */
  44363. camera: FollowCamera;
  44364. /**
  44365. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44366. */
  44367. axisControlRadius: boolean;
  44368. /**
  44369. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44370. */
  44371. axisControlHeight: boolean;
  44372. /**
  44373. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44374. */
  44375. axisControlRotation: boolean;
  44376. /**
  44377. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44378. * relation to mouseWheel events.
  44379. */
  44380. wheelPrecision: number;
  44381. /**
  44382. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44383. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44384. */
  44385. wheelDeltaPercentage: number;
  44386. private _wheel;
  44387. private _observer;
  44388. /**
  44389. * Attach the input controls to a specific dom element to get the input from.
  44390. * @param element Defines the element the controls should be listened from
  44391. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44392. */
  44393. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44394. /**
  44395. * Detach the current controls from the specified dom element.
  44396. * @param element Defines the element to stop listening the inputs from
  44397. */
  44398. detachControl(element: Nullable<HTMLElement>): void;
  44399. /**
  44400. * Gets the class name of the current intput.
  44401. * @returns the class name
  44402. */
  44403. getClassName(): string;
  44404. /**
  44405. * Get the friendly name associated with the input class.
  44406. * @returns the input friendly name
  44407. */
  44408. getSimpleName(): string;
  44409. }
  44410. }
  44411. declare module BABYLON {
  44412. /**
  44413. * Manage the pointers inputs to control an follow camera.
  44414. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44415. */
  44416. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44417. /**
  44418. * Defines the camera the input is attached to.
  44419. */
  44420. camera: FollowCamera;
  44421. /**
  44422. * Gets the class name of the current input.
  44423. * @returns the class name
  44424. */
  44425. getClassName(): string;
  44426. /**
  44427. * Defines the pointer angular sensibility along the X axis or how fast is
  44428. * the camera rotating.
  44429. * A negative number will reverse the axis direction.
  44430. */
  44431. angularSensibilityX: number;
  44432. /**
  44433. * Defines the pointer angular sensibility along the Y axis or how fast is
  44434. * the camera rotating.
  44435. * A negative number will reverse the axis direction.
  44436. */
  44437. angularSensibilityY: number;
  44438. /**
  44439. * Defines the pointer pinch precision or how fast is the camera zooming.
  44440. * A negative number will reverse the axis direction.
  44441. */
  44442. pinchPrecision: number;
  44443. /**
  44444. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44445. * from 0.
  44446. * It defines the percentage of current camera.radius to use as delta when
  44447. * pinch zoom is used.
  44448. */
  44449. pinchDeltaPercentage: number;
  44450. /**
  44451. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  44452. */
  44453. axisXControlRadius: boolean;
  44454. /**
  44455. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  44456. */
  44457. axisXControlHeight: boolean;
  44458. /**
  44459. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  44460. */
  44461. axisXControlRotation: boolean;
  44462. /**
  44463. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  44464. */
  44465. axisYControlRadius: boolean;
  44466. /**
  44467. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  44468. */
  44469. axisYControlHeight: boolean;
  44470. /**
  44471. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  44472. */
  44473. axisYControlRotation: boolean;
  44474. /**
  44475. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  44476. */
  44477. axisPinchControlRadius: boolean;
  44478. /**
  44479. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  44480. */
  44481. axisPinchControlHeight: boolean;
  44482. /**
  44483. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  44484. */
  44485. axisPinchControlRotation: boolean;
  44486. /**
  44487. * Log error messages if basic misconfiguration has occurred.
  44488. */
  44489. warningEnable: boolean;
  44490. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44491. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44492. private _warningCounter;
  44493. private _warning;
  44494. }
  44495. }
  44496. declare module BABYLON {
  44497. /**
  44498. * Default Inputs manager for the FollowCamera.
  44499. * It groups all the default supported inputs for ease of use.
  44500. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44501. */
  44502. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  44503. /**
  44504. * Instantiates a new FollowCameraInputsManager.
  44505. * @param camera Defines the camera the inputs belong to
  44506. */
  44507. constructor(camera: FollowCamera);
  44508. /**
  44509. * Add keyboard input support to the input manager.
  44510. * @returns the current input manager
  44511. */
  44512. addKeyboard(): FollowCameraInputsManager;
  44513. /**
  44514. * Add mouse wheel input support to the input manager.
  44515. * @returns the current input manager
  44516. */
  44517. addMouseWheel(): FollowCameraInputsManager;
  44518. /**
  44519. * Add pointers input support to the input manager.
  44520. * @returns the current input manager
  44521. */
  44522. addPointers(): FollowCameraInputsManager;
  44523. /**
  44524. * Add orientation input support to the input manager.
  44525. * @returns the current input manager
  44526. */
  44527. addVRDeviceOrientation(): FollowCameraInputsManager;
  44528. }
  44529. }
  44530. declare module BABYLON {
  44531. /**
  44532. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  44533. * an arc rotate version arcFollowCamera are available.
  44534. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44535. */
  44536. export class FollowCamera extends TargetCamera {
  44537. /**
  44538. * Distance the follow camera should follow an object at
  44539. */
  44540. radius: number;
  44541. /**
  44542. * Minimum allowed distance of the camera to the axis of rotation
  44543. * (The camera can not get closer).
  44544. * This can help limiting how the Camera is able to move in the scene.
  44545. */
  44546. lowerRadiusLimit: Nullable<number>;
  44547. /**
  44548. * Maximum allowed distance of the camera to the axis of rotation
  44549. * (The camera can not get further).
  44550. * This can help limiting how the Camera is able to move in the scene.
  44551. */
  44552. upperRadiusLimit: Nullable<number>;
  44553. /**
  44554. * Define a rotation offset between the camera and the object it follows
  44555. */
  44556. rotationOffset: number;
  44557. /**
  44558. * Minimum allowed angle to camera position relative to target object.
  44559. * This can help limiting how the Camera is able to move in the scene.
  44560. */
  44561. lowerRotationOffsetLimit: Nullable<number>;
  44562. /**
  44563. * Maximum allowed angle to camera position relative to target object.
  44564. * This can help limiting how the Camera is able to move in the scene.
  44565. */
  44566. upperRotationOffsetLimit: Nullable<number>;
  44567. /**
  44568. * Define a height offset between the camera and the object it follows.
  44569. * It can help following an object from the top (like a car chaing a plane)
  44570. */
  44571. heightOffset: number;
  44572. /**
  44573. * Minimum allowed height of camera position relative to target object.
  44574. * This can help limiting how the Camera is able to move in the scene.
  44575. */
  44576. lowerHeightOffsetLimit: Nullable<number>;
  44577. /**
  44578. * Maximum allowed height of camera position relative to target object.
  44579. * This can help limiting how the Camera is able to move in the scene.
  44580. */
  44581. upperHeightOffsetLimit: Nullable<number>;
  44582. /**
  44583. * Define how fast the camera can accelerate to follow it s target.
  44584. */
  44585. cameraAcceleration: number;
  44586. /**
  44587. * Define the speed limit of the camera following an object.
  44588. */
  44589. maxCameraSpeed: number;
  44590. /**
  44591. * Define the target of the camera.
  44592. */
  44593. lockedTarget: Nullable<AbstractMesh>;
  44594. /**
  44595. * Defines the input associated with the camera.
  44596. */
  44597. inputs: FollowCameraInputsManager;
  44598. /**
  44599. * Instantiates the follow camera.
  44600. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44601. * @param name Define the name of the camera in the scene
  44602. * @param position Define the position of the camera
  44603. * @param scene Define the scene the camera belong to
  44604. * @param lockedTarget Define the target of the camera
  44605. */
  44606. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  44607. private _follow;
  44608. /**
  44609. * Attached controls to the current camera.
  44610. * @param element Defines the element the controls should be listened from
  44611. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44612. */
  44613. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44614. /**
  44615. * Detach the current controls from the camera.
  44616. * The camera will stop reacting to inputs.
  44617. * @param element Defines the element to stop listening the inputs from
  44618. */
  44619. detachControl(element: HTMLElement): void;
  44620. /** @hidden */
  44621. _checkInputs(): void;
  44622. private _checkLimits;
  44623. /**
  44624. * Gets the camera class name.
  44625. * @returns the class name
  44626. */
  44627. getClassName(): string;
  44628. }
  44629. /**
  44630. * Arc Rotate version of the follow camera.
  44631. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  44632. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44633. */
  44634. export class ArcFollowCamera extends TargetCamera {
  44635. /** The longitudinal angle of the camera */
  44636. alpha: number;
  44637. /** The latitudinal angle of the camera */
  44638. beta: number;
  44639. /** The radius of the camera from its target */
  44640. radius: number;
  44641. private _cartesianCoordinates;
  44642. /** Define the camera target (the mesh it should follow) */
  44643. private _meshTarget;
  44644. /**
  44645. * Instantiates a new ArcFollowCamera
  44646. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44647. * @param name Define the name of the camera
  44648. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  44649. * @param beta Define the rotation angle of the camera around the elevation axis
  44650. * @param radius Define the radius of the camera from its target point
  44651. * @param target Define the target of the camera
  44652. * @param scene Define the scene the camera belongs to
  44653. */
  44654. constructor(name: string,
  44655. /** The longitudinal angle of the camera */
  44656. alpha: number,
  44657. /** The latitudinal angle of the camera */
  44658. beta: number,
  44659. /** The radius of the camera from its target */
  44660. radius: number,
  44661. /** Define the camera target (the mesh it should follow) */
  44662. target: Nullable<AbstractMesh>, scene: Scene);
  44663. private _follow;
  44664. /** @hidden */
  44665. _checkInputs(): void;
  44666. /**
  44667. * Returns the class name of the object.
  44668. * It is mostly used internally for serialization purposes.
  44669. */
  44670. getClassName(): string;
  44671. }
  44672. }
  44673. declare module BABYLON {
  44674. /**
  44675. * Manage the keyboard inputs to control the movement of a follow camera.
  44676. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44677. */
  44678. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  44679. /**
  44680. * Defines the camera the input is attached to.
  44681. */
  44682. camera: FollowCamera;
  44683. /**
  44684. * Defines the list of key codes associated with the up action (increase heightOffset)
  44685. */
  44686. keysHeightOffsetIncr: number[];
  44687. /**
  44688. * Defines the list of key codes associated with the down action (decrease heightOffset)
  44689. */
  44690. keysHeightOffsetDecr: number[];
  44691. /**
  44692. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  44693. */
  44694. keysHeightOffsetModifierAlt: boolean;
  44695. /**
  44696. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  44697. */
  44698. keysHeightOffsetModifierCtrl: boolean;
  44699. /**
  44700. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  44701. */
  44702. keysHeightOffsetModifierShift: boolean;
  44703. /**
  44704. * Defines the list of key codes associated with the left action (increase rotationOffset)
  44705. */
  44706. keysRotationOffsetIncr: number[];
  44707. /**
  44708. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  44709. */
  44710. keysRotationOffsetDecr: number[];
  44711. /**
  44712. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  44713. */
  44714. keysRotationOffsetModifierAlt: boolean;
  44715. /**
  44716. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  44717. */
  44718. keysRotationOffsetModifierCtrl: boolean;
  44719. /**
  44720. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  44721. */
  44722. keysRotationOffsetModifierShift: boolean;
  44723. /**
  44724. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  44725. */
  44726. keysRadiusIncr: number[];
  44727. /**
  44728. * Defines the list of key codes associated with the zoom-out action (increase radius)
  44729. */
  44730. keysRadiusDecr: number[];
  44731. /**
  44732. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  44733. */
  44734. keysRadiusModifierAlt: boolean;
  44735. /**
  44736. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  44737. */
  44738. keysRadiusModifierCtrl: boolean;
  44739. /**
  44740. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  44741. */
  44742. keysRadiusModifierShift: boolean;
  44743. /**
  44744. * Defines the rate of change of heightOffset.
  44745. */
  44746. heightSensibility: number;
  44747. /**
  44748. * Defines the rate of change of rotationOffset.
  44749. */
  44750. rotationSensibility: number;
  44751. /**
  44752. * Defines the rate of change of radius.
  44753. */
  44754. radiusSensibility: number;
  44755. private _keys;
  44756. private _ctrlPressed;
  44757. private _altPressed;
  44758. private _shiftPressed;
  44759. private _onCanvasBlurObserver;
  44760. private _onKeyboardObserver;
  44761. private _engine;
  44762. private _scene;
  44763. /**
  44764. * Attach the input controls to a specific dom element to get the input from.
  44765. * @param element Defines the element the controls should be listened from
  44766. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44767. */
  44768. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44769. /**
  44770. * Detach the current controls from the specified dom element.
  44771. * @param element Defines the element to stop listening the inputs from
  44772. */
  44773. detachControl(element: Nullable<HTMLElement>): void;
  44774. /**
  44775. * Update the current camera state depending on the inputs that have been used this frame.
  44776. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44777. */
  44778. checkInputs(): void;
  44779. /**
  44780. * Gets the class name of the current input.
  44781. * @returns the class name
  44782. */
  44783. getClassName(): string;
  44784. /**
  44785. * Get the friendly name associated with the input class.
  44786. * @returns the input friendly name
  44787. */
  44788. getSimpleName(): string;
  44789. /**
  44790. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44791. * allow modification of the heightOffset value.
  44792. */
  44793. private _modifierHeightOffset;
  44794. /**
  44795. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44796. * allow modification of the rotationOffset value.
  44797. */
  44798. private _modifierRotationOffset;
  44799. /**
  44800. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44801. * allow modification of the radius value.
  44802. */
  44803. private _modifierRadius;
  44804. }
  44805. }
  44806. declare module BABYLON {
  44807. interface FreeCameraInputsManager {
  44808. /**
  44809. * @hidden
  44810. */
  44811. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  44812. /**
  44813. * Add orientation input support to the input manager.
  44814. * @returns the current input manager
  44815. */
  44816. addDeviceOrientation(): FreeCameraInputsManager;
  44817. }
  44818. /**
  44819. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  44820. * Screen rotation is taken into account.
  44821. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44822. */
  44823. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  44824. private _camera;
  44825. private _screenOrientationAngle;
  44826. private _constantTranform;
  44827. private _screenQuaternion;
  44828. private _alpha;
  44829. private _beta;
  44830. private _gamma;
  44831. /**
  44832. * Can be used to detect if a device orientation sensor is available on a device
  44833. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  44834. * @returns a promise that will resolve on orientation change
  44835. */
  44836. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  44837. /**
  44838. * @hidden
  44839. */
  44840. _onDeviceOrientationChangedObservable: Observable<void>;
  44841. /**
  44842. * Instantiates a new input
  44843. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44844. */
  44845. constructor();
  44846. /**
  44847. * Define the camera controlled by the input.
  44848. */
  44849. get camera(): FreeCamera;
  44850. set camera(camera: FreeCamera);
  44851. /**
  44852. * Attach the input controls to a specific dom element to get the input from.
  44853. * @param element Defines the element the controls should be listened from
  44854. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44855. */
  44856. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44857. private _orientationChanged;
  44858. private _deviceOrientation;
  44859. /**
  44860. * Detach the current controls from the specified dom element.
  44861. * @param element Defines the element to stop listening the inputs from
  44862. */
  44863. detachControl(element: Nullable<HTMLElement>): void;
  44864. /**
  44865. * Update the current camera state depending on the inputs that have been used this frame.
  44866. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44867. */
  44868. checkInputs(): void;
  44869. /**
  44870. * Gets the class name of the current intput.
  44871. * @returns the class name
  44872. */
  44873. getClassName(): string;
  44874. /**
  44875. * Get the friendly name associated with the input class.
  44876. * @returns the input friendly name
  44877. */
  44878. getSimpleName(): string;
  44879. }
  44880. }
  44881. declare module BABYLON {
  44882. /**
  44883. * Manage the gamepad inputs to control a free camera.
  44884. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44885. */
  44886. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  44887. /**
  44888. * Define the camera the input is attached to.
  44889. */
  44890. camera: FreeCamera;
  44891. /**
  44892. * Define the Gamepad controlling the input
  44893. */
  44894. gamepad: Nullable<Gamepad>;
  44895. /**
  44896. * Defines the gamepad rotation sensiblity.
  44897. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44898. */
  44899. gamepadAngularSensibility: number;
  44900. /**
  44901. * Defines the gamepad move sensiblity.
  44902. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44903. */
  44904. gamepadMoveSensibility: number;
  44905. private _yAxisScale;
  44906. /**
  44907. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44908. */
  44909. get invertYAxis(): boolean;
  44910. set invertYAxis(value: boolean);
  44911. private _onGamepadConnectedObserver;
  44912. private _onGamepadDisconnectedObserver;
  44913. private _cameraTransform;
  44914. private _deltaTransform;
  44915. private _vector3;
  44916. private _vector2;
  44917. /**
  44918. * Attach the input controls to a specific dom element to get the input from.
  44919. * @param element Defines the element the controls should be listened from
  44920. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44921. */
  44922. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44923. /**
  44924. * Detach the current controls from the specified dom element.
  44925. * @param element Defines the element to stop listening the inputs from
  44926. */
  44927. detachControl(element: Nullable<HTMLElement>): void;
  44928. /**
  44929. * Update the current camera state depending on the inputs that have been used this frame.
  44930. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44931. */
  44932. checkInputs(): void;
  44933. /**
  44934. * Gets the class name of the current intput.
  44935. * @returns the class name
  44936. */
  44937. getClassName(): string;
  44938. /**
  44939. * Get the friendly name associated with the input class.
  44940. * @returns the input friendly name
  44941. */
  44942. getSimpleName(): string;
  44943. }
  44944. }
  44945. declare module BABYLON {
  44946. /**
  44947. * Defines the potential axis of a Joystick
  44948. */
  44949. export enum JoystickAxis {
  44950. /** X axis */
  44951. X = 0,
  44952. /** Y axis */
  44953. Y = 1,
  44954. /** Z axis */
  44955. Z = 2
  44956. }
  44957. /**
  44958. * Represents the different customization options available
  44959. * for VirtualJoystick
  44960. */
  44961. interface VirtualJoystickCustomizations {
  44962. /**
  44963. * Size of the joystick's puck
  44964. */
  44965. puckSize: number;
  44966. /**
  44967. * Size of the joystick's container
  44968. */
  44969. containerSize: number;
  44970. /**
  44971. * Color of the joystick && puck
  44972. */
  44973. color: string;
  44974. /**
  44975. * Image URL for the joystick's puck
  44976. */
  44977. puckImage?: string;
  44978. /**
  44979. * Image URL for the joystick's container
  44980. */
  44981. containerImage?: string;
  44982. /**
  44983. * Defines the unmoving position of the joystick container
  44984. */
  44985. position?: {
  44986. x: number;
  44987. y: number;
  44988. };
  44989. /**
  44990. * Defines whether or not the joystick container is always visible
  44991. */
  44992. alwaysVisible: boolean;
  44993. /**
  44994. * Defines whether or not to limit the movement of the puck to the joystick's container
  44995. */
  44996. limitToContainer: boolean;
  44997. }
  44998. /**
  44999. * Class used to define virtual joystick (used in touch mode)
  45000. */
  45001. export class VirtualJoystick {
  45002. /**
  45003. * Gets or sets a boolean indicating that left and right values must be inverted
  45004. */
  45005. reverseLeftRight: boolean;
  45006. /**
  45007. * Gets or sets a boolean indicating that up and down values must be inverted
  45008. */
  45009. reverseUpDown: boolean;
  45010. /**
  45011. * Gets the offset value for the position (ie. the change of the position value)
  45012. */
  45013. deltaPosition: Vector3;
  45014. /**
  45015. * Gets a boolean indicating if the virtual joystick was pressed
  45016. */
  45017. pressed: boolean;
  45018. /**
  45019. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45020. */
  45021. static Canvas: Nullable<HTMLCanvasElement>;
  45022. /**
  45023. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  45024. */
  45025. limitToContainer: boolean;
  45026. private static _globalJoystickIndex;
  45027. private static _alwaysVisibleSticks;
  45028. private static vjCanvasContext;
  45029. private static vjCanvasWidth;
  45030. private static vjCanvasHeight;
  45031. private static halfWidth;
  45032. private static _GetDefaultOptions;
  45033. private _action;
  45034. private _axisTargetedByLeftAndRight;
  45035. private _axisTargetedByUpAndDown;
  45036. private _joystickSensibility;
  45037. private _inversedSensibility;
  45038. private _joystickPointerID;
  45039. private _joystickColor;
  45040. private _joystickPointerPos;
  45041. private _joystickPreviousPointerPos;
  45042. private _joystickPointerStartPos;
  45043. private _deltaJoystickVector;
  45044. private _leftJoystick;
  45045. private _touches;
  45046. private _joystickPosition;
  45047. private _alwaysVisible;
  45048. private _puckImage;
  45049. private _containerImage;
  45050. private _joystickPuckSize;
  45051. private _joystickContainerSize;
  45052. private _clearPuckSize;
  45053. private _clearContainerSize;
  45054. private _clearPuckSizeOffset;
  45055. private _clearContainerSizeOffset;
  45056. private _onPointerDownHandlerRef;
  45057. private _onPointerMoveHandlerRef;
  45058. private _onPointerUpHandlerRef;
  45059. private _onResize;
  45060. /**
  45061. * Creates a new virtual joystick
  45062. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45063. * @param customizations Defines the options we want to customize the VirtualJoystick
  45064. */
  45065. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  45066. /**
  45067. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45068. * @param newJoystickSensibility defines the new sensibility
  45069. */
  45070. setJoystickSensibility(newJoystickSensibility: number): void;
  45071. private _onPointerDown;
  45072. private _onPointerMove;
  45073. private _onPointerUp;
  45074. /**
  45075. * Change the color of the virtual joystick
  45076. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45077. */
  45078. setJoystickColor(newColor: string): void;
  45079. /**
  45080. * Size of the joystick's container
  45081. */
  45082. set containerSize(newSize: number);
  45083. get containerSize(): number;
  45084. /**
  45085. * Size of the joystick's puck
  45086. */
  45087. set puckSize(newSize: number);
  45088. get puckSize(): number;
  45089. /**
  45090. * Clears the set position of the joystick
  45091. */
  45092. clearPosition(): void;
  45093. /**
  45094. * Defines whether or not the joystick container is always visible
  45095. */
  45096. set alwaysVisible(value: boolean);
  45097. get alwaysVisible(): boolean;
  45098. /**
  45099. * Sets the constant position of the Joystick container
  45100. * @param x X axis coordinate
  45101. * @param y Y axis coordinate
  45102. */
  45103. setPosition(x: number, y: number): void;
  45104. /**
  45105. * Defines a callback to call when the joystick is touched
  45106. * @param action defines the callback
  45107. */
  45108. setActionOnTouch(action: () => any): void;
  45109. /**
  45110. * Defines which axis you'd like to control for left & right
  45111. * @param axis defines the axis to use
  45112. */
  45113. setAxisForLeftRight(axis: JoystickAxis): void;
  45114. /**
  45115. * Defines which axis you'd like to control for up & down
  45116. * @param axis defines the axis to use
  45117. */
  45118. setAxisForUpDown(axis: JoystickAxis): void;
  45119. /**
  45120. * Clears the canvas from the previous puck / container draw
  45121. */
  45122. private _clearPreviousDraw;
  45123. /**
  45124. * Loads `urlPath` to be used for the container's image
  45125. * @param urlPath defines the urlPath of an image to use
  45126. */
  45127. setContainerImage(urlPath: string): void;
  45128. /**
  45129. * Loads `urlPath` to be used for the puck's image
  45130. * @param urlPath defines the urlPath of an image to use
  45131. */
  45132. setPuckImage(urlPath: string): void;
  45133. /**
  45134. * Draws the Virtual Joystick's container
  45135. */
  45136. private _drawContainer;
  45137. /**
  45138. * Draws the Virtual Joystick's puck
  45139. */
  45140. private _drawPuck;
  45141. private _drawVirtualJoystick;
  45142. /**
  45143. * Release internal HTML canvas
  45144. */
  45145. releaseCanvas(): void;
  45146. }
  45147. }
  45148. declare module BABYLON {
  45149. interface FreeCameraInputsManager {
  45150. /**
  45151. * Add virtual joystick input support to the input manager.
  45152. * @returns the current input manager
  45153. */
  45154. addVirtualJoystick(): FreeCameraInputsManager;
  45155. }
  45156. /**
  45157. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45158. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45159. */
  45160. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45161. /**
  45162. * Defines the camera the input is attached to.
  45163. */
  45164. camera: FreeCamera;
  45165. private _leftjoystick;
  45166. private _rightjoystick;
  45167. /**
  45168. * Gets the left stick of the virtual joystick.
  45169. * @returns The virtual Joystick
  45170. */
  45171. getLeftJoystick(): VirtualJoystick;
  45172. /**
  45173. * Gets the right stick of the virtual joystick.
  45174. * @returns The virtual Joystick
  45175. */
  45176. getRightJoystick(): VirtualJoystick;
  45177. /**
  45178. * Update the current camera state depending on the inputs that have been used this frame.
  45179. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45180. */
  45181. checkInputs(): void;
  45182. /**
  45183. * Attach the input controls to a specific dom element to get the input from.
  45184. * @param element Defines the element the controls should be listened from
  45185. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45186. */
  45187. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45188. /**
  45189. * Detach the current controls from the specified dom element.
  45190. * @param element Defines the element to stop listening the inputs from
  45191. */
  45192. detachControl(element: Nullable<HTMLElement>): void;
  45193. /**
  45194. * Gets the class name of the current intput.
  45195. * @returns the class name
  45196. */
  45197. getClassName(): string;
  45198. /**
  45199. * Get the friendly name associated with the input class.
  45200. * @returns the input friendly name
  45201. */
  45202. getSimpleName(): string;
  45203. }
  45204. }
  45205. declare module BABYLON {
  45206. /**
  45207. * This represents a FPS type of camera controlled by touch.
  45208. * This is like a universal camera minus the Gamepad controls.
  45209. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45210. */
  45211. export class TouchCamera extends FreeCamera {
  45212. /**
  45213. * Defines the touch sensibility for rotation.
  45214. * The higher the faster.
  45215. */
  45216. get touchAngularSensibility(): number;
  45217. set touchAngularSensibility(value: number);
  45218. /**
  45219. * Defines the touch sensibility for move.
  45220. * The higher the faster.
  45221. */
  45222. get touchMoveSensibility(): number;
  45223. set touchMoveSensibility(value: number);
  45224. /**
  45225. * Instantiates a new touch camera.
  45226. * This represents a FPS type of camera controlled by touch.
  45227. * This is like a universal camera minus the Gamepad controls.
  45228. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45229. * @param name Define the name of the camera in the scene
  45230. * @param position Define the start position of the camera in the scene
  45231. * @param scene Define the scene the camera belongs to
  45232. */
  45233. constructor(name: string, position: Vector3, scene: Scene);
  45234. /**
  45235. * Gets the current object class name.
  45236. * @return the class name
  45237. */
  45238. getClassName(): string;
  45239. /** @hidden */
  45240. _setupInputs(): void;
  45241. }
  45242. }
  45243. declare module BABYLON {
  45244. /**
  45245. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45246. * being tilted forward or back and left or right.
  45247. */
  45248. export class DeviceOrientationCamera extends FreeCamera {
  45249. private _initialQuaternion;
  45250. private _quaternionCache;
  45251. private _tmpDragQuaternion;
  45252. private _disablePointerInputWhenUsingDeviceOrientation;
  45253. /**
  45254. * Creates a new device orientation camera
  45255. * @param name The name of the camera
  45256. * @param position The start position camera
  45257. * @param scene The scene the camera belongs to
  45258. */
  45259. constructor(name: string, position: Vector3, scene: Scene);
  45260. /**
  45261. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45262. */
  45263. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45264. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45265. private _dragFactor;
  45266. /**
  45267. * Enabled turning on the y axis when the orientation sensor is active
  45268. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45269. */
  45270. enableHorizontalDragging(dragFactor?: number): void;
  45271. /**
  45272. * Gets the current instance class name ("DeviceOrientationCamera").
  45273. * This helps avoiding instanceof at run time.
  45274. * @returns the class name
  45275. */
  45276. getClassName(): string;
  45277. /**
  45278. * @hidden
  45279. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45280. */
  45281. _checkInputs(): void;
  45282. /**
  45283. * Reset the camera to its default orientation on the specified axis only.
  45284. * @param axis The axis to reset
  45285. */
  45286. resetToCurrentRotation(axis?: Axis): void;
  45287. }
  45288. }
  45289. declare module BABYLON {
  45290. /**
  45291. * Defines supported buttons for XBox360 compatible gamepads
  45292. */
  45293. export enum Xbox360Button {
  45294. /** A */
  45295. A = 0,
  45296. /** B */
  45297. B = 1,
  45298. /** X */
  45299. X = 2,
  45300. /** Y */
  45301. Y = 3,
  45302. /** Left button */
  45303. LB = 4,
  45304. /** Right button */
  45305. RB = 5,
  45306. /** Back */
  45307. Back = 8,
  45308. /** Start */
  45309. Start = 9,
  45310. /** Left stick */
  45311. LeftStick = 10,
  45312. /** Right stick */
  45313. RightStick = 11
  45314. }
  45315. /** Defines values for XBox360 DPad */
  45316. export enum Xbox360Dpad {
  45317. /** Up */
  45318. Up = 12,
  45319. /** Down */
  45320. Down = 13,
  45321. /** Left */
  45322. Left = 14,
  45323. /** Right */
  45324. Right = 15
  45325. }
  45326. /**
  45327. * Defines a XBox360 gamepad
  45328. */
  45329. export class Xbox360Pad extends Gamepad {
  45330. private _leftTrigger;
  45331. private _rightTrigger;
  45332. private _onlefttriggerchanged;
  45333. private _onrighttriggerchanged;
  45334. private _onbuttondown;
  45335. private _onbuttonup;
  45336. private _ondpaddown;
  45337. private _ondpadup;
  45338. /** Observable raised when a button is pressed */
  45339. onButtonDownObservable: Observable<Xbox360Button>;
  45340. /** Observable raised when a button is released */
  45341. onButtonUpObservable: Observable<Xbox360Button>;
  45342. /** Observable raised when a pad is pressed */
  45343. onPadDownObservable: Observable<Xbox360Dpad>;
  45344. /** Observable raised when a pad is released */
  45345. onPadUpObservable: Observable<Xbox360Dpad>;
  45346. private _buttonA;
  45347. private _buttonB;
  45348. private _buttonX;
  45349. private _buttonY;
  45350. private _buttonBack;
  45351. private _buttonStart;
  45352. private _buttonLB;
  45353. private _buttonRB;
  45354. private _buttonLeftStick;
  45355. private _buttonRightStick;
  45356. private _dPadUp;
  45357. private _dPadDown;
  45358. private _dPadLeft;
  45359. private _dPadRight;
  45360. private _isXboxOnePad;
  45361. /**
  45362. * Creates a new XBox360 gamepad object
  45363. * @param id defines the id of this gamepad
  45364. * @param index defines its index
  45365. * @param gamepad defines the internal HTML gamepad object
  45366. * @param xboxOne defines if it is a XBox One gamepad
  45367. */
  45368. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45369. /**
  45370. * Defines the callback to call when left trigger is pressed
  45371. * @param callback defines the callback to use
  45372. */
  45373. onlefttriggerchanged(callback: (value: number) => void): void;
  45374. /**
  45375. * Defines the callback to call when right trigger is pressed
  45376. * @param callback defines the callback to use
  45377. */
  45378. onrighttriggerchanged(callback: (value: number) => void): void;
  45379. /**
  45380. * Gets the left trigger value
  45381. */
  45382. get leftTrigger(): number;
  45383. /**
  45384. * Sets the left trigger value
  45385. */
  45386. set leftTrigger(newValue: number);
  45387. /**
  45388. * Gets the right trigger value
  45389. */
  45390. get rightTrigger(): number;
  45391. /**
  45392. * Sets the right trigger value
  45393. */
  45394. set rightTrigger(newValue: number);
  45395. /**
  45396. * Defines the callback to call when a button is pressed
  45397. * @param callback defines the callback to use
  45398. */
  45399. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45400. /**
  45401. * Defines the callback to call when a button is released
  45402. * @param callback defines the callback to use
  45403. */
  45404. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45405. /**
  45406. * Defines the callback to call when a pad is pressed
  45407. * @param callback defines the callback to use
  45408. */
  45409. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45410. /**
  45411. * Defines the callback to call when a pad is released
  45412. * @param callback defines the callback to use
  45413. */
  45414. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45415. private _setButtonValue;
  45416. private _setDPadValue;
  45417. /**
  45418. * Gets the value of the `A` button
  45419. */
  45420. get buttonA(): number;
  45421. /**
  45422. * Sets the value of the `A` button
  45423. */
  45424. set buttonA(value: number);
  45425. /**
  45426. * Gets the value of the `B` button
  45427. */
  45428. get buttonB(): number;
  45429. /**
  45430. * Sets the value of the `B` button
  45431. */
  45432. set buttonB(value: number);
  45433. /**
  45434. * Gets the value of the `X` button
  45435. */
  45436. get buttonX(): number;
  45437. /**
  45438. * Sets the value of the `X` button
  45439. */
  45440. set buttonX(value: number);
  45441. /**
  45442. * Gets the value of the `Y` button
  45443. */
  45444. get buttonY(): number;
  45445. /**
  45446. * Sets the value of the `Y` button
  45447. */
  45448. set buttonY(value: number);
  45449. /**
  45450. * Gets the value of the `Start` button
  45451. */
  45452. get buttonStart(): number;
  45453. /**
  45454. * Sets the value of the `Start` button
  45455. */
  45456. set buttonStart(value: number);
  45457. /**
  45458. * Gets the value of the `Back` button
  45459. */
  45460. get buttonBack(): number;
  45461. /**
  45462. * Sets the value of the `Back` button
  45463. */
  45464. set buttonBack(value: number);
  45465. /**
  45466. * Gets the value of the `Left` button
  45467. */
  45468. get buttonLB(): number;
  45469. /**
  45470. * Sets the value of the `Left` button
  45471. */
  45472. set buttonLB(value: number);
  45473. /**
  45474. * Gets the value of the `Right` button
  45475. */
  45476. get buttonRB(): number;
  45477. /**
  45478. * Sets the value of the `Right` button
  45479. */
  45480. set buttonRB(value: number);
  45481. /**
  45482. * Gets the value of the Left joystick
  45483. */
  45484. get buttonLeftStick(): number;
  45485. /**
  45486. * Sets the value of the Left joystick
  45487. */
  45488. set buttonLeftStick(value: number);
  45489. /**
  45490. * Gets the value of the Right joystick
  45491. */
  45492. get buttonRightStick(): number;
  45493. /**
  45494. * Sets the value of the Right joystick
  45495. */
  45496. set buttonRightStick(value: number);
  45497. /**
  45498. * Gets the value of D-pad up
  45499. */
  45500. get dPadUp(): number;
  45501. /**
  45502. * Sets the value of D-pad up
  45503. */
  45504. set dPadUp(value: number);
  45505. /**
  45506. * Gets the value of D-pad down
  45507. */
  45508. get dPadDown(): number;
  45509. /**
  45510. * Sets the value of D-pad down
  45511. */
  45512. set dPadDown(value: number);
  45513. /**
  45514. * Gets the value of D-pad left
  45515. */
  45516. get dPadLeft(): number;
  45517. /**
  45518. * Sets the value of D-pad left
  45519. */
  45520. set dPadLeft(value: number);
  45521. /**
  45522. * Gets the value of D-pad right
  45523. */
  45524. get dPadRight(): number;
  45525. /**
  45526. * Sets the value of D-pad right
  45527. */
  45528. set dPadRight(value: number);
  45529. /**
  45530. * Force the gamepad to synchronize with device values
  45531. */
  45532. update(): void;
  45533. /**
  45534. * Disposes the gamepad
  45535. */
  45536. dispose(): void;
  45537. }
  45538. }
  45539. declare module BABYLON {
  45540. /**
  45541. * Defines supported buttons for DualShock compatible gamepads
  45542. */
  45543. export enum DualShockButton {
  45544. /** Cross */
  45545. Cross = 0,
  45546. /** Circle */
  45547. Circle = 1,
  45548. /** Square */
  45549. Square = 2,
  45550. /** Triangle */
  45551. Triangle = 3,
  45552. /** L1 */
  45553. L1 = 4,
  45554. /** R1 */
  45555. R1 = 5,
  45556. /** Share */
  45557. Share = 8,
  45558. /** Options */
  45559. Options = 9,
  45560. /** Left stick */
  45561. LeftStick = 10,
  45562. /** Right stick */
  45563. RightStick = 11
  45564. }
  45565. /** Defines values for DualShock DPad */
  45566. export enum DualShockDpad {
  45567. /** Up */
  45568. Up = 12,
  45569. /** Down */
  45570. Down = 13,
  45571. /** Left */
  45572. Left = 14,
  45573. /** Right */
  45574. Right = 15
  45575. }
  45576. /**
  45577. * Defines a DualShock gamepad
  45578. */
  45579. export class DualShockPad extends Gamepad {
  45580. private _leftTrigger;
  45581. private _rightTrigger;
  45582. private _onlefttriggerchanged;
  45583. private _onrighttriggerchanged;
  45584. private _onbuttondown;
  45585. private _onbuttonup;
  45586. private _ondpaddown;
  45587. private _ondpadup;
  45588. /** Observable raised when a button is pressed */
  45589. onButtonDownObservable: Observable<DualShockButton>;
  45590. /** Observable raised when a button is released */
  45591. onButtonUpObservable: Observable<DualShockButton>;
  45592. /** Observable raised when a pad is pressed */
  45593. onPadDownObservable: Observable<DualShockDpad>;
  45594. /** Observable raised when a pad is released */
  45595. onPadUpObservable: Observable<DualShockDpad>;
  45596. private _buttonCross;
  45597. private _buttonCircle;
  45598. private _buttonSquare;
  45599. private _buttonTriangle;
  45600. private _buttonShare;
  45601. private _buttonOptions;
  45602. private _buttonL1;
  45603. private _buttonR1;
  45604. private _buttonLeftStick;
  45605. private _buttonRightStick;
  45606. private _dPadUp;
  45607. private _dPadDown;
  45608. private _dPadLeft;
  45609. private _dPadRight;
  45610. /**
  45611. * Creates a new DualShock gamepad object
  45612. * @param id defines the id of this gamepad
  45613. * @param index defines its index
  45614. * @param gamepad defines the internal HTML gamepad object
  45615. */
  45616. constructor(id: string, index: number, gamepad: any);
  45617. /**
  45618. * Defines the callback to call when left trigger is pressed
  45619. * @param callback defines the callback to use
  45620. */
  45621. onlefttriggerchanged(callback: (value: number) => void): void;
  45622. /**
  45623. * Defines the callback to call when right trigger is pressed
  45624. * @param callback defines the callback to use
  45625. */
  45626. onrighttriggerchanged(callback: (value: number) => void): void;
  45627. /**
  45628. * Gets the left trigger value
  45629. */
  45630. get leftTrigger(): number;
  45631. /**
  45632. * Sets the left trigger value
  45633. */
  45634. set leftTrigger(newValue: number);
  45635. /**
  45636. * Gets the right trigger value
  45637. */
  45638. get rightTrigger(): number;
  45639. /**
  45640. * Sets the right trigger value
  45641. */
  45642. set rightTrigger(newValue: number);
  45643. /**
  45644. * Defines the callback to call when a button is pressed
  45645. * @param callback defines the callback to use
  45646. */
  45647. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  45648. /**
  45649. * Defines the callback to call when a button is released
  45650. * @param callback defines the callback to use
  45651. */
  45652. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  45653. /**
  45654. * Defines the callback to call when a pad is pressed
  45655. * @param callback defines the callback to use
  45656. */
  45657. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  45658. /**
  45659. * Defines the callback to call when a pad is released
  45660. * @param callback defines the callback to use
  45661. */
  45662. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  45663. private _setButtonValue;
  45664. private _setDPadValue;
  45665. /**
  45666. * Gets the value of the `Cross` button
  45667. */
  45668. get buttonCross(): number;
  45669. /**
  45670. * Sets the value of the `Cross` button
  45671. */
  45672. set buttonCross(value: number);
  45673. /**
  45674. * Gets the value of the `Circle` button
  45675. */
  45676. get buttonCircle(): number;
  45677. /**
  45678. * Sets the value of the `Circle` button
  45679. */
  45680. set buttonCircle(value: number);
  45681. /**
  45682. * Gets the value of the `Square` button
  45683. */
  45684. get buttonSquare(): number;
  45685. /**
  45686. * Sets the value of the `Square` button
  45687. */
  45688. set buttonSquare(value: number);
  45689. /**
  45690. * Gets the value of the `Triangle` button
  45691. */
  45692. get buttonTriangle(): number;
  45693. /**
  45694. * Sets the value of the `Triangle` button
  45695. */
  45696. set buttonTriangle(value: number);
  45697. /**
  45698. * Gets the value of the `Options` button
  45699. */
  45700. get buttonOptions(): number;
  45701. /**
  45702. * Sets the value of the `Options` button
  45703. */
  45704. set buttonOptions(value: number);
  45705. /**
  45706. * Gets the value of the `Share` button
  45707. */
  45708. get buttonShare(): number;
  45709. /**
  45710. * Sets the value of the `Share` button
  45711. */
  45712. set buttonShare(value: number);
  45713. /**
  45714. * Gets the value of the `L1` button
  45715. */
  45716. get buttonL1(): number;
  45717. /**
  45718. * Sets the value of the `L1` button
  45719. */
  45720. set buttonL1(value: number);
  45721. /**
  45722. * Gets the value of the `R1` button
  45723. */
  45724. get buttonR1(): number;
  45725. /**
  45726. * Sets the value of the `R1` button
  45727. */
  45728. set buttonR1(value: number);
  45729. /**
  45730. * Gets the value of the Left joystick
  45731. */
  45732. get buttonLeftStick(): number;
  45733. /**
  45734. * Sets the value of the Left joystick
  45735. */
  45736. set buttonLeftStick(value: number);
  45737. /**
  45738. * Gets the value of the Right joystick
  45739. */
  45740. get buttonRightStick(): number;
  45741. /**
  45742. * Sets the value of the Right joystick
  45743. */
  45744. set buttonRightStick(value: number);
  45745. /**
  45746. * Gets the value of D-pad up
  45747. */
  45748. get dPadUp(): number;
  45749. /**
  45750. * Sets the value of D-pad up
  45751. */
  45752. set dPadUp(value: number);
  45753. /**
  45754. * Gets the value of D-pad down
  45755. */
  45756. get dPadDown(): number;
  45757. /**
  45758. * Sets the value of D-pad down
  45759. */
  45760. set dPadDown(value: number);
  45761. /**
  45762. * Gets the value of D-pad left
  45763. */
  45764. get dPadLeft(): number;
  45765. /**
  45766. * Sets the value of D-pad left
  45767. */
  45768. set dPadLeft(value: number);
  45769. /**
  45770. * Gets the value of D-pad right
  45771. */
  45772. get dPadRight(): number;
  45773. /**
  45774. * Sets the value of D-pad right
  45775. */
  45776. set dPadRight(value: number);
  45777. /**
  45778. * Force the gamepad to synchronize with device values
  45779. */
  45780. update(): void;
  45781. /**
  45782. * Disposes the gamepad
  45783. */
  45784. dispose(): void;
  45785. }
  45786. }
  45787. declare module BABYLON {
  45788. /**
  45789. * Manager for handling gamepads
  45790. */
  45791. export class GamepadManager {
  45792. private _scene?;
  45793. private _babylonGamepads;
  45794. private _oneGamepadConnected;
  45795. /** @hidden */
  45796. _isMonitoring: boolean;
  45797. private _gamepadEventSupported;
  45798. private _gamepadSupport?;
  45799. /**
  45800. * observable to be triggered when the gamepad controller has been connected
  45801. */
  45802. onGamepadConnectedObservable: Observable<Gamepad>;
  45803. /**
  45804. * observable to be triggered when the gamepad controller has been disconnected
  45805. */
  45806. onGamepadDisconnectedObservable: Observable<Gamepad>;
  45807. private _onGamepadConnectedEvent;
  45808. private _onGamepadDisconnectedEvent;
  45809. /**
  45810. * Initializes the gamepad manager
  45811. * @param _scene BabylonJS scene
  45812. */
  45813. constructor(_scene?: Scene | undefined);
  45814. /**
  45815. * The gamepads in the game pad manager
  45816. */
  45817. get gamepads(): Gamepad[];
  45818. /**
  45819. * Get the gamepad controllers based on type
  45820. * @param type The type of gamepad controller
  45821. * @returns Nullable gamepad
  45822. */
  45823. getGamepadByType(type?: number): Nullable<Gamepad>;
  45824. /**
  45825. * Disposes the gamepad manager
  45826. */
  45827. dispose(): void;
  45828. private _addNewGamepad;
  45829. private _startMonitoringGamepads;
  45830. private _stopMonitoringGamepads;
  45831. /** @hidden */
  45832. _checkGamepadsStatus(): void;
  45833. private _updateGamepadObjects;
  45834. }
  45835. }
  45836. declare module BABYLON {
  45837. interface Scene {
  45838. /** @hidden */
  45839. _gamepadManager: Nullable<GamepadManager>;
  45840. /**
  45841. * Gets the gamepad manager associated with the scene
  45842. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  45843. */
  45844. gamepadManager: GamepadManager;
  45845. }
  45846. /**
  45847. * Interface representing a free camera inputs manager
  45848. */
  45849. interface FreeCameraInputsManager {
  45850. /**
  45851. * Adds gamepad input support to the FreeCameraInputsManager.
  45852. * @returns the FreeCameraInputsManager
  45853. */
  45854. addGamepad(): FreeCameraInputsManager;
  45855. }
  45856. /**
  45857. * Interface representing an arc rotate camera inputs manager
  45858. */
  45859. interface ArcRotateCameraInputsManager {
  45860. /**
  45861. * Adds gamepad input support to the ArcRotateCamera InputManager.
  45862. * @returns the camera inputs manager
  45863. */
  45864. addGamepad(): ArcRotateCameraInputsManager;
  45865. }
  45866. /**
  45867. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  45868. */
  45869. export class GamepadSystemSceneComponent implements ISceneComponent {
  45870. /**
  45871. * The component name helpfull to identify the component in the list of scene components.
  45872. */
  45873. readonly name: string;
  45874. /**
  45875. * The scene the component belongs to.
  45876. */
  45877. scene: Scene;
  45878. /**
  45879. * Creates a new instance of the component for the given scene
  45880. * @param scene Defines the scene to register the component in
  45881. */
  45882. constructor(scene: Scene);
  45883. /**
  45884. * Registers the component in a given scene
  45885. */
  45886. register(): void;
  45887. /**
  45888. * Rebuilds the elements related to this component in case of
  45889. * context lost for instance.
  45890. */
  45891. rebuild(): void;
  45892. /**
  45893. * Disposes the component and the associated ressources
  45894. */
  45895. dispose(): void;
  45896. private _beforeCameraUpdate;
  45897. }
  45898. }
  45899. declare module BABYLON {
  45900. /**
  45901. * 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,
  45902. * which still works and will still be found in many Playgrounds.
  45903. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45904. */
  45905. export class UniversalCamera extends TouchCamera {
  45906. /**
  45907. * Defines the gamepad rotation sensiblity.
  45908. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45909. */
  45910. get gamepadAngularSensibility(): number;
  45911. set gamepadAngularSensibility(value: number);
  45912. /**
  45913. * Defines the gamepad move sensiblity.
  45914. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45915. */
  45916. get gamepadMoveSensibility(): number;
  45917. set gamepadMoveSensibility(value: number);
  45918. /**
  45919. * 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,
  45920. * which still works and will still be found in many Playgrounds.
  45921. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45922. * @param name Define the name of the camera in the scene
  45923. * @param position Define the start position of the camera in the scene
  45924. * @param scene Define the scene the camera belongs to
  45925. */
  45926. constructor(name: string, position: Vector3, scene: Scene);
  45927. /**
  45928. * Gets the current object class name.
  45929. * @return the class name
  45930. */
  45931. getClassName(): string;
  45932. }
  45933. }
  45934. declare module BABYLON {
  45935. /**
  45936. * This represents a FPS type of camera. This is only here for back compat purpose.
  45937. * Please use the UniversalCamera instead as both are identical.
  45938. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45939. */
  45940. export class GamepadCamera extends UniversalCamera {
  45941. /**
  45942. * Instantiates a new Gamepad Camera
  45943. * This represents a FPS type of camera. This is only here for back compat purpose.
  45944. * Please use the UniversalCamera instead as both are identical.
  45945. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45946. * @param name Define the name of the camera in the scene
  45947. * @param position Define the start position of the camera in the scene
  45948. * @param scene Define the scene the camera belongs to
  45949. */
  45950. constructor(name: string, position: Vector3, scene: Scene);
  45951. /**
  45952. * Gets the current object class name.
  45953. * @return the class name
  45954. */
  45955. getClassName(): string;
  45956. }
  45957. }
  45958. declare module BABYLON {
  45959. /** @hidden */
  45960. export var passPixelShader: {
  45961. name: string;
  45962. shader: string;
  45963. };
  45964. }
  45965. declare module BABYLON {
  45966. /** @hidden */
  45967. export var passCubePixelShader: {
  45968. name: string;
  45969. shader: string;
  45970. };
  45971. }
  45972. declare module BABYLON {
  45973. /**
  45974. * PassPostProcess which produces an output the same as it's input
  45975. */
  45976. export class PassPostProcess extends PostProcess {
  45977. /**
  45978. * Gets a string identifying the name of the class
  45979. * @returns "PassPostProcess" string
  45980. */
  45981. getClassName(): string;
  45982. /**
  45983. * Creates the PassPostProcess
  45984. * @param name The name of the effect.
  45985. * @param options The required width/height ratio to downsize to before computing the render pass.
  45986. * @param camera The camera to apply the render pass to.
  45987. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45988. * @param engine The engine which the post process will be applied. (default: current engine)
  45989. * @param reusable If the post process can be reused on the same frame. (default: false)
  45990. * @param textureType The type of texture to be used when performing the post processing.
  45991. * @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)
  45992. */
  45993. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45994. /** @hidden */
  45995. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  45996. }
  45997. /**
  45998. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  45999. */
  46000. export class PassCubePostProcess extends PostProcess {
  46001. private _face;
  46002. /**
  46003. * Gets or sets the cube face to display.
  46004. * * 0 is +X
  46005. * * 1 is -X
  46006. * * 2 is +Y
  46007. * * 3 is -Y
  46008. * * 4 is +Z
  46009. * * 5 is -Z
  46010. */
  46011. get face(): number;
  46012. set face(value: number);
  46013. /**
  46014. * Gets a string identifying the name of the class
  46015. * @returns "PassCubePostProcess" string
  46016. */
  46017. getClassName(): string;
  46018. /**
  46019. * Creates the PassCubePostProcess
  46020. * @param name The name of the effect.
  46021. * @param options The required width/height ratio to downsize to before computing the render pass.
  46022. * @param camera The camera to apply the render pass to.
  46023. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46024. * @param engine The engine which the post process will be applied. (default: current engine)
  46025. * @param reusable If the post process can be reused on the same frame. (default: false)
  46026. * @param textureType The type of texture to be used when performing the post processing.
  46027. * @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)
  46028. */
  46029. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46030. /** @hidden */
  46031. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  46032. }
  46033. }
  46034. declare module BABYLON {
  46035. /** @hidden */
  46036. export var anaglyphPixelShader: {
  46037. name: string;
  46038. shader: string;
  46039. };
  46040. }
  46041. declare module BABYLON {
  46042. /**
  46043. * Postprocess used to generate anaglyphic rendering
  46044. */
  46045. export class AnaglyphPostProcess extends PostProcess {
  46046. private _passedProcess;
  46047. /**
  46048. * Gets a string identifying the name of the class
  46049. * @returns "AnaglyphPostProcess" string
  46050. */
  46051. getClassName(): string;
  46052. /**
  46053. * Creates a new AnaglyphPostProcess
  46054. * @param name defines postprocess name
  46055. * @param options defines creation options or target ratio scale
  46056. * @param rigCameras defines cameras using this postprocess
  46057. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46058. * @param engine defines hosting engine
  46059. * @param reusable defines if the postprocess will be reused multiple times per frame
  46060. */
  46061. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46062. }
  46063. }
  46064. declare module BABYLON {
  46065. /**
  46066. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46067. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46068. */
  46069. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46070. /**
  46071. * Creates a new AnaglyphArcRotateCamera
  46072. * @param name defines camera name
  46073. * @param alpha defines alpha angle (in radians)
  46074. * @param beta defines beta angle (in radians)
  46075. * @param radius defines radius
  46076. * @param target defines camera target
  46077. * @param interaxialDistance defines distance between each color axis
  46078. * @param scene defines the hosting scene
  46079. */
  46080. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46081. /**
  46082. * Gets camera class name
  46083. * @returns AnaglyphArcRotateCamera
  46084. */
  46085. getClassName(): string;
  46086. }
  46087. }
  46088. declare module BABYLON {
  46089. /**
  46090. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46091. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46092. */
  46093. export class AnaglyphFreeCamera extends FreeCamera {
  46094. /**
  46095. * Creates a new AnaglyphFreeCamera
  46096. * @param name defines camera name
  46097. * @param position defines initial position
  46098. * @param interaxialDistance defines distance between each color axis
  46099. * @param scene defines the hosting scene
  46100. */
  46101. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46102. /**
  46103. * Gets camera class name
  46104. * @returns AnaglyphFreeCamera
  46105. */
  46106. getClassName(): string;
  46107. }
  46108. }
  46109. declare module BABYLON {
  46110. /**
  46111. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46112. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46113. */
  46114. export class AnaglyphGamepadCamera extends GamepadCamera {
  46115. /**
  46116. * Creates a new AnaglyphGamepadCamera
  46117. * @param name defines camera name
  46118. * @param position defines initial position
  46119. * @param interaxialDistance defines distance between each color axis
  46120. * @param scene defines the hosting scene
  46121. */
  46122. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46123. /**
  46124. * Gets camera class name
  46125. * @returns AnaglyphGamepadCamera
  46126. */
  46127. getClassName(): string;
  46128. }
  46129. }
  46130. declare module BABYLON {
  46131. /**
  46132. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46133. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46134. */
  46135. export class AnaglyphUniversalCamera extends UniversalCamera {
  46136. /**
  46137. * Creates a new AnaglyphUniversalCamera
  46138. * @param name defines camera name
  46139. * @param position defines initial position
  46140. * @param interaxialDistance defines distance between each color axis
  46141. * @param scene defines the hosting scene
  46142. */
  46143. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46144. /**
  46145. * Gets camera class name
  46146. * @returns AnaglyphUniversalCamera
  46147. */
  46148. getClassName(): string;
  46149. }
  46150. }
  46151. declare module BABYLON {
  46152. /**
  46153. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46154. * @see https://doc.babylonjs.com/features/cameras
  46155. */
  46156. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46157. /**
  46158. * Creates a new StereoscopicArcRotateCamera
  46159. * @param name defines camera name
  46160. * @param alpha defines alpha angle (in radians)
  46161. * @param beta defines beta angle (in radians)
  46162. * @param radius defines radius
  46163. * @param target defines camera target
  46164. * @param interaxialDistance defines distance between each color axis
  46165. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46166. * @param scene defines the hosting scene
  46167. */
  46168. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46169. /**
  46170. * Gets camera class name
  46171. * @returns StereoscopicArcRotateCamera
  46172. */
  46173. getClassName(): string;
  46174. }
  46175. }
  46176. declare module BABYLON {
  46177. /**
  46178. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46179. * @see https://doc.babylonjs.com/features/cameras
  46180. */
  46181. export class StereoscopicFreeCamera extends FreeCamera {
  46182. /**
  46183. * Creates a new StereoscopicFreeCamera
  46184. * @param name defines camera name
  46185. * @param position defines initial position
  46186. * @param interaxialDistance defines distance between each color axis
  46187. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46188. * @param scene defines the hosting scene
  46189. */
  46190. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46191. /**
  46192. * Gets camera class name
  46193. * @returns StereoscopicFreeCamera
  46194. */
  46195. getClassName(): string;
  46196. }
  46197. }
  46198. declare module BABYLON {
  46199. /**
  46200. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46201. * @see https://doc.babylonjs.com/features/cameras
  46202. */
  46203. export class StereoscopicGamepadCamera extends GamepadCamera {
  46204. /**
  46205. * Creates a new StereoscopicGamepadCamera
  46206. * @param name defines camera name
  46207. * @param position defines initial position
  46208. * @param interaxialDistance defines distance between each color axis
  46209. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46210. * @param scene defines the hosting scene
  46211. */
  46212. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46213. /**
  46214. * Gets camera class name
  46215. * @returns StereoscopicGamepadCamera
  46216. */
  46217. getClassName(): string;
  46218. }
  46219. }
  46220. declare module BABYLON {
  46221. /**
  46222. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46223. * @see https://doc.babylonjs.com/features/cameras
  46224. */
  46225. export class StereoscopicUniversalCamera extends UniversalCamera {
  46226. /**
  46227. * Creates a new StereoscopicUniversalCamera
  46228. * @param name defines camera name
  46229. * @param position defines initial position
  46230. * @param interaxialDistance defines distance between each color axis
  46231. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46232. * @param scene defines the hosting scene
  46233. */
  46234. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46235. /**
  46236. * Gets camera class name
  46237. * @returns StereoscopicUniversalCamera
  46238. */
  46239. getClassName(): string;
  46240. }
  46241. }
  46242. declare module BABYLON {
  46243. /**
  46244. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46245. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46246. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46247. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46248. */
  46249. export class VirtualJoysticksCamera extends FreeCamera {
  46250. /**
  46251. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46252. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46253. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46254. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46255. * @param name Define the name of the camera in the scene
  46256. * @param position Define the start position of the camera in the scene
  46257. * @param scene Define the scene the camera belongs to
  46258. */
  46259. constructor(name: string, position: Vector3, scene: Scene);
  46260. /**
  46261. * Gets the current object class name.
  46262. * @return the class name
  46263. */
  46264. getClassName(): string;
  46265. }
  46266. }
  46267. declare module BABYLON {
  46268. /**
  46269. * This represents all the required metrics to create a VR camera.
  46270. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46271. */
  46272. export class VRCameraMetrics {
  46273. /**
  46274. * Define the horizontal resolution off the screen.
  46275. */
  46276. hResolution: number;
  46277. /**
  46278. * Define the vertical resolution off the screen.
  46279. */
  46280. vResolution: number;
  46281. /**
  46282. * Define the horizontal screen size.
  46283. */
  46284. hScreenSize: number;
  46285. /**
  46286. * Define the vertical screen size.
  46287. */
  46288. vScreenSize: number;
  46289. /**
  46290. * Define the vertical screen center position.
  46291. */
  46292. vScreenCenter: number;
  46293. /**
  46294. * Define the distance of the eyes to the screen.
  46295. */
  46296. eyeToScreenDistance: number;
  46297. /**
  46298. * Define the distance between both lenses
  46299. */
  46300. lensSeparationDistance: number;
  46301. /**
  46302. * Define the distance between both viewer's eyes.
  46303. */
  46304. interpupillaryDistance: number;
  46305. /**
  46306. * Define the distortion factor of the VR postprocess.
  46307. * Please, touch with care.
  46308. */
  46309. distortionK: number[];
  46310. /**
  46311. * Define the chromatic aberration correction factors for the VR post process.
  46312. */
  46313. chromaAbCorrection: number[];
  46314. /**
  46315. * Define the scale factor of the post process.
  46316. * The smaller the better but the slower.
  46317. */
  46318. postProcessScaleFactor: number;
  46319. /**
  46320. * Define an offset for the lens center.
  46321. */
  46322. lensCenterOffset: number;
  46323. /**
  46324. * Define if the current vr camera should compensate the distortion of the lense or not.
  46325. */
  46326. compensateDistortion: boolean;
  46327. /**
  46328. * Defines if multiview should be enabled when rendering (Default: false)
  46329. */
  46330. multiviewEnabled: boolean;
  46331. /**
  46332. * Gets the rendering aspect ratio based on the provided resolutions.
  46333. */
  46334. get aspectRatio(): number;
  46335. /**
  46336. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46337. */
  46338. get aspectRatioFov(): number;
  46339. /**
  46340. * @hidden
  46341. */
  46342. get leftHMatrix(): Matrix;
  46343. /**
  46344. * @hidden
  46345. */
  46346. get rightHMatrix(): Matrix;
  46347. /**
  46348. * @hidden
  46349. */
  46350. get leftPreViewMatrix(): Matrix;
  46351. /**
  46352. * @hidden
  46353. */
  46354. get rightPreViewMatrix(): Matrix;
  46355. /**
  46356. * Get the default VRMetrics based on the most generic setup.
  46357. * @returns the default vr metrics
  46358. */
  46359. static GetDefault(): VRCameraMetrics;
  46360. }
  46361. }
  46362. declare module BABYLON {
  46363. /** @hidden */
  46364. export var vrDistortionCorrectionPixelShader: {
  46365. name: string;
  46366. shader: string;
  46367. };
  46368. }
  46369. declare module BABYLON {
  46370. /**
  46371. * VRDistortionCorrectionPostProcess used for mobile VR
  46372. */
  46373. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46374. private _isRightEye;
  46375. private _distortionFactors;
  46376. private _postProcessScaleFactor;
  46377. private _lensCenterOffset;
  46378. private _scaleIn;
  46379. private _scaleFactor;
  46380. private _lensCenter;
  46381. /**
  46382. * Gets a string identifying the name of the class
  46383. * @returns "VRDistortionCorrectionPostProcess" string
  46384. */
  46385. getClassName(): string;
  46386. /**
  46387. * Initializes the VRDistortionCorrectionPostProcess
  46388. * @param name The name of the effect.
  46389. * @param camera The camera to apply the render pass to.
  46390. * @param isRightEye If this is for the right eye distortion
  46391. * @param vrMetrics All the required metrics for the VR camera
  46392. */
  46393. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46394. }
  46395. }
  46396. declare module BABYLON {
  46397. /**
  46398. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46399. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46400. */
  46401. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46402. /**
  46403. * Creates a new VRDeviceOrientationArcRotateCamera
  46404. * @param name defines camera name
  46405. * @param alpha defines the camera rotation along the logitudinal axis
  46406. * @param beta defines the camera rotation along the latitudinal axis
  46407. * @param radius defines the camera distance from its target
  46408. * @param target defines the camera target
  46409. * @param scene defines the scene the camera belongs to
  46410. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46411. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46412. */
  46413. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46414. /**
  46415. * Gets camera class name
  46416. * @returns VRDeviceOrientationArcRotateCamera
  46417. */
  46418. getClassName(): string;
  46419. }
  46420. }
  46421. declare module BABYLON {
  46422. /**
  46423. * Camera used to simulate VR rendering (based on FreeCamera)
  46424. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46425. */
  46426. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  46427. /**
  46428. * Creates a new VRDeviceOrientationFreeCamera
  46429. * @param name defines camera name
  46430. * @param position defines the start position of the camera
  46431. * @param scene defines the scene the camera belongs to
  46432. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46433. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46434. */
  46435. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46436. /**
  46437. * Gets camera class name
  46438. * @returns VRDeviceOrientationFreeCamera
  46439. */
  46440. getClassName(): string;
  46441. }
  46442. }
  46443. declare module BABYLON {
  46444. /**
  46445. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  46446. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46447. */
  46448. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  46449. /**
  46450. * Creates a new VRDeviceOrientationGamepadCamera
  46451. * @param name defines camera name
  46452. * @param position defines the start position of the camera
  46453. * @param scene defines the scene the camera belongs to
  46454. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46455. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46456. */
  46457. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46458. /**
  46459. * Gets camera class name
  46460. * @returns VRDeviceOrientationGamepadCamera
  46461. */
  46462. getClassName(): string;
  46463. }
  46464. }
  46465. declare module BABYLON {
  46466. /**
  46467. * A class extending Texture allowing drawing on a texture
  46468. * @see https://doc.babylonjs.com/how_to/dynamictexture
  46469. */
  46470. export class DynamicTexture extends Texture {
  46471. private _generateMipMaps;
  46472. private _canvas;
  46473. private _context;
  46474. /**
  46475. * Creates a DynamicTexture
  46476. * @param name defines the name of the texture
  46477. * @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
  46478. * @param scene defines the scene where you want the texture
  46479. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46480. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  46481. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  46482. */
  46483. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46484. /**
  46485. * Get the current class name of the texture useful for serialization or dynamic coding.
  46486. * @returns "DynamicTexture"
  46487. */
  46488. getClassName(): string;
  46489. /**
  46490. * Gets the current state of canRescale
  46491. */
  46492. get canRescale(): boolean;
  46493. private _recreate;
  46494. /**
  46495. * Scales the texture
  46496. * @param ratio the scale factor to apply to both width and height
  46497. */
  46498. scale(ratio: number): void;
  46499. /**
  46500. * Resizes the texture
  46501. * @param width the new width
  46502. * @param height the new height
  46503. */
  46504. scaleTo(width: number, height: number): void;
  46505. /**
  46506. * Gets the context of the canvas used by the texture
  46507. * @returns the canvas context of the dynamic texture
  46508. */
  46509. getContext(): CanvasRenderingContext2D;
  46510. /**
  46511. * Clears the texture
  46512. */
  46513. clear(): void;
  46514. /**
  46515. * Updates the texture
  46516. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46517. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46518. */
  46519. update(invertY?: boolean, premulAlpha?: boolean): void;
  46520. /**
  46521. * Draws text onto the texture
  46522. * @param text defines the text to be drawn
  46523. * @param x defines the placement of the text from the left
  46524. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46525. * @param font defines the font to be used with font-style, font-size, font-name
  46526. * @param color defines the color used for the text
  46527. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46528. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46529. * @param update defines whether texture is immediately update (default is true)
  46530. */
  46531. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  46532. /**
  46533. * Clones the texture
  46534. * @returns the clone of the texture.
  46535. */
  46536. clone(): DynamicTexture;
  46537. /**
  46538. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46539. * @returns a serialized dynamic texture object
  46540. */
  46541. serialize(): any;
  46542. private _IsCanvasElement;
  46543. /** @hidden */
  46544. _rebuild(): void;
  46545. }
  46546. }
  46547. declare module BABYLON {
  46548. /**
  46549. * Class containing static functions to help procedurally build meshes
  46550. */
  46551. export class GroundBuilder {
  46552. /**
  46553. * Creates a ground mesh
  46554. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  46555. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  46556. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46557. * @param name defines the name of the mesh
  46558. * @param options defines the options used to create the mesh
  46559. * @param scene defines the hosting scene
  46560. * @returns the ground mesh
  46561. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  46562. */
  46563. static CreateGround(name: string, options: {
  46564. width?: number;
  46565. height?: number;
  46566. subdivisions?: number;
  46567. subdivisionsX?: number;
  46568. subdivisionsY?: number;
  46569. updatable?: boolean;
  46570. }, scene: any): Mesh;
  46571. /**
  46572. * Creates a tiled ground mesh
  46573. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  46574. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  46575. * * 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
  46576. * * 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
  46577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46578. * @param name defines the name of the mesh
  46579. * @param options defines the options used to create the mesh
  46580. * @param scene defines the hosting scene
  46581. * @returns the tiled ground mesh
  46582. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  46583. */
  46584. static CreateTiledGround(name: string, options: {
  46585. xmin: number;
  46586. zmin: number;
  46587. xmax: number;
  46588. zmax: number;
  46589. subdivisions?: {
  46590. w: number;
  46591. h: number;
  46592. };
  46593. precision?: {
  46594. w: number;
  46595. h: number;
  46596. };
  46597. updatable?: boolean;
  46598. }, scene?: Nullable<Scene>): Mesh;
  46599. /**
  46600. * Creates a ground mesh from a height map
  46601. * * The parameter `url` sets the URL of the height map image resource.
  46602. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  46603. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  46604. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  46605. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  46606. * * 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.
  46607. * * 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).
  46608. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  46609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46610. * @param name defines the name of the mesh
  46611. * @param url defines the url to the height map
  46612. * @param options defines the options used to create the mesh
  46613. * @param scene defines the hosting scene
  46614. * @returns the ground mesh
  46615. * @see https://doc.babylonjs.com/babylon101/height_map
  46616. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  46617. */
  46618. static CreateGroundFromHeightMap(name: string, url: string, options: {
  46619. width?: number;
  46620. height?: number;
  46621. subdivisions?: number;
  46622. minHeight?: number;
  46623. maxHeight?: number;
  46624. colorFilter?: Color3;
  46625. alphaFilter?: number;
  46626. updatable?: boolean;
  46627. onReady?: (mesh: GroundMesh) => void;
  46628. }, scene?: Nullable<Scene>): GroundMesh;
  46629. }
  46630. }
  46631. declare module BABYLON {
  46632. /**
  46633. * Class containing static functions to help procedurally build meshes
  46634. */
  46635. export class TorusBuilder {
  46636. /**
  46637. * Creates a torus mesh
  46638. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  46639. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  46640. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  46641. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46642. * * 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
  46643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46644. * @param name defines the name of the mesh
  46645. * @param options defines the options used to create the mesh
  46646. * @param scene defines the hosting scene
  46647. * @returns the torus mesh
  46648. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  46649. */
  46650. static CreateTorus(name: string, options: {
  46651. diameter?: number;
  46652. thickness?: number;
  46653. tessellation?: number;
  46654. updatable?: boolean;
  46655. sideOrientation?: number;
  46656. frontUVs?: Vector4;
  46657. backUVs?: Vector4;
  46658. }, scene: any): Mesh;
  46659. }
  46660. }
  46661. declare module BABYLON {
  46662. /**
  46663. * Class containing static functions to help procedurally build meshes
  46664. */
  46665. export class CylinderBuilder {
  46666. /**
  46667. * Creates a cylinder or a cone mesh
  46668. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  46669. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  46670. * * 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.
  46671. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  46672. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  46673. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  46674. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  46675. * * 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).
  46676. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  46677. * * 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).
  46678. * * 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
  46679. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  46680. * * 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
  46681. * * 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.
  46682. * * If `enclose` is false, a ring surface is one element.
  46683. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  46684. * * 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
  46685. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46686. * * 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
  46687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46688. * @param name defines the name of the mesh
  46689. * @param options defines the options used to create the mesh
  46690. * @param scene defines the hosting scene
  46691. * @returns the cylinder mesh
  46692. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  46693. */
  46694. static CreateCylinder(name: string, options: {
  46695. height?: number;
  46696. diameterTop?: number;
  46697. diameterBottom?: number;
  46698. diameter?: number;
  46699. tessellation?: number;
  46700. subdivisions?: number;
  46701. arc?: number;
  46702. faceColors?: Color4[];
  46703. faceUV?: Vector4[];
  46704. updatable?: boolean;
  46705. hasRings?: boolean;
  46706. enclose?: boolean;
  46707. cap?: number;
  46708. sideOrientation?: number;
  46709. frontUVs?: Vector4;
  46710. backUVs?: Vector4;
  46711. }, scene: any): Mesh;
  46712. }
  46713. }
  46714. declare module BABYLON {
  46715. /**
  46716. * States of the webXR experience
  46717. */
  46718. export enum WebXRState {
  46719. /**
  46720. * Transitioning to being in XR mode
  46721. */
  46722. ENTERING_XR = 0,
  46723. /**
  46724. * Transitioning to non XR mode
  46725. */
  46726. EXITING_XR = 1,
  46727. /**
  46728. * In XR mode and presenting
  46729. */
  46730. IN_XR = 2,
  46731. /**
  46732. * Not entered XR mode
  46733. */
  46734. NOT_IN_XR = 3
  46735. }
  46736. /**
  46737. * Abstraction of the XR render target
  46738. */
  46739. export interface WebXRRenderTarget extends IDisposable {
  46740. /**
  46741. * xrpresent context of the canvas which can be used to display/mirror xr content
  46742. */
  46743. canvasContext: WebGLRenderingContext;
  46744. /**
  46745. * xr layer for the canvas
  46746. */
  46747. xrLayer: Nullable<XRWebGLLayer>;
  46748. /**
  46749. * Initializes the xr layer for the session
  46750. * @param xrSession xr session
  46751. * @returns a promise that will resolve once the XR Layer has been created
  46752. */
  46753. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46754. }
  46755. }
  46756. declare module BABYLON {
  46757. /**
  46758. * COnfiguration object for WebXR output canvas
  46759. */
  46760. export class WebXRManagedOutputCanvasOptions {
  46761. /**
  46762. * An optional canvas in case you wish to create it yourself and provide it here.
  46763. * If not provided, a new canvas will be created
  46764. */
  46765. canvasElement?: HTMLCanvasElement;
  46766. /**
  46767. * Options for this XR Layer output
  46768. */
  46769. canvasOptions?: XRWebGLLayerOptions;
  46770. /**
  46771. * CSS styling for a newly created canvas (if not provided)
  46772. */
  46773. newCanvasCssStyle?: string;
  46774. /**
  46775. * Get the default values of the configuration object
  46776. * @returns default values of this configuration object
  46777. */
  46778. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  46779. }
  46780. /**
  46781. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  46782. */
  46783. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  46784. private _options;
  46785. private _canvas;
  46786. private _engine;
  46787. private _originalCanvasSize;
  46788. /**
  46789. * Rendering context of the canvas which can be used to display/mirror xr content
  46790. */
  46791. canvasContext: WebGLRenderingContext;
  46792. /**
  46793. * xr layer for the canvas
  46794. */
  46795. xrLayer: Nullable<XRWebGLLayer>;
  46796. /**
  46797. * Obseervers registered here will be triggered when the xr layer was initialized
  46798. */
  46799. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  46800. /**
  46801. * Initializes the canvas to be added/removed upon entering/exiting xr
  46802. * @param _xrSessionManager The XR Session manager
  46803. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  46804. */
  46805. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  46806. /**
  46807. * Disposes of the object
  46808. */
  46809. dispose(): void;
  46810. /**
  46811. * Initializes the xr layer for the session
  46812. * @param xrSession xr session
  46813. * @returns a promise that will resolve once the XR Layer has been created
  46814. */
  46815. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46816. private _addCanvas;
  46817. private _removeCanvas;
  46818. private _setCanvasSize;
  46819. private _setManagedOutputCanvas;
  46820. }
  46821. }
  46822. declare module BABYLON {
  46823. /**
  46824. * Manages an XRSession to work with Babylon's engine
  46825. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  46826. */
  46827. export class WebXRSessionManager implements IDisposable {
  46828. /** The scene which the session should be created for */
  46829. scene: Scene;
  46830. private _referenceSpace;
  46831. private _rttProvider;
  46832. private _sessionEnded;
  46833. private _xrNavigator;
  46834. private baseLayer;
  46835. /**
  46836. * The base reference space from which the session started. good if you want to reset your
  46837. * reference space
  46838. */
  46839. baseReferenceSpace: XRReferenceSpace;
  46840. /**
  46841. * Current XR frame
  46842. */
  46843. currentFrame: Nullable<XRFrame>;
  46844. /** WebXR timestamp updated every frame */
  46845. currentTimestamp: number;
  46846. /**
  46847. * Used just in case of a failure to initialize an immersive session.
  46848. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  46849. */
  46850. defaultHeightCompensation: number;
  46851. /**
  46852. * Fires every time a new xrFrame arrives which can be used to update the camera
  46853. */
  46854. onXRFrameObservable: Observable<XRFrame>;
  46855. /**
  46856. * Fires when the reference space changed
  46857. */
  46858. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  46859. /**
  46860. * Fires when the xr session is ended either by the device or manually done
  46861. */
  46862. onXRSessionEnded: Observable<any>;
  46863. /**
  46864. * Fires when the xr session is ended either by the device or manually done
  46865. */
  46866. onXRSessionInit: Observable<XRSession>;
  46867. /**
  46868. * Underlying xr session
  46869. */
  46870. session: XRSession;
  46871. /**
  46872. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  46873. * or get the offset the player is currently at.
  46874. */
  46875. viewerReferenceSpace: XRReferenceSpace;
  46876. /**
  46877. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  46878. * @param scene The scene which the session should be created for
  46879. */
  46880. constructor(
  46881. /** The scene which the session should be created for */
  46882. scene: Scene);
  46883. /**
  46884. * The current reference space used in this session. This reference space can constantly change!
  46885. * It is mainly used to offset the camera's position.
  46886. */
  46887. get referenceSpace(): XRReferenceSpace;
  46888. /**
  46889. * Set a new reference space and triggers the observable
  46890. */
  46891. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  46892. /**
  46893. * Disposes of the session manager
  46894. */
  46895. dispose(): void;
  46896. /**
  46897. * Stops the xrSession and restores the render loop
  46898. * @returns Promise which resolves after it exits XR
  46899. */
  46900. exitXRAsync(): Promise<void>;
  46901. /**
  46902. * Gets the correct render target texture to be rendered this frame for this eye
  46903. * @param eye the eye for which to get the render target
  46904. * @returns the render target for the specified eye
  46905. */
  46906. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  46907. /**
  46908. * Creates a WebXRRenderTarget object for the XR session
  46909. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  46910. * @param options optional options to provide when creating a new render target
  46911. * @returns a WebXR render target to which the session can render
  46912. */
  46913. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  46914. /**
  46915. * Initializes the manager
  46916. * After initialization enterXR can be called to start an XR session
  46917. * @returns Promise which resolves after it is initialized
  46918. */
  46919. initializeAsync(): Promise<void>;
  46920. /**
  46921. * Initializes an xr session
  46922. * @param xrSessionMode mode to initialize
  46923. * @param xrSessionInit defines optional and required values to pass to the session builder
  46924. * @returns a promise which will resolve once the session has been initialized
  46925. */
  46926. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  46927. /**
  46928. * Checks if a session would be supported for the creation options specified
  46929. * @param sessionMode session mode to check if supported eg. immersive-vr
  46930. * @returns A Promise that resolves to true if supported and false if not
  46931. */
  46932. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46933. /**
  46934. * Resets the reference space to the one started the session
  46935. */
  46936. resetReferenceSpace(): void;
  46937. /**
  46938. * Starts rendering to the xr layer
  46939. */
  46940. runXRRenderLoop(): void;
  46941. /**
  46942. * Sets the reference space on the xr session
  46943. * @param referenceSpaceType space to set
  46944. * @returns a promise that will resolve once the reference space has been set
  46945. */
  46946. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  46947. /**
  46948. * Updates the render state of the session
  46949. * @param state state to set
  46950. * @returns a promise that resolves once the render state has been updated
  46951. */
  46952. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  46953. /**
  46954. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  46955. * @param sessionMode defines the session to test
  46956. * @returns a promise with boolean as final value
  46957. */
  46958. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46959. private _createRenderTargetTexture;
  46960. }
  46961. }
  46962. declare module BABYLON {
  46963. /**
  46964. * WebXR Camera which holds the views for the xrSession
  46965. * @see https://doc.babylonjs.com/how_to/webxr_camera
  46966. */
  46967. export class WebXRCamera extends FreeCamera {
  46968. private _xrSessionManager;
  46969. private _firstFrame;
  46970. private _referenceQuaternion;
  46971. private _referencedPosition;
  46972. private _xrInvPositionCache;
  46973. private _xrInvQuaternionCache;
  46974. /**
  46975. * Observable raised before camera teleportation
  46976. */
  46977. onBeforeCameraTeleport: Observable<Vector3>;
  46978. /**
  46979. * Observable raised after camera teleportation
  46980. */
  46981. onAfterCameraTeleport: Observable<Vector3>;
  46982. /**
  46983. * Should position compensation execute on first frame.
  46984. * This is used when copying the position from a native (non XR) camera
  46985. */
  46986. compensateOnFirstFrame: boolean;
  46987. /**
  46988. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  46989. * @param name the name of the camera
  46990. * @param scene the scene to add the camera to
  46991. * @param _xrSessionManager a constructed xr session manager
  46992. */
  46993. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  46994. /**
  46995. * Return the user's height, unrelated to the current ground.
  46996. * This will be the y position of this camera, when ground level is 0.
  46997. */
  46998. get realWorldHeight(): number;
  46999. /** @hidden */
  47000. _updateForDualEyeDebugging(): void;
  47001. /**
  47002. * Sets this camera's transformation based on a non-vr camera
  47003. * @param otherCamera the non-vr camera to copy the transformation from
  47004. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47005. */
  47006. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47007. /**
  47008. * Gets the current instance class name ("WebXRCamera").
  47009. * @returns the class name
  47010. */
  47011. getClassName(): string;
  47012. private _rotate180;
  47013. private _updateFromXRSession;
  47014. private _updateNumberOfRigCameras;
  47015. private _updateReferenceSpace;
  47016. private _updateReferenceSpaceOffset;
  47017. }
  47018. }
  47019. declare module BABYLON {
  47020. /**
  47021. * Defining the interface required for a (webxr) feature
  47022. */
  47023. export interface IWebXRFeature extends IDisposable {
  47024. /**
  47025. * Is this feature attached
  47026. */
  47027. attached: boolean;
  47028. /**
  47029. * Should auto-attach be disabled?
  47030. */
  47031. disableAutoAttach: boolean;
  47032. /**
  47033. * Attach the feature to the session
  47034. * Will usually be called by the features manager
  47035. *
  47036. * @param force should attachment be forced (even when already attached)
  47037. * @returns true if successful.
  47038. */
  47039. attach(force?: boolean): boolean;
  47040. /**
  47041. * Detach the feature from the session
  47042. * Will usually be called by the features manager
  47043. *
  47044. * @returns true if successful.
  47045. */
  47046. detach(): boolean;
  47047. /**
  47048. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  47049. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  47050. *
  47051. * @returns whether or not the feature is compatible in this environment
  47052. */
  47053. isCompatible(): boolean;
  47054. /**
  47055. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  47056. */
  47057. xrNativeFeatureName?: string;
  47058. }
  47059. /**
  47060. * A list of the currently available features without referencing them
  47061. */
  47062. export class WebXRFeatureName {
  47063. /**
  47064. * The name of the anchor system feature
  47065. */
  47066. static ANCHOR_SYSTEM: string;
  47067. /**
  47068. * The name of the background remover feature
  47069. */
  47070. static BACKGROUND_REMOVER: string;
  47071. /**
  47072. * The name of the hit test feature
  47073. */
  47074. static HIT_TEST: string;
  47075. /**
  47076. * physics impostors for xr controllers feature
  47077. */
  47078. static PHYSICS_CONTROLLERS: string;
  47079. /**
  47080. * The name of the plane detection feature
  47081. */
  47082. static PLANE_DETECTION: string;
  47083. /**
  47084. * The name of the pointer selection feature
  47085. */
  47086. static POINTER_SELECTION: string;
  47087. /**
  47088. * The name of the teleportation feature
  47089. */
  47090. static TELEPORTATION: string;
  47091. }
  47092. /**
  47093. * Defining the constructor of a feature. Used to register the modules.
  47094. */
  47095. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  47096. /**
  47097. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  47098. * It is mainly used in AR sessions.
  47099. *
  47100. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  47101. */
  47102. export class WebXRFeaturesManager implements IDisposable {
  47103. private _xrSessionManager;
  47104. private static readonly _AvailableFeatures;
  47105. private _features;
  47106. /**
  47107. * constructs a new features manages.
  47108. *
  47109. * @param _xrSessionManager an instance of WebXRSessionManager
  47110. */
  47111. constructor(_xrSessionManager: WebXRSessionManager);
  47112. /**
  47113. * Used to register a module. After calling this function a developer can use this feature in the scene.
  47114. * Mainly used internally.
  47115. *
  47116. * @param featureName the name of the feature to register
  47117. * @param constructorFunction the function used to construct the module
  47118. * @param version the (babylon) version of the module
  47119. * @param stable is that a stable version of this module
  47120. */
  47121. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  47122. /**
  47123. * Returns a constructor of a specific feature.
  47124. *
  47125. * @param featureName the name of the feature to construct
  47126. * @param version the version of the feature to load
  47127. * @param xrSessionManager the xrSessionManager. Used to construct the module
  47128. * @param options optional options provided to the module.
  47129. * @returns a function that, when called, will return a new instance of this feature
  47130. */
  47131. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  47132. /**
  47133. * Can be used to return the list of features currently registered
  47134. *
  47135. * @returns an Array of available features
  47136. */
  47137. static GetAvailableFeatures(): string[];
  47138. /**
  47139. * Gets the versions available for a specific feature
  47140. * @param featureName the name of the feature
  47141. * @returns an array with the available versions
  47142. */
  47143. static GetAvailableVersions(featureName: string): string[];
  47144. /**
  47145. * Return the latest unstable version of this feature
  47146. * @param featureName the name of the feature to search
  47147. * @returns the version number. if not found will return -1
  47148. */
  47149. static GetLatestVersionOfFeature(featureName: string): number;
  47150. /**
  47151. * Return the latest stable version of this feature
  47152. * @param featureName the name of the feature to search
  47153. * @returns the version number. if not found will return -1
  47154. */
  47155. static GetStableVersionOfFeature(featureName: string): number;
  47156. /**
  47157. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  47158. * Can be used during a session to start a feature
  47159. * @param featureName the name of feature to attach
  47160. */
  47161. attachFeature(featureName: string): void;
  47162. /**
  47163. * Can be used inside a session or when the session ends to detach a specific feature
  47164. * @param featureName the name of the feature to detach
  47165. */
  47166. detachFeature(featureName: string): void;
  47167. /**
  47168. * Used to disable an already-enabled feature
  47169. * The feature will be disposed and will be recreated once enabled.
  47170. * @param featureName the feature to disable
  47171. * @returns true if disable was successful
  47172. */
  47173. disableFeature(featureName: string | {
  47174. Name: string;
  47175. }): boolean;
  47176. /**
  47177. * dispose this features manager
  47178. */
  47179. dispose(): void;
  47180. /**
  47181. * 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.
  47182. * 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.
  47183. *
  47184. * @param featureName the name of the feature to load or the class of the feature
  47185. * @param version optional version to load. if not provided the latest version will be enabled
  47186. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47187. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47188. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  47189. * @returns a new constructed feature or throws an error if feature not found.
  47190. */
  47191. enableFeature(featureName: string | {
  47192. Name: string;
  47193. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  47194. /**
  47195. * get the implementation of an enabled feature.
  47196. * @param featureName the name of the feature to load
  47197. * @returns the feature class, if found
  47198. */
  47199. getEnabledFeature(featureName: string): IWebXRFeature;
  47200. /**
  47201. * Get the list of enabled features
  47202. * @returns an array of enabled features
  47203. */
  47204. getEnabledFeatures(): string[];
  47205. /**
  47206. * This function will exten the session creation configuration object with enabled features.
  47207. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  47208. * according to the defined "required" variable, provided during enableFeature call
  47209. * @param xrSessionInit the xr Session init object to extend
  47210. *
  47211. * @returns an extended XRSessionInit object
  47212. */
  47213. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  47214. }
  47215. }
  47216. declare module BABYLON {
  47217. /**
  47218. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  47219. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  47220. */
  47221. export class WebXRExperienceHelper implements IDisposable {
  47222. private scene;
  47223. private _nonVRCamera;
  47224. private _originalSceneAutoClear;
  47225. private _supported;
  47226. /**
  47227. * Camera used to render xr content
  47228. */
  47229. camera: WebXRCamera;
  47230. /** A features manager for this xr session */
  47231. featuresManager: WebXRFeaturesManager;
  47232. /**
  47233. * Observers registered here will be triggered after the camera's initial transformation is set
  47234. * This can be used to set a different ground level or an extra rotation.
  47235. *
  47236. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  47237. * to the position set after this observable is done executing.
  47238. */
  47239. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  47240. /**
  47241. * Fires when the state of the experience helper has changed
  47242. */
  47243. onStateChangedObservable: Observable<WebXRState>;
  47244. /** Session manager used to keep track of xr session */
  47245. sessionManager: WebXRSessionManager;
  47246. /**
  47247. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  47248. */
  47249. state: WebXRState;
  47250. /**
  47251. * Creates a WebXRExperienceHelper
  47252. * @param scene The scene the helper should be created in
  47253. */
  47254. private constructor();
  47255. /**
  47256. * Creates the experience helper
  47257. * @param scene the scene to attach the experience helper to
  47258. * @returns a promise for the experience helper
  47259. */
  47260. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  47261. /**
  47262. * Disposes of the experience helper
  47263. */
  47264. dispose(): void;
  47265. /**
  47266. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  47267. * @param sessionMode options for the XR session
  47268. * @param referenceSpaceType frame of reference of the XR session
  47269. * @param renderTarget the output canvas that will be used to enter XR mode
  47270. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  47271. * @returns promise that resolves after xr mode has entered
  47272. */
  47273. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  47274. /**
  47275. * Exits XR mode and returns the scene to its original state
  47276. * @returns promise that resolves after xr mode has exited
  47277. */
  47278. exitXRAsync(): Promise<void>;
  47279. private _nonXRToXRCamera;
  47280. private _setState;
  47281. }
  47282. }
  47283. declare module BABYLON {
  47284. /**
  47285. * X-Y values for axes in WebXR
  47286. */
  47287. export interface IWebXRMotionControllerAxesValue {
  47288. /**
  47289. * The value of the x axis
  47290. */
  47291. x: number;
  47292. /**
  47293. * The value of the y-axis
  47294. */
  47295. y: number;
  47296. }
  47297. /**
  47298. * changed / previous values for the values of this component
  47299. */
  47300. export interface IWebXRMotionControllerComponentChangesValues<T> {
  47301. /**
  47302. * current (this frame) value
  47303. */
  47304. current: T;
  47305. /**
  47306. * previous (last change) value
  47307. */
  47308. previous: T;
  47309. }
  47310. /**
  47311. * Represents changes in the component between current frame and last values recorded
  47312. */
  47313. export interface IWebXRMotionControllerComponentChanges {
  47314. /**
  47315. * will be populated with previous and current values if axes changed
  47316. */
  47317. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  47318. /**
  47319. * will be populated with previous and current values if pressed changed
  47320. */
  47321. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47322. /**
  47323. * will be populated with previous and current values if touched changed
  47324. */
  47325. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47326. /**
  47327. * will be populated with previous and current values if value changed
  47328. */
  47329. value?: IWebXRMotionControllerComponentChangesValues<number>;
  47330. }
  47331. /**
  47332. * This class represents a single component (for example button or thumbstick) of a motion controller
  47333. */
  47334. export class WebXRControllerComponent implements IDisposable {
  47335. /**
  47336. * the id of this component
  47337. */
  47338. id: string;
  47339. /**
  47340. * the type of the component
  47341. */
  47342. type: MotionControllerComponentType;
  47343. private _buttonIndex;
  47344. private _axesIndices;
  47345. private _axes;
  47346. private _changes;
  47347. private _currentValue;
  47348. private _hasChanges;
  47349. private _pressed;
  47350. private _touched;
  47351. /**
  47352. * button component type
  47353. */
  47354. static BUTTON_TYPE: MotionControllerComponentType;
  47355. /**
  47356. * squeeze component type
  47357. */
  47358. static SQUEEZE_TYPE: MotionControllerComponentType;
  47359. /**
  47360. * Thumbstick component type
  47361. */
  47362. static THUMBSTICK_TYPE: MotionControllerComponentType;
  47363. /**
  47364. * Touchpad component type
  47365. */
  47366. static TOUCHPAD_TYPE: MotionControllerComponentType;
  47367. /**
  47368. * trigger component type
  47369. */
  47370. static TRIGGER_TYPE: MotionControllerComponentType;
  47371. /**
  47372. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  47373. * the axes data changes
  47374. */
  47375. onAxisValueChangedObservable: Observable<{
  47376. x: number;
  47377. y: number;
  47378. }>;
  47379. /**
  47380. * Observers registered here will be triggered when the state of a button changes
  47381. * State change is either pressed / touched / value
  47382. */
  47383. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  47384. /**
  47385. * Creates a new component for a motion controller.
  47386. * It is created by the motion controller itself
  47387. *
  47388. * @param id the id of this component
  47389. * @param type the type of the component
  47390. * @param _buttonIndex index in the buttons array of the gamepad
  47391. * @param _axesIndices indices of the values in the axes array of the gamepad
  47392. */
  47393. constructor(
  47394. /**
  47395. * the id of this component
  47396. */
  47397. id: string,
  47398. /**
  47399. * the type of the component
  47400. */
  47401. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  47402. /**
  47403. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  47404. */
  47405. get axes(): IWebXRMotionControllerAxesValue;
  47406. /**
  47407. * Get the changes. Elements will be populated only if they changed with their previous and current value
  47408. */
  47409. get changes(): IWebXRMotionControllerComponentChanges;
  47410. /**
  47411. * Return whether or not the component changed the last frame
  47412. */
  47413. get hasChanges(): boolean;
  47414. /**
  47415. * is the button currently pressed
  47416. */
  47417. get pressed(): boolean;
  47418. /**
  47419. * is the button currently touched
  47420. */
  47421. get touched(): boolean;
  47422. /**
  47423. * Get the current value of this component
  47424. */
  47425. get value(): number;
  47426. /**
  47427. * Dispose this component
  47428. */
  47429. dispose(): void;
  47430. /**
  47431. * Are there axes correlating to this component
  47432. * @return true is axes data is available
  47433. */
  47434. isAxes(): boolean;
  47435. /**
  47436. * Is this component a button (hence - pressable)
  47437. * @returns true if can be pressed
  47438. */
  47439. isButton(): boolean;
  47440. /**
  47441. * update this component using the gamepad object it is in. Called on every frame
  47442. * @param nativeController the native gamepad controller object
  47443. */
  47444. update(nativeController: IMinimalMotionControllerObject): void;
  47445. }
  47446. }
  47447. declare module BABYLON {
  47448. /**
  47449. * Interface used to represent data loading progression
  47450. */
  47451. export interface ISceneLoaderProgressEvent {
  47452. /**
  47453. * Defines if data length to load can be evaluated
  47454. */
  47455. readonly lengthComputable: boolean;
  47456. /**
  47457. * Defines the loaded data length
  47458. */
  47459. readonly loaded: number;
  47460. /**
  47461. * Defines the data length to load
  47462. */
  47463. readonly total: number;
  47464. }
  47465. /**
  47466. * Interface used by SceneLoader plugins to define supported file extensions
  47467. */
  47468. export interface ISceneLoaderPluginExtensions {
  47469. /**
  47470. * Defines the list of supported extensions
  47471. */
  47472. [extension: string]: {
  47473. isBinary: boolean;
  47474. };
  47475. }
  47476. /**
  47477. * Interface used by SceneLoader plugin factory
  47478. */
  47479. export interface ISceneLoaderPluginFactory {
  47480. /**
  47481. * Defines the name of the factory
  47482. */
  47483. name: string;
  47484. /**
  47485. * Function called to create a new plugin
  47486. * @return the new plugin
  47487. */
  47488. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  47489. /**
  47490. * The callback that returns true if the data can be directly loaded.
  47491. * @param data string containing the file data
  47492. * @returns if the data can be loaded directly
  47493. */
  47494. canDirectLoad?(data: string): boolean;
  47495. }
  47496. /**
  47497. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  47498. */
  47499. export interface ISceneLoaderPluginBase {
  47500. /**
  47501. * The friendly name of this plugin.
  47502. */
  47503. name: string;
  47504. /**
  47505. * The file extensions supported by this plugin.
  47506. */
  47507. extensions: string | ISceneLoaderPluginExtensions;
  47508. /**
  47509. * The callback called when loading from a url.
  47510. * @param scene scene loading this url
  47511. * @param url url to load
  47512. * @param onSuccess callback called when the file successfully loads
  47513. * @param onProgress callback called while file is loading (if the server supports this mode)
  47514. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  47515. * @param onError callback called when the file fails to load
  47516. * @returns a file request object
  47517. */
  47518. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47519. /**
  47520. * The callback called when loading from a file object.
  47521. * @param scene scene loading this file
  47522. * @param file defines the file to load
  47523. * @param onSuccess defines the callback to call when data is loaded
  47524. * @param onProgress defines the callback to call during loading process
  47525. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  47526. * @param onError defines the callback to call when an error occurs
  47527. * @returns a file request object
  47528. */
  47529. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47530. /**
  47531. * The callback that returns true if the data can be directly loaded.
  47532. * @param data string containing the file data
  47533. * @returns if the data can be loaded directly
  47534. */
  47535. canDirectLoad?(data: string): boolean;
  47536. /**
  47537. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  47538. * @param scene scene loading this data
  47539. * @param data string containing the data
  47540. * @returns data to pass to the plugin
  47541. */
  47542. directLoad?(scene: Scene, data: string): any;
  47543. /**
  47544. * The callback that allows custom handling of the root url based on the response url.
  47545. * @param rootUrl the original root url
  47546. * @param responseURL the response url if available
  47547. * @returns the new root url
  47548. */
  47549. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  47550. }
  47551. /**
  47552. * Interface used to define a SceneLoader plugin
  47553. */
  47554. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  47555. /**
  47556. * Import meshes into a scene.
  47557. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47558. * @param scene The scene to import into
  47559. * @param data The data to import
  47560. * @param rootUrl The root url for scene and resources
  47561. * @param meshes The meshes array to import into
  47562. * @param particleSystems The particle systems array to import into
  47563. * @param skeletons The skeletons array to import into
  47564. * @param onError The callback when import fails
  47565. * @returns True if successful or false otherwise
  47566. */
  47567. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  47568. /**
  47569. * Load into a scene.
  47570. * @param scene The scene to load into
  47571. * @param data The data to import
  47572. * @param rootUrl The root url for scene and resources
  47573. * @param onError The callback when import fails
  47574. * @returns True if successful or false otherwise
  47575. */
  47576. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  47577. /**
  47578. * Load into an asset container.
  47579. * @param scene The scene to load into
  47580. * @param data The data to import
  47581. * @param rootUrl The root url for scene and resources
  47582. * @param onError The callback when import fails
  47583. * @returns The loaded asset container
  47584. */
  47585. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  47586. }
  47587. /**
  47588. * Interface used to define an async SceneLoader plugin
  47589. */
  47590. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  47591. /**
  47592. * Import meshes into a scene.
  47593. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47594. * @param scene The scene to import into
  47595. * @param data The data to import
  47596. * @param rootUrl The root url for scene and resources
  47597. * @param onProgress The callback when the load progresses
  47598. * @param fileName Defines the name of the file to load
  47599. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  47600. */
  47601. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  47602. meshes: AbstractMesh[];
  47603. particleSystems: IParticleSystem[];
  47604. skeletons: Skeleton[];
  47605. animationGroups: AnimationGroup[];
  47606. }>;
  47607. /**
  47608. * Load into a scene.
  47609. * @param scene The scene to load into
  47610. * @param data The data to import
  47611. * @param rootUrl The root url for scene and resources
  47612. * @param onProgress The callback when the load progresses
  47613. * @param fileName Defines the name of the file to load
  47614. * @returns Nothing
  47615. */
  47616. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  47617. /**
  47618. * Load into an asset container.
  47619. * @param scene The scene to load into
  47620. * @param data The data to import
  47621. * @param rootUrl The root url for scene and resources
  47622. * @param onProgress The callback when the load progresses
  47623. * @param fileName Defines the name of the file to load
  47624. * @returns The loaded asset container
  47625. */
  47626. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  47627. }
  47628. /**
  47629. * Mode that determines how to handle old animation groups before loading new ones.
  47630. */
  47631. export enum SceneLoaderAnimationGroupLoadingMode {
  47632. /**
  47633. * Reset all old animations to initial state then dispose them.
  47634. */
  47635. Clean = 0,
  47636. /**
  47637. * Stop all old animations.
  47638. */
  47639. Stop = 1,
  47640. /**
  47641. * Restart old animations from first frame.
  47642. */
  47643. Sync = 2,
  47644. /**
  47645. * Old animations remains untouched.
  47646. */
  47647. NoSync = 3
  47648. }
  47649. /**
  47650. * Defines a plugin registered by the SceneLoader
  47651. */
  47652. interface IRegisteredPlugin {
  47653. /**
  47654. * Defines the plugin to use
  47655. */
  47656. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47657. /**
  47658. * Defines if the plugin supports binary data
  47659. */
  47660. isBinary: boolean;
  47661. }
  47662. /**
  47663. * Class used to load scene from various file formats using registered plugins
  47664. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  47665. */
  47666. export class SceneLoader {
  47667. /**
  47668. * No logging while loading
  47669. */
  47670. static readonly NO_LOGGING: number;
  47671. /**
  47672. * Minimal logging while loading
  47673. */
  47674. static readonly MINIMAL_LOGGING: number;
  47675. /**
  47676. * Summary logging while loading
  47677. */
  47678. static readonly SUMMARY_LOGGING: number;
  47679. /**
  47680. * Detailled logging while loading
  47681. */
  47682. static readonly DETAILED_LOGGING: number;
  47683. /**
  47684. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  47685. */
  47686. static get ForceFullSceneLoadingForIncremental(): boolean;
  47687. static set ForceFullSceneLoadingForIncremental(value: boolean);
  47688. /**
  47689. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  47690. */
  47691. static get ShowLoadingScreen(): boolean;
  47692. static set ShowLoadingScreen(value: boolean);
  47693. /**
  47694. * Defines the current logging level (while loading the scene)
  47695. * @ignorenaming
  47696. */
  47697. static get loggingLevel(): number;
  47698. static set loggingLevel(value: number);
  47699. /**
  47700. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  47701. */
  47702. static get CleanBoneMatrixWeights(): boolean;
  47703. static set CleanBoneMatrixWeights(value: boolean);
  47704. /**
  47705. * Event raised when a plugin is used to load a scene
  47706. */
  47707. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  47708. private static _registeredPlugins;
  47709. private static _showingLoadingScreen;
  47710. /**
  47711. * Gets the default plugin (used to load Babylon files)
  47712. * @returns the .babylon plugin
  47713. */
  47714. static GetDefaultPlugin(): IRegisteredPlugin;
  47715. private static _GetPluginForExtension;
  47716. private static _GetPluginForDirectLoad;
  47717. private static _GetPluginForFilename;
  47718. private static _GetDirectLoad;
  47719. private static _LoadData;
  47720. private static _GetFileInfo;
  47721. /**
  47722. * Gets a plugin that can load the given extension
  47723. * @param extension defines the extension to load
  47724. * @returns a plugin or null if none works
  47725. */
  47726. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47727. /**
  47728. * Gets a boolean indicating that the given extension can be loaded
  47729. * @param extension defines the extension to load
  47730. * @returns true if the extension is supported
  47731. */
  47732. static IsPluginForExtensionAvailable(extension: string): boolean;
  47733. /**
  47734. * Adds a new plugin to the list of registered plugins
  47735. * @param plugin defines the plugin to add
  47736. */
  47737. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  47738. /**
  47739. * Import meshes into a scene
  47740. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47741. * @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)
  47742. * @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)
  47743. * @param scene the instance of BABYLON.Scene to append to
  47744. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  47745. * @param onProgress a callback with a progress event for each file being loaded
  47746. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47747. * @param pluginExtension the extension used to determine the plugin
  47748. * @returns The loaded plugin
  47749. */
  47750. 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>;
  47751. /**
  47752. * Import meshes into a scene
  47753. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47754. * @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)
  47755. * @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)
  47756. * @param scene the instance of BABYLON.Scene to append to
  47757. * @param onProgress a callback with a progress event for each file being loaded
  47758. * @param pluginExtension the extension used to determine the plugin
  47759. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  47760. */
  47761. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  47762. meshes: AbstractMesh[];
  47763. particleSystems: IParticleSystem[];
  47764. skeletons: Skeleton[];
  47765. animationGroups: AnimationGroup[];
  47766. }>;
  47767. /**
  47768. * Load a scene
  47769. * @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)
  47770. * @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)
  47771. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47772. * @param onSuccess a callback with the scene when import succeeds
  47773. * @param onProgress a callback with a progress event for each file being loaded
  47774. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47775. * @param pluginExtension the extension used to determine the plugin
  47776. * @returns The loaded plugin
  47777. */
  47778. 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>;
  47779. /**
  47780. * Load a scene
  47781. * @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)
  47782. * @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)
  47783. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47784. * @param onProgress a callback with a progress event for each file being loaded
  47785. * @param pluginExtension the extension used to determine the plugin
  47786. * @returns The loaded scene
  47787. */
  47788. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47789. /**
  47790. * Append a scene
  47791. * @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)
  47792. * @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)
  47793. * @param scene is the instance of BABYLON.Scene to append to
  47794. * @param onSuccess a callback with the scene when import succeeds
  47795. * @param onProgress a callback with a progress event for each file being loaded
  47796. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47797. * @param pluginExtension the extension used to determine the plugin
  47798. * @returns The loaded plugin
  47799. */
  47800. 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>;
  47801. /**
  47802. * Append a scene
  47803. * @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)
  47804. * @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)
  47805. * @param scene is the instance of BABYLON.Scene to append to
  47806. * @param onProgress a callback with a progress event for each file being loaded
  47807. * @param pluginExtension the extension used to determine the plugin
  47808. * @returns The given scene
  47809. */
  47810. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47811. /**
  47812. * Load a scene into an asset container
  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 is the instance of BABYLON.Scene to append to (default: last created scene)
  47816. * @param onSuccess a callback with the scene 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 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>;
  47823. /**
  47824. * Load a scene into an asset container
  47825. * @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)
  47826. * @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)
  47827. * @param scene is the instance of Scene to append to
  47828. * @param onProgress a callback with a progress event for each file being loaded
  47829. * @param pluginExtension the extension used to determine the plugin
  47830. * @returns The loaded asset container
  47831. */
  47832. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  47833. /**
  47834. * Import animations from a file into a scene
  47835. * @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)
  47836. * @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)
  47837. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47838. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47839. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47840. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47841. * @param onSuccess a callback with the scene when import succeeds
  47842. * @param onProgress a callback with a progress event for each file being loaded
  47843. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47844. * @param pluginExtension the extension used to determine the plugin
  47845. */
  47846. 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;
  47847. /**
  47848. * Import animations from a file into a scene
  47849. * @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)
  47850. * @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)
  47851. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47852. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47853. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47854. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47855. * @param onSuccess a callback with the scene when import succeeds
  47856. * @param onProgress a callback with a progress event for each file being loaded
  47857. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47858. * @param pluginExtension the extension used to determine the plugin
  47859. * @returns the updated scene with imported animations
  47860. */
  47861. 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>;
  47862. }
  47863. }
  47864. declare module BABYLON {
  47865. /**
  47866. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  47867. */
  47868. export type MotionControllerHandedness = "none" | "left" | "right";
  47869. /**
  47870. * The type of components available in motion controllers.
  47871. * This is not the name of the component.
  47872. */
  47873. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  47874. /**
  47875. * The state of a controller component
  47876. */
  47877. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  47878. /**
  47879. * The schema of motion controller layout.
  47880. * No object will be initialized using this interface
  47881. * This is used just to define the profile.
  47882. */
  47883. export interface IMotionControllerLayout {
  47884. /**
  47885. * Path to load the assets. Usually relative to the base path
  47886. */
  47887. assetPath: string;
  47888. /**
  47889. * Available components (unsorted)
  47890. */
  47891. components: {
  47892. /**
  47893. * A map of component Ids
  47894. */
  47895. [componentId: string]: {
  47896. /**
  47897. * The type of input the component outputs
  47898. */
  47899. type: MotionControllerComponentType;
  47900. /**
  47901. * The indices of this component in the gamepad object
  47902. */
  47903. gamepadIndices: {
  47904. /**
  47905. * Index of button
  47906. */
  47907. button?: number;
  47908. /**
  47909. * If available, index of x-axis
  47910. */
  47911. xAxis?: number;
  47912. /**
  47913. * If available, index of y-axis
  47914. */
  47915. yAxis?: number;
  47916. };
  47917. /**
  47918. * The mesh's root node name
  47919. */
  47920. rootNodeName: string;
  47921. /**
  47922. * Animation definitions for this model
  47923. */
  47924. visualResponses: {
  47925. [stateKey: string]: {
  47926. /**
  47927. * What property will be animated
  47928. */
  47929. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  47930. /**
  47931. * What states influence this visual response
  47932. */
  47933. states: MotionControllerComponentStateType[];
  47934. /**
  47935. * Type of animation - movement or visibility
  47936. */
  47937. valueNodeProperty: "transform" | "visibility";
  47938. /**
  47939. * Base node name to move. Its position will be calculated according to the min and max nodes
  47940. */
  47941. valueNodeName?: string;
  47942. /**
  47943. * Minimum movement node
  47944. */
  47945. minNodeName?: string;
  47946. /**
  47947. * Max movement node
  47948. */
  47949. maxNodeName?: string;
  47950. };
  47951. };
  47952. /**
  47953. * If touch enabled, what is the name of node to display user feedback
  47954. */
  47955. touchPointNodeName?: string;
  47956. };
  47957. };
  47958. /**
  47959. * Is it xr standard mapping or not
  47960. */
  47961. gamepadMapping: "" | "xr-standard";
  47962. /**
  47963. * Base root node of this entire model
  47964. */
  47965. rootNodeName: string;
  47966. /**
  47967. * Defines the main button component id
  47968. */
  47969. selectComponentId: string;
  47970. }
  47971. /**
  47972. * A definition for the layout map in the input profile
  47973. */
  47974. export interface IMotionControllerLayoutMap {
  47975. /**
  47976. * Layouts with handedness type as a key
  47977. */
  47978. [handedness: string]: IMotionControllerLayout;
  47979. }
  47980. /**
  47981. * The XR Input profile schema
  47982. * Profiles can be found here:
  47983. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  47984. */
  47985. export interface IMotionControllerProfile {
  47986. /**
  47987. * fallback profiles for this profileId
  47988. */
  47989. fallbackProfileIds: string[];
  47990. /**
  47991. * The layout map, with handedness as key
  47992. */
  47993. layouts: IMotionControllerLayoutMap;
  47994. /**
  47995. * The id of this profile
  47996. * correlates to the profile(s) in the xrInput.profiles array
  47997. */
  47998. profileId: string;
  47999. }
  48000. /**
  48001. * A helper-interface for the 3 meshes needed for controller button animation
  48002. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48003. */
  48004. export interface IMotionControllerButtonMeshMap {
  48005. /**
  48006. * the mesh that defines the pressed value mesh position.
  48007. * This is used to find the max-position of this button
  48008. */
  48009. pressedMesh: AbstractMesh;
  48010. /**
  48011. * the mesh that defines the unpressed value mesh position.
  48012. * This is used to find the min (or initial) position of this button
  48013. */
  48014. unpressedMesh: AbstractMesh;
  48015. /**
  48016. * The mesh that will be changed when value changes
  48017. */
  48018. valueMesh: AbstractMesh;
  48019. }
  48020. /**
  48021. * A helper-interface for the 3 meshes needed for controller axis animation.
  48022. * This will be expanded when touchpad animations are fully supported
  48023. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48024. */
  48025. export interface IMotionControllerMeshMap {
  48026. /**
  48027. * the mesh that defines the maximum value mesh position.
  48028. */
  48029. maxMesh?: AbstractMesh;
  48030. /**
  48031. * the mesh that defines the minimum value mesh position.
  48032. */
  48033. minMesh?: AbstractMesh;
  48034. /**
  48035. * The mesh that will be changed when axis value changes
  48036. */
  48037. valueMesh: AbstractMesh;
  48038. }
  48039. /**
  48040. * The elements needed for change-detection of the gamepad objects in motion controllers
  48041. */
  48042. export interface IMinimalMotionControllerObject {
  48043. /**
  48044. * Available axes of this controller
  48045. */
  48046. axes: number[];
  48047. /**
  48048. * An array of available buttons
  48049. */
  48050. buttons: Array<{
  48051. /**
  48052. * Value of the button/trigger
  48053. */
  48054. value: number;
  48055. /**
  48056. * If the button/trigger is currently touched
  48057. */
  48058. touched: boolean;
  48059. /**
  48060. * If the button/trigger is currently pressed
  48061. */
  48062. pressed: boolean;
  48063. }>;
  48064. /**
  48065. * EXPERIMENTAL haptic support.
  48066. */
  48067. hapticActuators?: Array<{
  48068. pulse: (value: number, duration: number) => Promise<boolean>;
  48069. }>;
  48070. }
  48071. /**
  48072. * An Abstract Motion controller
  48073. * This class receives an xrInput and a profile layout and uses those to initialize the components
  48074. * Each component has an observable to check for changes in value and state
  48075. */
  48076. export abstract class WebXRAbstractMotionController implements IDisposable {
  48077. protected scene: Scene;
  48078. protected layout: IMotionControllerLayout;
  48079. /**
  48080. * The gamepad object correlating to this controller
  48081. */
  48082. gamepadObject: IMinimalMotionControllerObject;
  48083. /**
  48084. * handedness (left/right/none) of this controller
  48085. */
  48086. handedness: MotionControllerHandedness;
  48087. private _initComponent;
  48088. private _modelReady;
  48089. /**
  48090. * A map of components (WebXRControllerComponent) in this motion controller
  48091. * Components have a ComponentType and can also have both button and axis definitions
  48092. */
  48093. readonly components: {
  48094. [id: string]: WebXRControllerComponent;
  48095. };
  48096. /**
  48097. * Disable the model's animation. Can be set at any time.
  48098. */
  48099. disableAnimation: boolean;
  48100. /**
  48101. * Observers registered here will be triggered when the model of this controller is done loading
  48102. */
  48103. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  48104. /**
  48105. * The profile id of this motion controller
  48106. */
  48107. abstract profileId: string;
  48108. /**
  48109. * The root mesh of the model. It is null if the model was not yet initialized
  48110. */
  48111. rootMesh: Nullable<AbstractMesh>;
  48112. /**
  48113. * constructs a new abstract motion controller
  48114. * @param scene the scene to which the model of the controller will be added
  48115. * @param layout The profile layout to load
  48116. * @param gamepadObject The gamepad object correlating to this controller
  48117. * @param handedness handedness (left/right/none) of this controller
  48118. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  48119. */
  48120. constructor(scene: Scene, layout: IMotionControllerLayout,
  48121. /**
  48122. * The gamepad object correlating to this controller
  48123. */
  48124. gamepadObject: IMinimalMotionControllerObject,
  48125. /**
  48126. * handedness (left/right/none) of this controller
  48127. */
  48128. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  48129. /**
  48130. * Dispose this controller, the model mesh and all its components
  48131. */
  48132. dispose(): void;
  48133. /**
  48134. * Returns all components of specific type
  48135. * @param type the type to search for
  48136. * @return an array of components with this type
  48137. */
  48138. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  48139. /**
  48140. * get a component based an its component id as defined in layout.components
  48141. * @param id the id of the component
  48142. * @returns the component correlates to the id or undefined if not found
  48143. */
  48144. getComponent(id: string): WebXRControllerComponent;
  48145. /**
  48146. * Get the list of components available in this motion controller
  48147. * @returns an array of strings correlating to available components
  48148. */
  48149. getComponentIds(): string[];
  48150. /**
  48151. * Get the first component of specific type
  48152. * @param type type of component to find
  48153. * @return a controller component or null if not found
  48154. */
  48155. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  48156. /**
  48157. * Get the main (Select) component of this controller as defined in the layout
  48158. * @returns the main component of this controller
  48159. */
  48160. getMainComponent(): WebXRControllerComponent;
  48161. /**
  48162. * Loads the model correlating to this controller
  48163. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  48164. * @returns A promise fulfilled with the result of the model loading
  48165. */
  48166. loadModel(): Promise<boolean>;
  48167. /**
  48168. * Update this model using the current XRFrame
  48169. * @param xrFrame the current xr frame to use and update the model
  48170. */
  48171. updateFromXRFrame(xrFrame: XRFrame): void;
  48172. /**
  48173. * Backwards compatibility due to a deeply-integrated typo
  48174. */
  48175. get handness(): XREye;
  48176. /**
  48177. * Pulse (vibrate) this controller
  48178. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48179. * Consecutive calls to this function will cancel the last pulse call
  48180. *
  48181. * @param value the strength of the pulse in 0.0...1.0 range
  48182. * @param duration Duration of the pulse in milliseconds
  48183. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48184. * @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
  48185. */
  48186. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48187. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48188. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48189. /**
  48190. * Moves the axis on the controller mesh based on its current state
  48191. * @param axis the index of the axis
  48192. * @param axisValue the value of the axis which determines the meshes new position
  48193. * @hidden
  48194. */
  48195. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  48196. /**
  48197. * Update the model itself with the current frame data
  48198. * @param xrFrame the frame to use for updating the model mesh
  48199. */
  48200. protected updateModel(xrFrame: XRFrame): void;
  48201. /**
  48202. * Get the filename and path for this controller's model
  48203. * @returns a map of filename and path
  48204. */
  48205. protected abstract _getFilenameAndPath(): {
  48206. filename: string;
  48207. path: string;
  48208. };
  48209. /**
  48210. * This function is called before the mesh is loaded. It checks for loading constraints.
  48211. * For example, this function can check if the GLB loader is available
  48212. * If this function returns false, the generic controller will be loaded instead
  48213. * @returns Is the client ready to load the mesh
  48214. */
  48215. protected abstract _getModelLoadingConstraints(): boolean;
  48216. /**
  48217. * This function will be called after the model was successfully loaded and can be used
  48218. * for mesh transformations before it is available for the user
  48219. * @param meshes the loaded meshes
  48220. */
  48221. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  48222. /**
  48223. * Set the root mesh for this controller. Important for the WebXR controller class
  48224. * @param meshes the loaded meshes
  48225. */
  48226. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  48227. /**
  48228. * A function executed each frame that updates the mesh (if needed)
  48229. * @param xrFrame the current xrFrame
  48230. */
  48231. protected abstract _updateModel(xrFrame: XRFrame): void;
  48232. private _getGenericFilenameAndPath;
  48233. private _getGenericParentMesh;
  48234. }
  48235. }
  48236. declare module BABYLON {
  48237. /**
  48238. * A generic trigger-only motion controller for WebXR
  48239. */
  48240. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  48241. /**
  48242. * Static version of the profile id of this controller
  48243. */
  48244. static ProfileId: string;
  48245. profileId: string;
  48246. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  48247. protected _getFilenameAndPath(): {
  48248. filename: string;
  48249. path: string;
  48250. };
  48251. protected _getModelLoadingConstraints(): boolean;
  48252. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  48253. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48254. protected _updateModel(): void;
  48255. }
  48256. }
  48257. declare module BABYLON {
  48258. /**
  48259. * Class containing static functions to help procedurally build meshes
  48260. */
  48261. export class SphereBuilder {
  48262. /**
  48263. * Creates a sphere mesh
  48264. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48265. * * 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`)
  48266. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48267. * * 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
  48268. * * 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)
  48269. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48270. * * 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
  48271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48272. * @param name defines the name of the mesh
  48273. * @param options defines the options used to create the mesh
  48274. * @param scene defines the hosting scene
  48275. * @returns the sphere mesh
  48276. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48277. */
  48278. static CreateSphere(name: string, options: {
  48279. segments?: number;
  48280. diameter?: number;
  48281. diameterX?: number;
  48282. diameterY?: number;
  48283. diameterZ?: number;
  48284. arc?: number;
  48285. slice?: number;
  48286. sideOrientation?: number;
  48287. frontUVs?: Vector4;
  48288. backUVs?: Vector4;
  48289. updatable?: boolean;
  48290. }, scene?: Nullable<Scene>): Mesh;
  48291. }
  48292. }
  48293. declare module BABYLON {
  48294. /**
  48295. * A profiled motion controller has its profile loaded from an online repository.
  48296. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  48297. */
  48298. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  48299. private _repositoryUrl;
  48300. private _buttonMeshMapping;
  48301. private _touchDots;
  48302. /**
  48303. * The profile ID of this controller. Will be populated when the controller initializes.
  48304. */
  48305. profileId: string;
  48306. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  48307. dispose(): void;
  48308. protected _getFilenameAndPath(): {
  48309. filename: string;
  48310. path: string;
  48311. };
  48312. protected _getModelLoadingConstraints(): boolean;
  48313. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  48314. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48315. protected _updateModel(_xrFrame: XRFrame): void;
  48316. }
  48317. }
  48318. declare module BABYLON {
  48319. /**
  48320. * A construction function type to create a new controller based on an xrInput object
  48321. */
  48322. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  48323. /**
  48324. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  48325. *
  48326. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  48327. * it should be replaced with auto-loaded controllers.
  48328. *
  48329. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  48330. */
  48331. export class WebXRMotionControllerManager {
  48332. private static _AvailableControllers;
  48333. private static _Fallbacks;
  48334. private static _ProfileLoadingPromises;
  48335. private static _ProfilesList;
  48336. /**
  48337. * The base URL of the online controller repository. Can be changed at any time.
  48338. */
  48339. static BaseRepositoryUrl: string;
  48340. /**
  48341. * Which repository gets priority - local or online
  48342. */
  48343. static PrioritizeOnlineRepository: boolean;
  48344. /**
  48345. * Use the online repository, or use only locally-defined controllers
  48346. */
  48347. static UseOnlineRepository: boolean;
  48348. /**
  48349. * Clear the cache used for profile loading and reload when requested again
  48350. */
  48351. static ClearProfilesCache(): void;
  48352. /**
  48353. * Register the default fallbacks.
  48354. * This function is called automatically when this file is imported.
  48355. */
  48356. static DefaultFallbacks(): void;
  48357. /**
  48358. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  48359. * @param profileId the profile to which a fallback needs to be found
  48360. * @return an array with corresponding fallback profiles
  48361. */
  48362. static FindFallbackWithProfileId(profileId: string): string[];
  48363. /**
  48364. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  48365. * The order of search:
  48366. *
  48367. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  48368. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  48369. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  48370. * 4) return the generic trigger controller if none were found
  48371. *
  48372. * @param xrInput the xrInput to which a new controller is initialized
  48373. * @param scene the scene to which the model will be added
  48374. * @param forceProfile force a certain profile for this controller
  48375. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  48376. */
  48377. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  48378. /**
  48379. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  48380. *
  48381. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  48382. *
  48383. * @param type the profile type to register
  48384. * @param constructFunction the function to be called when loading this profile
  48385. */
  48386. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  48387. /**
  48388. * Register a fallback to a specific profile.
  48389. * @param profileId the profileId that will receive the fallbacks
  48390. * @param fallbacks A list of fallback profiles
  48391. */
  48392. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  48393. /**
  48394. * Will update the list of profiles available in the repository
  48395. * @return a promise that resolves to a map of profiles available online
  48396. */
  48397. static UpdateProfilesList(): Promise<{
  48398. [profile: string]: string;
  48399. }>;
  48400. private static _LoadProfileFromRepository;
  48401. private static _LoadProfilesFromAvailableControllers;
  48402. }
  48403. }
  48404. declare module BABYLON {
  48405. /**
  48406. * Configuration options for the WebXR controller creation
  48407. */
  48408. export interface IWebXRControllerOptions {
  48409. /**
  48410. * Should the controller mesh be animated when a user interacts with it
  48411. * The pressed buttons / thumbstick and touchpad animations will be disabled
  48412. */
  48413. disableMotionControllerAnimation?: boolean;
  48414. /**
  48415. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  48416. */
  48417. doNotLoadControllerMesh?: boolean;
  48418. /**
  48419. * Force a specific controller type for this controller.
  48420. * This can be used when creating your own profile or when testing different controllers
  48421. */
  48422. forceControllerProfile?: string;
  48423. /**
  48424. * Defines a rendering group ID for meshes that will be loaded.
  48425. * This is for the default controllers only.
  48426. */
  48427. renderingGroupId?: number;
  48428. }
  48429. /**
  48430. * Represents an XR controller
  48431. */
  48432. export class WebXRInputSource {
  48433. private _scene;
  48434. /** The underlying input source for the controller */
  48435. inputSource: XRInputSource;
  48436. private _options;
  48437. private _tmpVector;
  48438. private _uniqueId;
  48439. /**
  48440. * 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
  48441. */
  48442. grip?: AbstractMesh;
  48443. /**
  48444. * If available, this is the gamepad object related to this controller.
  48445. * Using this object it is possible to get click events and trackpad changes of the
  48446. * webxr controller that is currently being used.
  48447. */
  48448. motionController?: WebXRAbstractMotionController;
  48449. /**
  48450. * Event that fires when the controller is removed/disposed.
  48451. * The object provided as event data is this controller, after associated assets were disposed.
  48452. * uniqueId is still available.
  48453. */
  48454. onDisposeObservable: Observable<WebXRInputSource>;
  48455. /**
  48456. * Will be triggered when the mesh associated with the motion controller is done loading.
  48457. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  48458. * A shortened version of controller -> motion controller -> on mesh loaded.
  48459. */
  48460. onMeshLoadedObservable: Observable<AbstractMesh>;
  48461. /**
  48462. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  48463. */
  48464. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  48465. /**
  48466. * Pointer which can be used to select objects or attach a visible laser to
  48467. */
  48468. pointer: AbstractMesh;
  48469. /**
  48470. * Creates the input source object
  48471. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  48472. * @param _scene the scene which the controller should be associated to
  48473. * @param inputSource the underlying input source for the controller
  48474. * @param _options options for this controller creation
  48475. */
  48476. constructor(_scene: Scene,
  48477. /** The underlying input source for the controller */
  48478. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  48479. /**
  48480. * Get this controllers unique id
  48481. */
  48482. get uniqueId(): string;
  48483. /**
  48484. * Disposes of the object
  48485. */
  48486. dispose(): void;
  48487. /**
  48488. * Gets a world space ray coming from the pointer or grip
  48489. * @param result the resulting ray
  48490. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  48491. */
  48492. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  48493. /**
  48494. * Updates the controller pose based on the given XRFrame
  48495. * @param xrFrame xr frame to update the pose with
  48496. * @param referenceSpace reference space to use
  48497. */
  48498. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  48499. }
  48500. }
  48501. declare module BABYLON {
  48502. /**
  48503. * The schema for initialization options of the XR Input class
  48504. */
  48505. export interface IWebXRInputOptions {
  48506. /**
  48507. * If set to true no model will be automatically loaded
  48508. */
  48509. doNotLoadControllerMeshes?: boolean;
  48510. /**
  48511. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  48512. * If not found, the xr input profile data will be used.
  48513. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  48514. */
  48515. forceInputProfile?: string;
  48516. /**
  48517. * Do not send a request to the controller repository to load the profile.
  48518. *
  48519. * Instead, use the controllers available in babylon itself.
  48520. */
  48521. disableOnlineControllerRepository?: boolean;
  48522. /**
  48523. * A custom URL for the controllers repository
  48524. */
  48525. customControllersRepositoryURL?: string;
  48526. /**
  48527. * Should the controller model's components not move according to the user input
  48528. */
  48529. disableControllerAnimation?: boolean;
  48530. /**
  48531. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  48532. */
  48533. controllerOptions?: IWebXRControllerOptions;
  48534. }
  48535. /**
  48536. * XR input used to track XR inputs such as controllers/rays
  48537. */
  48538. export class WebXRInput implements IDisposable {
  48539. /**
  48540. * the xr session manager for this session
  48541. */
  48542. xrSessionManager: WebXRSessionManager;
  48543. /**
  48544. * the WebXR camera for this session. Mainly used for teleportation
  48545. */
  48546. xrCamera: WebXRCamera;
  48547. private readonly options;
  48548. /**
  48549. * XR controllers being tracked
  48550. */
  48551. controllers: Array<WebXRInputSource>;
  48552. private _frameObserver;
  48553. private _sessionEndedObserver;
  48554. private _sessionInitObserver;
  48555. /**
  48556. * Event when a controller has been connected/added
  48557. */
  48558. onControllerAddedObservable: Observable<WebXRInputSource>;
  48559. /**
  48560. * Event when a controller has been removed/disconnected
  48561. */
  48562. onControllerRemovedObservable: Observable<WebXRInputSource>;
  48563. /**
  48564. * Initializes the WebXRInput
  48565. * @param xrSessionManager the xr session manager for this session
  48566. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  48567. * @param options = initialization options for this xr input
  48568. */
  48569. constructor(
  48570. /**
  48571. * the xr session manager for this session
  48572. */
  48573. xrSessionManager: WebXRSessionManager,
  48574. /**
  48575. * the WebXR camera for this session. Mainly used for teleportation
  48576. */
  48577. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  48578. private _onInputSourcesChange;
  48579. private _addAndRemoveControllers;
  48580. /**
  48581. * Disposes of the object
  48582. */
  48583. dispose(): void;
  48584. }
  48585. }
  48586. declare module BABYLON {
  48587. /**
  48588. * This is the base class for all WebXR features.
  48589. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  48590. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  48591. */
  48592. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  48593. protected _xrSessionManager: WebXRSessionManager;
  48594. private _attached;
  48595. private _removeOnDetach;
  48596. /**
  48597. * Should auto-attach be disabled?
  48598. */
  48599. disableAutoAttach: boolean;
  48600. /**
  48601. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  48602. */
  48603. xrNativeFeatureName: string;
  48604. /**
  48605. * Construct a new (abstract) WebXR feature
  48606. * @param _xrSessionManager the xr session manager for this feature
  48607. */
  48608. constructor(_xrSessionManager: WebXRSessionManager);
  48609. /**
  48610. * Is this feature attached
  48611. */
  48612. get attached(): boolean;
  48613. /**
  48614. * attach this feature
  48615. *
  48616. * @param force should attachment be forced (even when already attached)
  48617. * @returns true if successful, false is failed or already attached
  48618. */
  48619. attach(force?: boolean): boolean;
  48620. /**
  48621. * detach this feature.
  48622. *
  48623. * @returns true if successful, false if failed or already detached
  48624. */
  48625. detach(): boolean;
  48626. /**
  48627. * Dispose this feature and all of the resources attached
  48628. */
  48629. dispose(): void;
  48630. /**
  48631. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48632. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48633. *
  48634. * @returns whether or not the feature is compatible in this environment
  48635. */
  48636. isCompatible(): boolean;
  48637. /**
  48638. * This is used to register callbacks that will automatically be removed when detach is called.
  48639. * @param observable the observable to which the observer will be attached
  48640. * @param callback the callback to register
  48641. */
  48642. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  48643. /**
  48644. * Code in this function will be executed on each xrFrame received from the browser.
  48645. * This function will not execute after the feature is detached.
  48646. * @param _xrFrame the current frame
  48647. */
  48648. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  48649. }
  48650. }
  48651. declare module BABYLON {
  48652. /**
  48653. * Renders a layer on top of an existing scene
  48654. */
  48655. export class UtilityLayerRenderer implements IDisposable {
  48656. /** the original scene that will be rendered on top of */
  48657. originalScene: Scene;
  48658. private _pointerCaptures;
  48659. private _lastPointerEvents;
  48660. private static _DefaultUtilityLayer;
  48661. private static _DefaultKeepDepthUtilityLayer;
  48662. private _sharedGizmoLight;
  48663. private _renderCamera;
  48664. /**
  48665. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  48666. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  48667. * @returns the camera that is used when rendering the utility layer
  48668. */
  48669. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  48670. /**
  48671. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  48672. * @param cam the camera that should be used when rendering the utility layer
  48673. */
  48674. setRenderCamera(cam: Nullable<Camera>): void;
  48675. /**
  48676. * @hidden
  48677. * Light which used by gizmos to get light shading
  48678. */
  48679. _getSharedGizmoLight(): HemisphericLight;
  48680. /**
  48681. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  48682. */
  48683. pickUtilitySceneFirst: boolean;
  48684. /**
  48685. * 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)
  48686. */
  48687. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  48688. /**
  48689. * 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)
  48690. */
  48691. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  48692. /**
  48693. * The scene that is rendered on top of the original scene
  48694. */
  48695. utilityLayerScene: Scene;
  48696. /**
  48697. * If the utility layer should automatically be rendered on top of existing scene
  48698. */
  48699. shouldRender: boolean;
  48700. /**
  48701. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  48702. */
  48703. onlyCheckPointerDownEvents: boolean;
  48704. /**
  48705. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  48706. */
  48707. processAllEvents: boolean;
  48708. /**
  48709. * Observable raised when the pointer move from the utility layer scene to the main scene
  48710. */
  48711. onPointerOutObservable: Observable<number>;
  48712. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  48713. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  48714. private _afterRenderObserver;
  48715. private _sceneDisposeObserver;
  48716. private _originalPointerObserver;
  48717. /**
  48718. * Instantiates a UtilityLayerRenderer
  48719. * @param originalScene the original scene that will be rendered on top of
  48720. * @param handleEvents boolean indicating if the utility layer should handle events
  48721. */
  48722. constructor(
  48723. /** the original scene that will be rendered on top of */
  48724. originalScene: Scene, handleEvents?: boolean);
  48725. private _notifyObservers;
  48726. /**
  48727. * Renders the utility layers scene on top of the original scene
  48728. */
  48729. render(): void;
  48730. /**
  48731. * Disposes of the renderer
  48732. */
  48733. dispose(): void;
  48734. private _updateCamera;
  48735. }
  48736. }
  48737. declare module BABYLON {
  48738. /**
  48739. * Options interface for the pointer selection module
  48740. */
  48741. export interface IWebXRControllerPointerSelectionOptions {
  48742. /**
  48743. * if provided, this scene will be used to render meshes.
  48744. */
  48745. customUtilityLayerScene?: Scene;
  48746. /**
  48747. * 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)
  48748. * If not disabled, the last picked point will be used to execute a pointer up event
  48749. * If disabled, pointer up event will be triggered right after the pointer down event.
  48750. * Used in screen and gaze target ray mode only
  48751. */
  48752. disablePointerUpOnTouchOut: boolean;
  48753. /**
  48754. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  48755. */
  48756. forceGazeMode: boolean;
  48757. /**
  48758. * 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
  48759. * to start a new countdown to the pointer down event.
  48760. * Defaults to 1.
  48761. */
  48762. gazeModePointerMovedFactor?: number;
  48763. /**
  48764. * Different button type to use instead of the main component
  48765. */
  48766. overrideButtonId?: string;
  48767. /**
  48768. * use this rendering group id for the meshes (optional)
  48769. */
  48770. renderingGroupId?: number;
  48771. /**
  48772. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  48773. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  48774. * 3000 means 3 seconds between pointing at something and selecting it
  48775. */
  48776. timeToSelect?: number;
  48777. /**
  48778. * Should meshes created here be added to a utility layer or the main scene
  48779. */
  48780. useUtilityLayer?: boolean;
  48781. /**
  48782. * Optional WebXR camera to be used for gaze selection
  48783. */
  48784. gazeCamera?: WebXRCamera;
  48785. /**
  48786. * the xr input to use with this pointer selection
  48787. */
  48788. xrInput: WebXRInput;
  48789. }
  48790. /**
  48791. * A module that will enable pointer selection for motion controllers of XR Input Sources
  48792. */
  48793. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  48794. private readonly _options;
  48795. private static _idCounter;
  48796. private _attachController;
  48797. private _controllers;
  48798. private _scene;
  48799. private _tmpVectorForPickCompare;
  48800. /**
  48801. * The module's name
  48802. */
  48803. static readonly Name: string;
  48804. /**
  48805. * The (Babylon) version of this module.
  48806. * This is an integer representing the implementation version.
  48807. * This number does not correspond to the WebXR specs version
  48808. */
  48809. static readonly Version: number;
  48810. /**
  48811. * Disable lighting on the laser pointer (so it will always be visible)
  48812. */
  48813. disablePointerLighting: boolean;
  48814. /**
  48815. * Disable lighting on the selection mesh (so it will always be visible)
  48816. */
  48817. disableSelectionMeshLighting: boolean;
  48818. /**
  48819. * Should the laser pointer be displayed
  48820. */
  48821. displayLaserPointer: boolean;
  48822. /**
  48823. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  48824. */
  48825. displaySelectionMesh: boolean;
  48826. /**
  48827. * This color will be set to the laser pointer when selection is triggered
  48828. */
  48829. laserPointerPickedColor: Color3;
  48830. /**
  48831. * Default color of the laser pointer
  48832. */
  48833. laserPointerDefaultColor: Color3;
  48834. /**
  48835. * default color of the selection ring
  48836. */
  48837. selectionMeshDefaultColor: Color3;
  48838. /**
  48839. * This color will be applied to the selection ring when selection is triggered
  48840. */
  48841. selectionMeshPickedColor: Color3;
  48842. /**
  48843. * Optional filter to be used for ray selection. This predicate shares behavior with
  48844. * scene.pointerMovePredicate which takes priority if it is also assigned.
  48845. */
  48846. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48847. /**
  48848. * constructs a new background remover module
  48849. * @param _xrSessionManager the session manager for this module
  48850. * @param _options read-only options to be used in this module
  48851. */
  48852. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  48853. /**
  48854. * attach this feature
  48855. * Will usually be called by the features manager
  48856. *
  48857. * @returns true if successful.
  48858. */
  48859. attach(): boolean;
  48860. /**
  48861. * detach this feature.
  48862. * Will usually be called by the features manager
  48863. *
  48864. * @returns true if successful.
  48865. */
  48866. detach(): boolean;
  48867. /**
  48868. * Will get the mesh under a specific pointer.
  48869. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  48870. * @param controllerId the controllerId to check
  48871. * @returns The mesh under pointer or null if no mesh is under the pointer
  48872. */
  48873. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  48874. /**
  48875. * Get the xr controller that correlates to the pointer id in the pointer event
  48876. *
  48877. * @param id the pointer id to search for
  48878. * @returns the controller that correlates to this id or null if not found
  48879. */
  48880. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  48881. protected _onXRFrame(_xrFrame: XRFrame): void;
  48882. private _attachGazeMode;
  48883. private _attachScreenRayMode;
  48884. private _attachTrackedPointerRayMode;
  48885. private _convertNormalToDirectionOfRay;
  48886. private _detachController;
  48887. private _generateNewMeshPair;
  48888. private _pickingMoved;
  48889. private _updatePointerDistance;
  48890. /** @hidden */
  48891. get lasterPointerDefaultColor(): Color3;
  48892. }
  48893. }
  48894. declare module BABYLON {
  48895. /**
  48896. * Button which can be used to enter a different mode of XR
  48897. */
  48898. export class WebXREnterExitUIButton {
  48899. /** button element */
  48900. element: HTMLElement;
  48901. /** XR initialization options for the button */
  48902. sessionMode: XRSessionMode;
  48903. /** Reference space type */
  48904. referenceSpaceType: XRReferenceSpaceType;
  48905. /**
  48906. * Creates a WebXREnterExitUIButton
  48907. * @param element button element
  48908. * @param sessionMode XR initialization session mode
  48909. * @param referenceSpaceType the type of reference space to be used
  48910. */
  48911. constructor(
  48912. /** button element */
  48913. element: HTMLElement,
  48914. /** XR initialization options for the button */
  48915. sessionMode: XRSessionMode,
  48916. /** Reference space type */
  48917. referenceSpaceType: XRReferenceSpaceType);
  48918. /**
  48919. * Extendable function which can be used to update the button's visuals when the state changes
  48920. * @param activeButton the current active button in the UI
  48921. */
  48922. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  48923. }
  48924. /**
  48925. * Options to create the webXR UI
  48926. */
  48927. export class WebXREnterExitUIOptions {
  48928. /**
  48929. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  48930. */
  48931. customButtons?: Array<WebXREnterExitUIButton>;
  48932. /**
  48933. * A reference space type to use when creating the default button.
  48934. * Default is local-floor
  48935. */
  48936. referenceSpaceType?: XRReferenceSpaceType;
  48937. /**
  48938. * Context to enter xr with
  48939. */
  48940. renderTarget?: Nullable<WebXRRenderTarget>;
  48941. /**
  48942. * A session mode to use when creating the default button.
  48943. * Default is immersive-vr
  48944. */
  48945. sessionMode?: XRSessionMode;
  48946. /**
  48947. * A list of optional features to init the session with
  48948. */
  48949. optionalFeatures?: string[];
  48950. /**
  48951. * A list of optional features to init the session with
  48952. */
  48953. requiredFeatures?: string[];
  48954. }
  48955. /**
  48956. * UI to allow the user to enter/exit XR mode
  48957. */
  48958. export class WebXREnterExitUI implements IDisposable {
  48959. private scene;
  48960. /** version of the options passed to this UI */
  48961. options: WebXREnterExitUIOptions;
  48962. private _activeButton;
  48963. private _buttons;
  48964. private _overlay;
  48965. /**
  48966. * Fired every time the active button is changed.
  48967. *
  48968. * When xr is entered via a button that launches xr that button will be the callback parameter
  48969. *
  48970. * When exiting xr the callback parameter will be null)
  48971. */
  48972. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  48973. /**
  48974. *
  48975. * @param scene babylon scene object to use
  48976. * @param options (read-only) version of the options passed to this UI
  48977. */
  48978. private constructor();
  48979. /**
  48980. * Creates UI to allow the user to enter/exit XR mode
  48981. * @param scene the scene to add the ui to
  48982. * @param helper the xr experience helper to enter/exit xr with
  48983. * @param options options to configure the UI
  48984. * @returns the created ui
  48985. */
  48986. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  48987. /**
  48988. * Disposes of the XR UI component
  48989. */
  48990. dispose(): void;
  48991. private _updateButtons;
  48992. }
  48993. }
  48994. declare module BABYLON {
  48995. /**
  48996. * Class containing static functions to help procedurally build meshes
  48997. */
  48998. export class LinesBuilder {
  48999. /**
  49000. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49001. * * 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
  49002. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49003. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49004. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49005. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49006. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49007. * * 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
  49008. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49009. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49010. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49011. * @param name defines the name of the new line system
  49012. * @param options defines the options used to create the line system
  49013. * @param scene defines the hosting scene
  49014. * @returns a new line system mesh
  49015. */
  49016. static CreateLineSystem(name: string, options: {
  49017. lines: Vector3[][];
  49018. updatable?: boolean;
  49019. instance?: Nullable<LinesMesh>;
  49020. colors?: Nullable<Color4[][]>;
  49021. useVertexAlpha?: boolean;
  49022. }, scene: Nullable<Scene>): LinesMesh;
  49023. /**
  49024. * Creates a line mesh
  49025. * 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
  49026. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49027. * * The parameter `points` is an array successive Vector3
  49028. * * 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
  49029. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49030. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49031. * * When updating an instance, remember that only point positions can change, not the number of points
  49032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49033. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49034. * @param name defines the name of the new line system
  49035. * @param options defines the options used to create the line system
  49036. * @param scene defines the hosting scene
  49037. * @returns a new line mesh
  49038. */
  49039. static CreateLines(name: string, options: {
  49040. points: Vector3[];
  49041. updatable?: boolean;
  49042. instance?: Nullable<LinesMesh>;
  49043. colors?: Color4[];
  49044. useVertexAlpha?: boolean;
  49045. }, scene?: Nullable<Scene>): LinesMesh;
  49046. /**
  49047. * Creates a dashed line mesh
  49048. * * 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
  49049. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49050. * * The parameter `points` is an array successive Vector3
  49051. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49052. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49053. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49054. * * 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
  49055. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49056. * * When updating an instance, remember that only point positions can change, not the number of points
  49057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49058. * @param name defines the name of the mesh
  49059. * @param options defines the options used to create the mesh
  49060. * @param scene defines the hosting scene
  49061. * @returns the dashed line mesh
  49062. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49063. */
  49064. static CreateDashedLines(name: string, options: {
  49065. points: Vector3[];
  49066. dashSize?: number;
  49067. gapSize?: number;
  49068. dashNb?: number;
  49069. updatable?: boolean;
  49070. instance?: LinesMesh;
  49071. useVertexAlpha?: boolean;
  49072. }, scene?: Nullable<Scene>): LinesMesh;
  49073. }
  49074. }
  49075. declare module BABYLON {
  49076. /**
  49077. * Construction options for a timer
  49078. */
  49079. export interface ITimerOptions<T> {
  49080. /**
  49081. * Time-to-end
  49082. */
  49083. timeout: number;
  49084. /**
  49085. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  49086. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  49087. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  49088. */
  49089. contextObservable: Observable<T>;
  49090. /**
  49091. * Optional parameters when adding an observer to the observable
  49092. */
  49093. observableParameters?: {
  49094. mask?: number;
  49095. insertFirst?: boolean;
  49096. scope?: any;
  49097. };
  49098. /**
  49099. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  49100. */
  49101. breakCondition?: (data?: ITimerData<T>) => boolean;
  49102. /**
  49103. * Will be triggered when the time condition has met
  49104. */
  49105. onEnded?: (data: ITimerData<any>) => void;
  49106. /**
  49107. * Will be triggered when the break condition has met (prematurely ended)
  49108. */
  49109. onAborted?: (data: ITimerData<any>) => void;
  49110. /**
  49111. * Optional function to execute on each tick (or count)
  49112. */
  49113. onTick?: (data: ITimerData<any>) => void;
  49114. }
  49115. /**
  49116. * An interface defining the data sent by the timer
  49117. */
  49118. export interface ITimerData<T> {
  49119. /**
  49120. * When did it start
  49121. */
  49122. startTime: number;
  49123. /**
  49124. * Time now
  49125. */
  49126. currentTime: number;
  49127. /**
  49128. * Time passed since started
  49129. */
  49130. deltaTime: number;
  49131. /**
  49132. * How much is completed, in [0.0...1.0].
  49133. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  49134. */
  49135. completeRate: number;
  49136. /**
  49137. * What the registered observable sent in the last count
  49138. */
  49139. payload: T;
  49140. }
  49141. /**
  49142. * The current state of the timer
  49143. */
  49144. export enum TimerState {
  49145. /**
  49146. * Timer initialized, not yet started
  49147. */
  49148. INIT = 0,
  49149. /**
  49150. * Timer started and counting
  49151. */
  49152. STARTED = 1,
  49153. /**
  49154. * Timer ended (whether aborted or time reached)
  49155. */
  49156. ENDED = 2
  49157. }
  49158. /**
  49159. * A simple version of the timer. Will take options and start the timer immediately after calling it
  49160. *
  49161. * @param options options with which to initialize this timer
  49162. */
  49163. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  49164. /**
  49165. * An advanced implementation of a timer class
  49166. */
  49167. export class AdvancedTimer<T = any> implements IDisposable {
  49168. /**
  49169. * Will notify each time the timer calculates the remaining time
  49170. */
  49171. onEachCountObservable: Observable<ITimerData<T>>;
  49172. /**
  49173. * Will trigger when the timer was aborted due to the break condition
  49174. */
  49175. onTimerAbortedObservable: Observable<ITimerData<T>>;
  49176. /**
  49177. * Will trigger when the timer ended successfully
  49178. */
  49179. onTimerEndedObservable: Observable<ITimerData<T>>;
  49180. /**
  49181. * Will trigger when the timer state has changed
  49182. */
  49183. onStateChangedObservable: Observable<TimerState>;
  49184. private _observer;
  49185. private _contextObservable;
  49186. private _observableParameters;
  49187. private _startTime;
  49188. private _timer;
  49189. private _state;
  49190. private _breakCondition;
  49191. private _timeToEnd;
  49192. private _breakOnNextTick;
  49193. /**
  49194. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  49195. * @param options construction options for this advanced timer
  49196. */
  49197. constructor(options: ITimerOptions<T>);
  49198. /**
  49199. * set a breaking condition for this timer. Default is to never break during count
  49200. * @param predicate the new break condition. Returns true to break, false otherwise
  49201. */
  49202. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  49203. /**
  49204. * Reset ALL associated observables in this advanced timer
  49205. */
  49206. clearObservables(): void;
  49207. /**
  49208. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  49209. *
  49210. * @param timeToEnd how much time to measure until timer ended
  49211. */
  49212. start(timeToEnd?: number): void;
  49213. /**
  49214. * Will force a stop on the next tick.
  49215. */
  49216. stop(): void;
  49217. /**
  49218. * Dispose this timer, clearing all resources
  49219. */
  49220. dispose(): void;
  49221. private _setState;
  49222. private _tick;
  49223. private _stop;
  49224. }
  49225. }
  49226. declare module BABYLON {
  49227. /**
  49228. * The options container for the teleportation module
  49229. */
  49230. export interface IWebXRTeleportationOptions {
  49231. /**
  49232. * if provided, this scene will be used to render meshes.
  49233. */
  49234. customUtilityLayerScene?: Scene;
  49235. /**
  49236. * Values to configure the default target mesh
  49237. */
  49238. defaultTargetMeshOptions?: {
  49239. /**
  49240. * Fill color of the teleportation area
  49241. */
  49242. teleportationFillColor?: string;
  49243. /**
  49244. * Border color for the teleportation area
  49245. */
  49246. teleportationBorderColor?: string;
  49247. /**
  49248. * Disable the mesh's animation sequence
  49249. */
  49250. disableAnimation?: boolean;
  49251. /**
  49252. * Disable lighting on the material or the ring and arrow
  49253. */
  49254. disableLighting?: boolean;
  49255. /**
  49256. * Override the default material of the torus and arrow
  49257. */
  49258. torusArrowMaterial?: Material;
  49259. };
  49260. /**
  49261. * A list of meshes to use as floor meshes.
  49262. * Meshes can be added and removed after initializing the feature using the
  49263. * addFloorMesh and removeFloorMesh functions
  49264. * If empty, rotation will still work
  49265. */
  49266. floorMeshes?: AbstractMesh[];
  49267. /**
  49268. * use this rendering group id for the meshes (optional)
  49269. */
  49270. renderingGroupId?: number;
  49271. /**
  49272. * Should teleportation move only to snap points
  49273. */
  49274. snapPointsOnly?: boolean;
  49275. /**
  49276. * An array of points to which the teleportation will snap to.
  49277. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  49278. */
  49279. snapPositions?: Vector3[];
  49280. /**
  49281. * How close should the teleportation ray be in order to snap to position.
  49282. * Default to 0.8 units (meters)
  49283. */
  49284. snapToPositionRadius?: number;
  49285. /**
  49286. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  49287. * If you want to support rotation, make sure your mesh has a direction indicator.
  49288. *
  49289. * When left untouched, the default mesh will be initialized.
  49290. */
  49291. teleportationTargetMesh?: AbstractMesh;
  49292. /**
  49293. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  49294. */
  49295. timeToTeleport?: number;
  49296. /**
  49297. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  49298. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  49299. */
  49300. useMainComponentOnly?: boolean;
  49301. /**
  49302. * Should meshes created here be added to a utility layer or the main scene
  49303. */
  49304. useUtilityLayer?: boolean;
  49305. /**
  49306. * Babylon XR Input class for controller
  49307. */
  49308. xrInput: WebXRInput;
  49309. }
  49310. /**
  49311. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  49312. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  49313. * the input of the attached controllers.
  49314. */
  49315. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  49316. private _options;
  49317. private _controllers;
  49318. private _currentTeleportationControllerId;
  49319. private _floorMeshes;
  49320. private _quadraticBezierCurve;
  49321. private _selectionFeature;
  49322. private _snapToPositions;
  49323. private _snappedToPoint;
  49324. private _teleportationRingMaterial?;
  49325. private _tmpRay;
  49326. private _tmpVector;
  49327. /**
  49328. * The module's name
  49329. */
  49330. static readonly Name: string;
  49331. /**
  49332. * The (Babylon) version of this module.
  49333. * This is an integer representing the implementation version.
  49334. * This number does not correspond to the webxr specs version
  49335. */
  49336. static readonly Version: number;
  49337. /**
  49338. * Is movement backwards enabled
  49339. */
  49340. backwardsMovementEnabled: boolean;
  49341. /**
  49342. * Distance to travel when moving backwards
  49343. */
  49344. backwardsTeleportationDistance: number;
  49345. /**
  49346. * The distance from the user to the inspection point in the direction of the controller
  49347. * A higher number will allow the user to move further
  49348. * defaults to 5 (meters, in xr units)
  49349. */
  49350. parabolicCheckRadius: number;
  49351. /**
  49352. * Should the module support parabolic ray on top of direct ray
  49353. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  49354. * Very helpful when moving between floors / different heights
  49355. */
  49356. parabolicRayEnabled: boolean;
  49357. /**
  49358. * How much rotation should be applied when rotating right and left
  49359. */
  49360. rotationAngle: number;
  49361. /**
  49362. * Is rotation enabled when moving forward?
  49363. * Disabling this feature will prevent the user from deciding the direction when teleporting
  49364. */
  49365. rotationEnabled: boolean;
  49366. /**
  49367. * constructs a new anchor system
  49368. * @param _xrSessionManager an instance of WebXRSessionManager
  49369. * @param _options configuration object for this feature
  49370. */
  49371. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  49372. /**
  49373. * Get the snapPointsOnly flag
  49374. */
  49375. get snapPointsOnly(): boolean;
  49376. /**
  49377. * Sets the snapPointsOnly flag
  49378. * @param snapToPoints should teleportation be exclusively to snap points
  49379. */
  49380. set snapPointsOnly(snapToPoints: boolean);
  49381. /**
  49382. * Add a new mesh to the floor meshes array
  49383. * @param mesh the mesh to use as floor mesh
  49384. */
  49385. addFloorMesh(mesh: AbstractMesh): void;
  49386. /**
  49387. * Add a new snap-to point to fix teleportation to this position
  49388. * @param newSnapPoint The new Snap-To point
  49389. */
  49390. addSnapPoint(newSnapPoint: Vector3): void;
  49391. attach(): boolean;
  49392. detach(): boolean;
  49393. dispose(): void;
  49394. /**
  49395. * Remove a mesh from the floor meshes array
  49396. * @param mesh the mesh to remove
  49397. */
  49398. removeFloorMesh(mesh: AbstractMesh): void;
  49399. /**
  49400. * Remove a mesh from the floor meshes array using its name
  49401. * @param name the mesh name to remove
  49402. */
  49403. removeFloorMeshByName(name: string): void;
  49404. /**
  49405. * 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
  49406. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  49407. * @returns was the point found and removed or not
  49408. */
  49409. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  49410. /**
  49411. * This function sets a selection feature that will be disabled when
  49412. * the forward ray is shown and will be reattached when hidden.
  49413. * This is used to remove the selection rays when moving.
  49414. * @param selectionFeature the feature to disable when forward movement is enabled
  49415. */
  49416. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  49417. protected _onXRFrame(_xrFrame: XRFrame): void;
  49418. private _attachController;
  49419. private _createDefaultTargetMesh;
  49420. private _detachController;
  49421. private _findClosestSnapPointWithRadius;
  49422. private _setTargetMeshPosition;
  49423. private _setTargetMeshVisibility;
  49424. private _showParabolicPath;
  49425. private _teleportForward;
  49426. }
  49427. }
  49428. declare module BABYLON {
  49429. /**
  49430. * Options for the default xr helper
  49431. */
  49432. export class WebXRDefaultExperienceOptions {
  49433. /**
  49434. * Enable or disable default UI to enter XR
  49435. */
  49436. disableDefaultUI?: boolean;
  49437. /**
  49438. * Should teleportation not initialize. defaults to false.
  49439. */
  49440. disableTeleportation?: boolean;
  49441. /**
  49442. * Floor meshes that will be used for teleport
  49443. */
  49444. floorMeshes?: Array<AbstractMesh>;
  49445. /**
  49446. * If set to true, the first frame will not be used to reset position
  49447. * The first frame is mainly used when copying transformation from the old camera
  49448. * Mainly used in AR
  49449. */
  49450. ignoreNativeCameraTransformation?: boolean;
  49451. /**
  49452. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  49453. */
  49454. inputOptions?: IWebXRInputOptions;
  49455. /**
  49456. * optional configuration for the output canvas
  49457. */
  49458. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  49459. /**
  49460. * optional UI options. This can be used among other to change session mode and reference space type
  49461. */
  49462. uiOptions?: WebXREnterExitUIOptions;
  49463. /**
  49464. * When loading teleportation and pointer select, use stable versions instead of latest.
  49465. */
  49466. useStablePlugins?: boolean;
  49467. /**
  49468. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  49469. */
  49470. renderingGroupId?: number;
  49471. /**
  49472. * A list of optional features to init the session with
  49473. * If set to true, all features we support will be added
  49474. */
  49475. optionalFeatures?: boolean | string[];
  49476. }
  49477. /**
  49478. * Default experience which provides a similar setup to the previous webVRExperience
  49479. */
  49480. export class WebXRDefaultExperience {
  49481. /**
  49482. * Base experience
  49483. */
  49484. baseExperience: WebXRExperienceHelper;
  49485. /**
  49486. * Enables ui for entering/exiting xr
  49487. */
  49488. enterExitUI: WebXREnterExitUI;
  49489. /**
  49490. * Input experience extension
  49491. */
  49492. input: WebXRInput;
  49493. /**
  49494. * Enables laser pointer and selection
  49495. */
  49496. pointerSelection: WebXRControllerPointerSelection;
  49497. /**
  49498. * Default target xr should render to
  49499. */
  49500. renderTarget: WebXRRenderTarget;
  49501. /**
  49502. * Enables teleportation
  49503. */
  49504. teleportation: WebXRMotionControllerTeleportation;
  49505. private constructor();
  49506. /**
  49507. * Creates the default xr experience
  49508. * @param scene scene
  49509. * @param options options for basic configuration
  49510. * @returns resulting WebXRDefaultExperience
  49511. */
  49512. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49513. /**
  49514. * DIsposes of the experience helper
  49515. */
  49516. dispose(): void;
  49517. }
  49518. }
  49519. declare module BABYLON {
  49520. /**
  49521. * Options to modify the vr teleportation behavior.
  49522. */
  49523. export interface VRTeleportationOptions {
  49524. /**
  49525. * The name of the mesh which should be used as the teleportation floor. (default: null)
  49526. */
  49527. floorMeshName?: string;
  49528. /**
  49529. * A list of meshes to be used as the teleportation floor. (default: empty)
  49530. */
  49531. floorMeshes?: Mesh[];
  49532. /**
  49533. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  49534. */
  49535. teleportationMode?: number;
  49536. /**
  49537. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  49538. */
  49539. teleportationTime?: number;
  49540. /**
  49541. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  49542. */
  49543. teleportationSpeed?: number;
  49544. /**
  49545. * The easing function used in the animation or null for Linear. (default CircleEase)
  49546. */
  49547. easingFunction?: EasingFunction;
  49548. }
  49549. /**
  49550. * Options to modify the vr experience helper's behavior.
  49551. */
  49552. export interface VRExperienceHelperOptions extends WebVROptions {
  49553. /**
  49554. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  49555. */
  49556. createDeviceOrientationCamera?: boolean;
  49557. /**
  49558. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  49559. */
  49560. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  49561. /**
  49562. * Uses the main button on the controller to toggle the laser casted. (default: true)
  49563. */
  49564. laserToggle?: boolean;
  49565. /**
  49566. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  49567. */
  49568. floorMeshes?: Mesh[];
  49569. /**
  49570. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  49571. */
  49572. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  49573. /**
  49574. * Defines if WebXR should be used instead of WebVR (if available)
  49575. */
  49576. useXR?: boolean;
  49577. }
  49578. /**
  49579. * Event containing information after VR has been entered
  49580. */
  49581. export class OnAfterEnteringVRObservableEvent {
  49582. /**
  49583. * If entering vr was successful
  49584. */
  49585. success: boolean;
  49586. }
  49587. /**
  49588. * Helps to quickly add VR support to an existing scene.
  49589. * See https://doc.babylonjs.com/how_to/webvr_helper
  49590. */
  49591. export class VRExperienceHelper {
  49592. /** Options to modify the vr experience helper's behavior. */
  49593. webVROptions: VRExperienceHelperOptions;
  49594. private _scene;
  49595. private _position;
  49596. private _btnVR;
  49597. private _btnVRDisplayed;
  49598. private _webVRsupported;
  49599. private _webVRready;
  49600. private _webVRrequesting;
  49601. private _webVRpresenting;
  49602. private _hasEnteredVR;
  49603. private _fullscreenVRpresenting;
  49604. private _inputElement;
  49605. private _webVRCamera;
  49606. private _vrDeviceOrientationCamera;
  49607. private _deviceOrientationCamera;
  49608. private _existingCamera;
  49609. private _onKeyDown;
  49610. private _onVrDisplayPresentChange;
  49611. private _onVRDisplayChanged;
  49612. private _onVRRequestPresentStart;
  49613. private _onVRRequestPresentComplete;
  49614. /**
  49615. * 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)
  49616. */
  49617. enableGazeEvenWhenNoPointerLock: boolean;
  49618. /**
  49619. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  49620. */
  49621. exitVROnDoubleTap: boolean;
  49622. /**
  49623. * Observable raised right before entering VR.
  49624. */
  49625. onEnteringVRObservable: Observable<VRExperienceHelper>;
  49626. /**
  49627. * Observable raised when entering VR has completed.
  49628. */
  49629. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  49630. /**
  49631. * Observable raised when exiting VR.
  49632. */
  49633. onExitingVRObservable: Observable<VRExperienceHelper>;
  49634. /**
  49635. * Observable raised when controller mesh is loaded.
  49636. */
  49637. onControllerMeshLoadedObservable: Observable<WebVRController>;
  49638. /** Return this.onEnteringVRObservable
  49639. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  49640. */
  49641. get onEnteringVR(): Observable<VRExperienceHelper>;
  49642. /** Return this.onExitingVRObservable
  49643. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  49644. */
  49645. get onExitingVR(): Observable<VRExperienceHelper>;
  49646. /** Return this.onControllerMeshLoadedObservable
  49647. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  49648. */
  49649. get onControllerMeshLoaded(): Observable<WebVRController>;
  49650. private _rayLength;
  49651. private _useCustomVRButton;
  49652. private _teleportationRequested;
  49653. private _teleportActive;
  49654. private _floorMeshName;
  49655. private _floorMeshesCollection;
  49656. private _teleportationMode;
  49657. private _teleportationTime;
  49658. private _teleportationSpeed;
  49659. private _teleportationEasing;
  49660. private _rotationAllowed;
  49661. private _teleportBackwardsVector;
  49662. private _teleportationTarget;
  49663. private _isDefaultTeleportationTarget;
  49664. private _postProcessMove;
  49665. private _teleportationFillColor;
  49666. private _teleportationBorderColor;
  49667. private _rotationAngle;
  49668. private _haloCenter;
  49669. private _cameraGazer;
  49670. private _padSensibilityUp;
  49671. private _padSensibilityDown;
  49672. private _leftController;
  49673. private _rightController;
  49674. private _gazeColor;
  49675. private _laserColor;
  49676. private _pickedLaserColor;
  49677. private _pickedGazeColor;
  49678. /**
  49679. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  49680. */
  49681. onNewMeshSelected: Observable<AbstractMesh>;
  49682. /**
  49683. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  49684. * This observable will provide the mesh and the controller used to select the mesh
  49685. */
  49686. onMeshSelectedWithController: Observable<{
  49687. mesh: AbstractMesh;
  49688. controller: WebVRController;
  49689. }>;
  49690. /**
  49691. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  49692. */
  49693. onNewMeshPicked: Observable<PickingInfo>;
  49694. private _circleEase;
  49695. /**
  49696. * Observable raised before camera teleportation
  49697. */
  49698. onBeforeCameraTeleport: Observable<Vector3>;
  49699. /**
  49700. * Observable raised after camera teleportation
  49701. */
  49702. onAfterCameraTeleport: Observable<Vector3>;
  49703. /**
  49704. * Observable raised when current selected mesh gets unselected
  49705. */
  49706. onSelectedMeshUnselected: Observable<AbstractMesh>;
  49707. private _raySelectionPredicate;
  49708. /**
  49709. * To be optionaly changed by user to define custom ray selection
  49710. */
  49711. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49712. /**
  49713. * To be optionaly changed by user to define custom selection logic (after ray selection)
  49714. */
  49715. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49716. /**
  49717. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  49718. */
  49719. teleportationEnabled: boolean;
  49720. private _defaultHeight;
  49721. private _teleportationInitialized;
  49722. private _interactionsEnabled;
  49723. private _interactionsRequested;
  49724. private _displayGaze;
  49725. private _displayLaserPointer;
  49726. /**
  49727. * The mesh used to display where the user is going to teleport.
  49728. */
  49729. get teleportationTarget(): Mesh;
  49730. /**
  49731. * Sets the mesh to be used to display where the user is going to teleport.
  49732. */
  49733. set teleportationTarget(value: Mesh);
  49734. /**
  49735. * 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
  49736. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  49737. * See https://doc.babylonjs.com/resources/baking_transformations
  49738. */
  49739. get gazeTrackerMesh(): Mesh;
  49740. set gazeTrackerMesh(value: Mesh);
  49741. /**
  49742. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  49743. */
  49744. updateGazeTrackerScale: boolean;
  49745. /**
  49746. * If the gaze trackers color should be updated when selecting meshes
  49747. */
  49748. updateGazeTrackerColor: boolean;
  49749. /**
  49750. * If the controller laser color should be updated when selecting meshes
  49751. */
  49752. updateControllerLaserColor: boolean;
  49753. /**
  49754. * The gaze tracking mesh corresponding to the left controller
  49755. */
  49756. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  49757. /**
  49758. * The gaze tracking mesh corresponding to the right controller
  49759. */
  49760. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  49761. /**
  49762. * If the ray of the gaze should be displayed.
  49763. */
  49764. get displayGaze(): boolean;
  49765. /**
  49766. * Sets if the ray of the gaze should be displayed.
  49767. */
  49768. set displayGaze(value: boolean);
  49769. /**
  49770. * If the ray of the LaserPointer should be displayed.
  49771. */
  49772. get displayLaserPointer(): boolean;
  49773. /**
  49774. * Sets if the ray of the LaserPointer should be displayed.
  49775. */
  49776. set displayLaserPointer(value: boolean);
  49777. /**
  49778. * The deviceOrientationCamera used as the camera when not in VR.
  49779. */
  49780. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  49781. /**
  49782. * Based on the current WebVR support, returns the current VR camera used.
  49783. */
  49784. get currentVRCamera(): Nullable<Camera>;
  49785. /**
  49786. * The webVRCamera which is used when in VR.
  49787. */
  49788. get webVRCamera(): WebVRFreeCamera;
  49789. /**
  49790. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  49791. */
  49792. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  49793. /**
  49794. * The html button that is used to trigger entering into VR.
  49795. */
  49796. get vrButton(): Nullable<HTMLButtonElement>;
  49797. private get _teleportationRequestInitiated();
  49798. /**
  49799. * Defines whether or not Pointer lock should be requested when switching to
  49800. * full screen.
  49801. */
  49802. requestPointerLockOnFullScreen: boolean;
  49803. /**
  49804. * If asking to force XR, this will be populated with the default xr experience
  49805. */
  49806. xr: WebXRDefaultExperience;
  49807. /**
  49808. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  49809. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  49810. */
  49811. xrTestDone: boolean;
  49812. /**
  49813. * Instantiates a VRExperienceHelper.
  49814. * Helps to quickly add VR support to an existing scene.
  49815. * @param scene The scene the VRExperienceHelper belongs to.
  49816. * @param webVROptions Options to modify the vr experience helper's behavior.
  49817. */
  49818. constructor(scene: Scene,
  49819. /** Options to modify the vr experience helper's behavior. */
  49820. webVROptions?: VRExperienceHelperOptions);
  49821. private completeVRInit;
  49822. private _onDefaultMeshLoaded;
  49823. private _onResize;
  49824. private _onFullscreenChange;
  49825. /**
  49826. * Gets a value indicating if we are currently in VR mode.
  49827. */
  49828. get isInVRMode(): boolean;
  49829. private onVrDisplayPresentChange;
  49830. private onVRDisplayChanged;
  49831. private moveButtonToBottomRight;
  49832. private displayVRButton;
  49833. private updateButtonVisibility;
  49834. private _cachedAngularSensibility;
  49835. /**
  49836. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  49837. * Otherwise, will use the fullscreen API.
  49838. */
  49839. enterVR(): void;
  49840. /**
  49841. * Attempt to exit VR, or fullscreen.
  49842. */
  49843. exitVR(): void;
  49844. /**
  49845. * The position of the vr experience helper.
  49846. */
  49847. get position(): Vector3;
  49848. /**
  49849. * Sets the position of the vr experience helper.
  49850. */
  49851. set position(value: Vector3);
  49852. /**
  49853. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  49854. */
  49855. enableInteractions(): void;
  49856. private get _noControllerIsActive();
  49857. private beforeRender;
  49858. private _isTeleportationFloor;
  49859. /**
  49860. * Adds a floor mesh to be used for teleportation.
  49861. * @param floorMesh the mesh to be used for teleportation.
  49862. */
  49863. addFloorMesh(floorMesh: Mesh): void;
  49864. /**
  49865. * Removes a floor mesh from being used for teleportation.
  49866. * @param floorMesh the mesh to be removed.
  49867. */
  49868. removeFloorMesh(floorMesh: Mesh): void;
  49869. /**
  49870. * Enables interactions and teleportation using the VR controllers and gaze.
  49871. * @param vrTeleportationOptions options to modify teleportation behavior.
  49872. */
  49873. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  49874. private _onNewGamepadConnected;
  49875. private _tryEnableInteractionOnController;
  49876. private _onNewGamepadDisconnected;
  49877. private _enableInteractionOnController;
  49878. private _checkTeleportWithRay;
  49879. private _checkRotate;
  49880. private _checkTeleportBackwards;
  49881. private _enableTeleportationOnController;
  49882. private _createTeleportationCircles;
  49883. private _displayTeleportationTarget;
  49884. private _hideTeleportationTarget;
  49885. private _rotateCamera;
  49886. private _moveTeleportationSelectorTo;
  49887. private _workingVector;
  49888. private _workingQuaternion;
  49889. private _workingMatrix;
  49890. /**
  49891. * Time Constant Teleportation Mode
  49892. */
  49893. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  49894. /**
  49895. * Speed Constant Teleportation Mode
  49896. */
  49897. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  49898. /**
  49899. * Teleports the users feet to the desired location
  49900. * @param location The location where the user's feet should be placed
  49901. */
  49902. teleportCamera(location: Vector3): void;
  49903. private _convertNormalToDirectionOfRay;
  49904. private _castRayAndSelectObject;
  49905. private _notifySelectedMeshUnselected;
  49906. /**
  49907. * Permanently set new colors for the laser pointer
  49908. * @param color the new laser color
  49909. * @param pickedColor the new laser color when picked mesh detected
  49910. */
  49911. setLaserColor(color: Color3, pickedColor?: Color3): void;
  49912. /**
  49913. * Set lighting enabled / disabled on the laser pointer of both controllers
  49914. * @param enabled should the lighting be enabled on the laser pointer
  49915. */
  49916. setLaserLightingState(enabled?: boolean): void;
  49917. /**
  49918. * Permanently set new colors for the gaze pointer
  49919. * @param color the new gaze color
  49920. * @param pickedColor the new gaze color when picked mesh detected
  49921. */
  49922. setGazeColor(color: Color3, pickedColor?: Color3): void;
  49923. /**
  49924. * Sets the color of the laser ray from the vr controllers.
  49925. * @param color new color for the ray.
  49926. */
  49927. changeLaserColor(color: Color3): void;
  49928. /**
  49929. * Sets the color of the ray from the vr headsets gaze.
  49930. * @param color new color for the ray.
  49931. */
  49932. changeGazeColor(color: Color3): void;
  49933. /**
  49934. * Exits VR and disposes of the vr experience helper
  49935. */
  49936. dispose(): void;
  49937. /**
  49938. * Gets the name of the VRExperienceHelper class
  49939. * @returns "VRExperienceHelper"
  49940. */
  49941. getClassName(): string;
  49942. }
  49943. }
  49944. declare module BABYLON {
  49945. /**
  49946. * Contains an array of blocks representing the octree
  49947. */
  49948. export interface IOctreeContainer<T> {
  49949. /**
  49950. * Blocks within the octree
  49951. */
  49952. blocks: Array<OctreeBlock<T>>;
  49953. }
  49954. /**
  49955. * Class used to store a cell in an octree
  49956. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49957. */
  49958. export class OctreeBlock<T> {
  49959. /**
  49960. * Gets the content of the current block
  49961. */
  49962. entries: T[];
  49963. /**
  49964. * Gets the list of block children
  49965. */
  49966. blocks: Array<OctreeBlock<T>>;
  49967. private _depth;
  49968. private _maxDepth;
  49969. private _capacity;
  49970. private _minPoint;
  49971. private _maxPoint;
  49972. private _boundingVectors;
  49973. private _creationFunc;
  49974. /**
  49975. * Creates a new block
  49976. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  49977. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  49978. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49979. * @param depth defines the current depth of this block in the octree
  49980. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  49981. * @param creationFunc defines a callback to call when an element is added to the block
  49982. */
  49983. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  49984. /**
  49985. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49986. */
  49987. get capacity(): number;
  49988. /**
  49989. * Gets the minimum vector (in world space) of the block's bounding box
  49990. */
  49991. get minPoint(): Vector3;
  49992. /**
  49993. * Gets the maximum vector (in world space) of the block's bounding box
  49994. */
  49995. get maxPoint(): Vector3;
  49996. /**
  49997. * Add a new element to this block
  49998. * @param entry defines the element to add
  49999. */
  50000. addEntry(entry: T): void;
  50001. /**
  50002. * Remove an element from this block
  50003. * @param entry defines the element to remove
  50004. */
  50005. removeEntry(entry: T): void;
  50006. /**
  50007. * Add an array of elements to this block
  50008. * @param entries defines the array of elements to add
  50009. */
  50010. addEntries(entries: T[]): void;
  50011. /**
  50012. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  50013. * @param frustumPlanes defines the frustum planes to test
  50014. * @param selection defines the array to store current content if selection is positive
  50015. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50016. */
  50017. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50018. /**
  50019. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  50020. * @param sphereCenter defines the bounding sphere center
  50021. * @param sphereRadius defines the bounding sphere radius
  50022. * @param selection defines the array to store current content if selection is positive
  50023. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50024. */
  50025. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50026. /**
  50027. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  50028. * @param ray defines the ray to test with
  50029. * @param selection defines the array to store current content if selection is positive
  50030. */
  50031. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  50032. /**
  50033. * Subdivide the content into child blocks (this block will then be empty)
  50034. */
  50035. createInnerBlocks(): void;
  50036. /**
  50037. * @hidden
  50038. */
  50039. 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;
  50040. }
  50041. }
  50042. declare module BABYLON {
  50043. /**
  50044. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  50045. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50046. */
  50047. export class Octree<T> {
  50048. /** 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.) */
  50049. maxDepth: number;
  50050. /**
  50051. * Blocks within the octree containing objects
  50052. */
  50053. blocks: Array<OctreeBlock<T>>;
  50054. /**
  50055. * Content stored in the octree
  50056. */
  50057. dynamicContent: T[];
  50058. private _maxBlockCapacity;
  50059. private _selectionContent;
  50060. private _creationFunc;
  50061. /**
  50062. * Creates a octree
  50063. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50064. * @param creationFunc function to be used to instatiate the octree
  50065. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  50066. * @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.)
  50067. */
  50068. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  50069. /** 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.) */
  50070. maxDepth?: number);
  50071. /**
  50072. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  50073. * @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);
  50074. * @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);
  50075. * @param entries meshes to be added to the octree blocks
  50076. */
  50077. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  50078. /**
  50079. * Adds a mesh to the octree
  50080. * @param entry Mesh to add to the octree
  50081. */
  50082. addMesh(entry: T): void;
  50083. /**
  50084. * Remove an element from the octree
  50085. * @param entry defines the element to remove
  50086. */
  50087. removeMesh(entry: T): void;
  50088. /**
  50089. * Selects an array of meshes within the frustum
  50090. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  50091. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  50092. * @returns array of meshes within the frustum
  50093. */
  50094. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  50095. /**
  50096. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  50097. * @param sphereCenter defines the bounding sphere center
  50098. * @param sphereRadius defines the bounding sphere radius
  50099. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50100. * @returns an array of objects that intersect the sphere
  50101. */
  50102. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  50103. /**
  50104. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  50105. * @param ray defines the ray to test with
  50106. * @returns array of intersected objects
  50107. */
  50108. intersectsRay(ray: Ray): SmartArray<T>;
  50109. /**
  50110. * Adds a mesh into the octree block if it intersects the block
  50111. */
  50112. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  50113. /**
  50114. * Adds a submesh into the octree block if it intersects the block
  50115. */
  50116. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  50117. }
  50118. }
  50119. declare module BABYLON {
  50120. interface Scene {
  50121. /**
  50122. * @hidden
  50123. * Backing Filed
  50124. */
  50125. _selectionOctree: Octree<AbstractMesh>;
  50126. /**
  50127. * Gets the octree used to boost mesh selection (picking)
  50128. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50129. */
  50130. selectionOctree: Octree<AbstractMesh>;
  50131. /**
  50132. * Creates or updates the octree used to boost selection (picking)
  50133. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50134. * @param maxCapacity defines the maximum capacity per leaf
  50135. * @param maxDepth defines the maximum depth of the octree
  50136. * @returns an octree of AbstractMesh
  50137. */
  50138. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  50139. }
  50140. interface AbstractMesh {
  50141. /**
  50142. * @hidden
  50143. * Backing Field
  50144. */
  50145. _submeshesOctree: Octree<SubMesh>;
  50146. /**
  50147. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  50148. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  50149. * @param maxCapacity defines the maximum size of each block (64 by default)
  50150. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  50151. * @returns the new octree
  50152. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  50153. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50154. */
  50155. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  50156. }
  50157. /**
  50158. * Defines the octree scene component responsible to manage any octrees
  50159. * in a given scene.
  50160. */
  50161. export class OctreeSceneComponent {
  50162. /**
  50163. * The component name help to identify the component in the list of scene components.
  50164. */
  50165. readonly name: string;
  50166. /**
  50167. * The scene the component belongs to.
  50168. */
  50169. scene: Scene;
  50170. /**
  50171. * Indicates if the meshes have been checked to make sure they are isEnabled()
  50172. */
  50173. readonly checksIsEnabled: boolean;
  50174. /**
  50175. * Creates a new instance of the component for the given scene
  50176. * @param scene Defines the scene to register the component in
  50177. */
  50178. constructor(scene: Scene);
  50179. /**
  50180. * Registers the component in a given scene
  50181. */
  50182. register(): void;
  50183. /**
  50184. * Return the list of active meshes
  50185. * @returns the list of active meshes
  50186. */
  50187. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  50188. /**
  50189. * Return the list of active sub meshes
  50190. * @param mesh The mesh to get the candidates sub meshes from
  50191. * @returns the list of active sub meshes
  50192. */
  50193. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  50194. private _tempRay;
  50195. /**
  50196. * Return the list of sub meshes intersecting with a given local ray
  50197. * @param mesh defines the mesh to find the submesh for
  50198. * @param localRay defines the ray in local space
  50199. * @returns the list of intersecting sub meshes
  50200. */
  50201. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  50202. /**
  50203. * Return the list of sub meshes colliding with a collider
  50204. * @param mesh defines the mesh to find the submesh for
  50205. * @param collider defines the collider to evaluate the collision against
  50206. * @returns the list of colliding sub meshes
  50207. */
  50208. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  50209. /**
  50210. * Rebuilds the elements related to this component in case of
  50211. * context lost for instance.
  50212. */
  50213. rebuild(): void;
  50214. /**
  50215. * Disposes the component and the associated ressources.
  50216. */
  50217. dispose(): void;
  50218. }
  50219. }
  50220. declare module BABYLON {
  50221. /**
  50222. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  50223. */
  50224. export class Gizmo implements IDisposable {
  50225. /** The utility layer the gizmo will be added to */
  50226. gizmoLayer: UtilityLayerRenderer;
  50227. /**
  50228. * The root mesh of the gizmo
  50229. */
  50230. _rootMesh: Mesh;
  50231. private _attachedMesh;
  50232. private _attachedNode;
  50233. /**
  50234. * Ratio for the scale of the gizmo (Default: 1)
  50235. */
  50236. scaleRatio: number;
  50237. /**
  50238. * If a custom mesh has been set (Default: false)
  50239. */
  50240. protected _customMeshSet: boolean;
  50241. /**
  50242. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  50243. * * When set, interactions will be enabled
  50244. */
  50245. get attachedMesh(): Nullable<AbstractMesh>;
  50246. set attachedMesh(value: Nullable<AbstractMesh>);
  50247. /**
  50248. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  50249. * * When set, interactions will be enabled
  50250. */
  50251. get attachedNode(): Nullable<Node>;
  50252. set attachedNode(value: Nullable<Node>);
  50253. /**
  50254. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50255. * @param mesh The mesh to replace the default mesh of the gizmo
  50256. */
  50257. setCustomMesh(mesh: Mesh): void;
  50258. /**
  50259. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  50260. */
  50261. updateGizmoRotationToMatchAttachedMesh: boolean;
  50262. /**
  50263. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  50264. */
  50265. updateGizmoPositionToMatchAttachedMesh: boolean;
  50266. /**
  50267. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  50268. */
  50269. updateScale: boolean;
  50270. protected _interactionsEnabled: boolean;
  50271. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50272. private _beforeRenderObserver;
  50273. private _tempQuaternion;
  50274. private _tempVector;
  50275. private _tempVector2;
  50276. /**
  50277. * Creates a gizmo
  50278. * @param gizmoLayer The utility layer the gizmo will be added to
  50279. */
  50280. constructor(
  50281. /** The utility layer the gizmo will be added to */
  50282. gizmoLayer?: UtilityLayerRenderer);
  50283. /**
  50284. * Updates the gizmo to match the attached mesh's position/rotation
  50285. */
  50286. protected _update(): void;
  50287. /**
  50288. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  50289. * @param value Node, TransformNode or mesh
  50290. */
  50291. protected _matrixChanged(): void;
  50292. /**
  50293. * Disposes of the gizmo
  50294. */
  50295. dispose(): void;
  50296. }
  50297. }
  50298. declare module BABYLON {
  50299. /**
  50300. * Single plane drag gizmo
  50301. */
  50302. export class PlaneDragGizmo extends Gizmo {
  50303. /**
  50304. * Drag behavior responsible for the gizmos dragging interactions
  50305. */
  50306. dragBehavior: PointerDragBehavior;
  50307. private _pointerObserver;
  50308. /**
  50309. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50310. */
  50311. snapDistance: number;
  50312. /**
  50313. * Event that fires each time the gizmo snaps to a new location.
  50314. * * snapDistance is the the change in distance
  50315. */
  50316. onSnapObservable: Observable<{
  50317. snapDistance: number;
  50318. }>;
  50319. private _plane;
  50320. private _coloredMaterial;
  50321. private _hoverMaterial;
  50322. private _isEnabled;
  50323. private _parent;
  50324. /** @hidden */
  50325. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  50326. /** @hidden */
  50327. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50328. /**
  50329. * Creates a PlaneDragGizmo
  50330. * @param gizmoLayer The utility layer the gizmo will be added to
  50331. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  50332. * @param color The color of the gizmo
  50333. */
  50334. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50335. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50336. /**
  50337. * If the gizmo is enabled
  50338. */
  50339. set isEnabled(value: boolean);
  50340. get isEnabled(): boolean;
  50341. /**
  50342. * Disposes of the gizmo
  50343. */
  50344. dispose(): void;
  50345. }
  50346. }
  50347. declare module BABYLON {
  50348. /**
  50349. * Gizmo that enables dragging a mesh along 3 axis
  50350. */
  50351. export class PositionGizmo extends Gizmo {
  50352. /**
  50353. * Internal gizmo used for interactions on the x axis
  50354. */
  50355. xGizmo: AxisDragGizmo;
  50356. /**
  50357. * Internal gizmo used for interactions on the y axis
  50358. */
  50359. yGizmo: AxisDragGizmo;
  50360. /**
  50361. * Internal gizmo used for interactions on the z axis
  50362. */
  50363. zGizmo: AxisDragGizmo;
  50364. /**
  50365. * Internal gizmo used for interactions on the yz plane
  50366. */
  50367. xPlaneGizmo: PlaneDragGizmo;
  50368. /**
  50369. * Internal gizmo used for interactions on the xz plane
  50370. */
  50371. yPlaneGizmo: PlaneDragGizmo;
  50372. /**
  50373. * Internal gizmo used for interactions on the xy plane
  50374. */
  50375. zPlaneGizmo: PlaneDragGizmo;
  50376. /**
  50377. * private variables
  50378. */
  50379. private _meshAttached;
  50380. private _nodeAttached;
  50381. private _updateGizmoRotationToMatchAttachedMesh;
  50382. private _snapDistance;
  50383. private _scaleRatio;
  50384. /** Fires an event when any of it's sub gizmos are dragged */
  50385. onDragStartObservable: Observable<unknown>;
  50386. /** Fires an event when any of it's sub gizmos are released from dragging */
  50387. onDragEndObservable: Observable<unknown>;
  50388. /**
  50389. * If set to true, planar drag is enabled
  50390. */
  50391. private _planarGizmoEnabled;
  50392. get attachedMesh(): Nullable<AbstractMesh>;
  50393. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50394. get attachedNode(): Nullable<Node>;
  50395. set attachedNode(node: Nullable<Node>);
  50396. /**
  50397. * Creates a PositionGizmo
  50398. * @param gizmoLayer The utility layer the gizmo will be added to
  50399. @param thickness display gizmo axis thickness
  50400. */
  50401. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  50402. /**
  50403. * If the planar drag gizmo is enabled
  50404. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  50405. */
  50406. set planarGizmoEnabled(value: boolean);
  50407. get planarGizmoEnabled(): boolean;
  50408. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50409. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50410. /**
  50411. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50412. */
  50413. set snapDistance(value: number);
  50414. get snapDistance(): number;
  50415. /**
  50416. * Ratio for the scale of the gizmo (Default: 1)
  50417. */
  50418. set scaleRatio(value: number);
  50419. get scaleRatio(): number;
  50420. /**
  50421. * Disposes of the gizmo
  50422. */
  50423. dispose(): void;
  50424. /**
  50425. * CustomMeshes are not supported by this gizmo
  50426. * @param mesh The mesh to replace the default mesh of the gizmo
  50427. */
  50428. setCustomMesh(mesh: Mesh): void;
  50429. }
  50430. }
  50431. declare module BABYLON {
  50432. /**
  50433. * Single axis drag gizmo
  50434. */
  50435. export class AxisDragGizmo extends Gizmo {
  50436. /**
  50437. * Drag behavior responsible for the gizmos dragging interactions
  50438. */
  50439. dragBehavior: PointerDragBehavior;
  50440. private _pointerObserver;
  50441. /**
  50442. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50443. */
  50444. snapDistance: number;
  50445. /**
  50446. * Event that fires each time the gizmo snaps to a new location.
  50447. * * snapDistance is the the change in distance
  50448. */
  50449. onSnapObservable: Observable<{
  50450. snapDistance: number;
  50451. }>;
  50452. private _isEnabled;
  50453. private _parent;
  50454. private _arrow;
  50455. private _coloredMaterial;
  50456. private _hoverMaterial;
  50457. /** @hidden */
  50458. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  50459. /** @hidden */
  50460. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50461. /**
  50462. * Creates an AxisDragGizmo
  50463. * @param gizmoLayer The utility layer the gizmo will be added to
  50464. * @param dragAxis The axis which the gizmo will be able to drag on
  50465. * @param color The color of the gizmo
  50466. * @param thickness display gizmo axis thickness
  50467. */
  50468. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  50469. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50470. /**
  50471. * If the gizmo is enabled
  50472. */
  50473. set isEnabled(value: boolean);
  50474. get isEnabled(): boolean;
  50475. /**
  50476. * Disposes of the gizmo
  50477. */
  50478. dispose(): void;
  50479. }
  50480. }
  50481. declare module BABYLON.Debug {
  50482. /**
  50483. * The Axes viewer will show 3 axes in a specific point in space
  50484. */
  50485. export class AxesViewer {
  50486. private _xAxis;
  50487. private _yAxis;
  50488. private _zAxis;
  50489. private _scaleLinesFactor;
  50490. private _instanced;
  50491. /**
  50492. * Gets the hosting scene
  50493. */
  50494. scene: Scene;
  50495. /**
  50496. * Gets or sets a number used to scale line length
  50497. */
  50498. scaleLines: number;
  50499. /** Gets the node hierarchy used to render x-axis */
  50500. get xAxis(): TransformNode;
  50501. /** Gets the node hierarchy used to render y-axis */
  50502. get yAxis(): TransformNode;
  50503. /** Gets the node hierarchy used to render z-axis */
  50504. get zAxis(): TransformNode;
  50505. /**
  50506. * Creates a new AxesViewer
  50507. * @param scene defines the hosting scene
  50508. * @param scaleLines defines a number used to scale line length (1 by default)
  50509. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  50510. * @param xAxis defines the node hierarchy used to render the x-axis
  50511. * @param yAxis defines the node hierarchy used to render the y-axis
  50512. * @param zAxis defines the node hierarchy used to render the z-axis
  50513. */
  50514. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  50515. /**
  50516. * Force the viewer to update
  50517. * @param position defines the position of the viewer
  50518. * @param xaxis defines the x axis of the viewer
  50519. * @param yaxis defines the y axis of the viewer
  50520. * @param zaxis defines the z axis of the viewer
  50521. */
  50522. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  50523. /**
  50524. * Creates an instance of this axes viewer.
  50525. * @returns a new axes viewer with instanced meshes
  50526. */
  50527. createInstance(): AxesViewer;
  50528. /** Releases resources */
  50529. dispose(): void;
  50530. private static _SetRenderingGroupId;
  50531. }
  50532. }
  50533. declare module BABYLON.Debug {
  50534. /**
  50535. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  50536. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  50537. */
  50538. export class BoneAxesViewer extends AxesViewer {
  50539. /**
  50540. * Gets or sets the target mesh where to display the axes viewer
  50541. */
  50542. mesh: Nullable<Mesh>;
  50543. /**
  50544. * Gets or sets the target bone where to display the axes viewer
  50545. */
  50546. bone: Nullable<Bone>;
  50547. /** Gets current position */
  50548. pos: Vector3;
  50549. /** Gets direction of X axis */
  50550. xaxis: Vector3;
  50551. /** Gets direction of Y axis */
  50552. yaxis: Vector3;
  50553. /** Gets direction of Z axis */
  50554. zaxis: Vector3;
  50555. /**
  50556. * Creates a new BoneAxesViewer
  50557. * @param scene defines the hosting scene
  50558. * @param bone defines the target bone
  50559. * @param mesh defines the target mesh
  50560. * @param scaleLines defines a scaling factor for line length (1 by default)
  50561. */
  50562. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  50563. /**
  50564. * Force the viewer to update
  50565. */
  50566. update(): void;
  50567. /** Releases resources */
  50568. dispose(): void;
  50569. }
  50570. }
  50571. declare module BABYLON {
  50572. /**
  50573. * Interface used to define scene explorer extensibility option
  50574. */
  50575. export interface IExplorerExtensibilityOption {
  50576. /**
  50577. * Define the option label
  50578. */
  50579. label: string;
  50580. /**
  50581. * Defines the action to execute on click
  50582. */
  50583. action: (entity: any) => void;
  50584. }
  50585. /**
  50586. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  50587. */
  50588. export interface IExplorerExtensibilityGroup {
  50589. /**
  50590. * Defines a predicate to test if a given type mut be extended
  50591. */
  50592. predicate: (entity: any) => boolean;
  50593. /**
  50594. * Gets the list of options added to a type
  50595. */
  50596. entries: IExplorerExtensibilityOption[];
  50597. }
  50598. /**
  50599. * Interface used to define the options to use to create the Inspector
  50600. */
  50601. export interface IInspectorOptions {
  50602. /**
  50603. * Display in overlay mode (default: false)
  50604. */
  50605. overlay?: boolean;
  50606. /**
  50607. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  50608. */
  50609. globalRoot?: HTMLElement;
  50610. /**
  50611. * Display the Scene explorer
  50612. */
  50613. showExplorer?: boolean;
  50614. /**
  50615. * Display the property inspector
  50616. */
  50617. showInspector?: boolean;
  50618. /**
  50619. * Display in embed mode (both panes on the right)
  50620. */
  50621. embedMode?: boolean;
  50622. /**
  50623. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  50624. */
  50625. handleResize?: boolean;
  50626. /**
  50627. * Allow the panes to popup (default: true)
  50628. */
  50629. enablePopup?: boolean;
  50630. /**
  50631. * Allow the panes to be closed by users (default: true)
  50632. */
  50633. enableClose?: boolean;
  50634. /**
  50635. * Optional list of extensibility entries
  50636. */
  50637. explorerExtensibility?: IExplorerExtensibilityGroup[];
  50638. /**
  50639. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  50640. */
  50641. inspectorURL?: string;
  50642. /**
  50643. * Optional initial tab (default to DebugLayerTab.Properties)
  50644. */
  50645. initialTab?: DebugLayerTab;
  50646. }
  50647. interface Scene {
  50648. /**
  50649. * @hidden
  50650. * Backing field
  50651. */
  50652. _debugLayer: DebugLayer;
  50653. /**
  50654. * Gets the debug layer (aka Inspector) associated with the scene
  50655. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50656. */
  50657. debugLayer: DebugLayer;
  50658. }
  50659. /**
  50660. * Enum of inspector action tab
  50661. */
  50662. export enum DebugLayerTab {
  50663. /**
  50664. * Properties tag (default)
  50665. */
  50666. Properties = 0,
  50667. /**
  50668. * Debug tab
  50669. */
  50670. Debug = 1,
  50671. /**
  50672. * Statistics tab
  50673. */
  50674. Statistics = 2,
  50675. /**
  50676. * Tools tab
  50677. */
  50678. Tools = 3,
  50679. /**
  50680. * Settings tab
  50681. */
  50682. Settings = 4
  50683. }
  50684. /**
  50685. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50686. * what is happening in your scene
  50687. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50688. */
  50689. export class DebugLayer {
  50690. /**
  50691. * Define the url to get the inspector script from.
  50692. * By default it uses the babylonjs CDN.
  50693. * @ignoreNaming
  50694. */
  50695. static InspectorURL: string;
  50696. private _scene;
  50697. private BJSINSPECTOR;
  50698. private _onPropertyChangedObservable?;
  50699. /**
  50700. * Observable triggered when a property is changed through the inspector.
  50701. */
  50702. get onPropertyChangedObservable(): any;
  50703. /**
  50704. * Instantiates a new debug layer.
  50705. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50706. * what is happening in your scene
  50707. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50708. * @param scene Defines the scene to inspect
  50709. */
  50710. constructor(scene: Scene);
  50711. /** Creates the inspector window. */
  50712. private _createInspector;
  50713. /**
  50714. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  50715. * @param entity defines the entity to select
  50716. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  50717. */
  50718. select(entity: any, lineContainerTitles?: string | string[]): void;
  50719. /** Get the inspector from bundle or global */
  50720. private _getGlobalInspector;
  50721. /**
  50722. * Get if the inspector is visible or not.
  50723. * @returns true if visible otherwise, false
  50724. */
  50725. isVisible(): boolean;
  50726. /**
  50727. * Hide the inspector and close its window.
  50728. */
  50729. hide(): void;
  50730. /**
  50731. * Update the scene in the inspector
  50732. */
  50733. setAsActiveScene(): void;
  50734. /**
  50735. * Launch the debugLayer.
  50736. * @param config Define the configuration of the inspector
  50737. * @return a promise fulfilled when the debug layer is visible
  50738. */
  50739. show(config?: IInspectorOptions): Promise<DebugLayer>;
  50740. }
  50741. }
  50742. declare module BABYLON {
  50743. /**
  50744. * Class containing static functions to help procedurally build meshes
  50745. */
  50746. export class BoxBuilder {
  50747. /**
  50748. * Creates a box mesh
  50749. * * The parameter `size` sets the size (float) of each box side (default 1)
  50750. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50751. * * 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)
  50752. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50753. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50754. * * 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
  50755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50756. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50757. * @param name defines the name of the mesh
  50758. * @param options defines the options used to create the mesh
  50759. * @param scene defines the hosting scene
  50760. * @returns the box mesh
  50761. */
  50762. static CreateBox(name: string, options: {
  50763. size?: number;
  50764. width?: number;
  50765. height?: number;
  50766. depth?: number;
  50767. faceUV?: Vector4[];
  50768. faceColors?: Color4[];
  50769. sideOrientation?: number;
  50770. frontUVs?: Vector4;
  50771. backUVs?: Vector4;
  50772. wrap?: boolean;
  50773. topBaseAt?: number;
  50774. bottomBaseAt?: number;
  50775. updatable?: boolean;
  50776. }, scene?: Nullable<Scene>): Mesh;
  50777. }
  50778. }
  50779. declare module BABYLON.Debug {
  50780. /**
  50781. * Used to show the physics impostor around the specific mesh
  50782. */
  50783. export class PhysicsViewer {
  50784. /** @hidden */
  50785. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  50786. /** @hidden */
  50787. protected _meshes: Array<Nullable<AbstractMesh>>;
  50788. /** @hidden */
  50789. protected _scene: Nullable<Scene>;
  50790. /** @hidden */
  50791. protected _numMeshes: number;
  50792. /** @hidden */
  50793. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  50794. private _renderFunction;
  50795. private _utilityLayer;
  50796. private _debugBoxMesh;
  50797. private _debugSphereMesh;
  50798. private _debugCylinderMesh;
  50799. private _debugMaterial;
  50800. private _debugMeshMeshes;
  50801. /**
  50802. * Creates a new PhysicsViewer
  50803. * @param scene defines the hosting scene
  50804. */
  50805. constructor(scene: Scene);
  50806. /** @hidden */
  50807. protected _updateDebugMeshes(): void;
  50808. /**
  50809. * Renders a specified physic impostor
  50810. * @param impostor defines the impostor to render
  50811. * @param targetMesh defines the mesh represented by the impostor
  50812. * @returns the new debug mesh used to render the impostor
  50813. */
  50814. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  50815. /**
  50816. * Hides a specified physic impostor
  50817. * @param impostor defines the impostor to hide
  50818. */
  50819. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  50820. private _getDebugMaterial;
  50821. private _getDebugBoxMesh;
  50822. private _getDebugSphereMesh;
  50823. private _getDebugCylinderMesh;
  50824. private _getDebugMeshMesh;
  50825. private _getDebugMesh;
  50826. /** Releases all resources */
  50827. dispose(): void;
  50828. }
  50829. }
  50830. declare module BABYLON {
  50831. /**
  50832. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50833. * in order to better appreciate the issue one might have.
  50834. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50835. */
  50836. export class RayHelper {
  50837. /**
  50838. * Defines the ray we are currently tryin to visualize.
  50839. */
  50840. ray: Nullable<Ray>;
  50841. private _renderPoints;
  50842. private _renderLine;
  50843. private _renderFunction;
  50844. private _scene;
  50845. private _onAfterRenderObserver;
  50846. private _onAfterStepObserver;
  50847. private _attachedToMesh;
  50848. private _meshSpaceDirection;
  50849. private _meshSpaceOrigin;
  50850. /**
  50851. * Helper function to create a colored helper in a scene in one line.
  50852. * @param ray Defines the ray we are currently tryin to visualize
  50853. * @param scene Defines the scene the ray is used in
  50854. * @param color Defines the color we want to see the ray in
  50855. * @returns The newly created ray helper.
  50856. */
  50857. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  50858. /**
  50859. * Instantiate a new ray helper.
  50860. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50861. * in order to better appreciate the issue one might have.
  50862. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50863. * @param ray Defines the ray we are currently tryin to visualize
  50864. */
  50865. constructor(ray: Ray);
  50866. /**
  50867. * Shows the ray we are willing to debug.
  50868. * @param scene Defines the scene the ray needs to be rendered in
  50869. * @param color Defines the color the ray needs to be rendered in
  50870. */
  50871. show(scene: Scene, color?: Color3): void;
  50872. /**
  50873. * Hides the ray we are debugging.
  50874. */
  50875. hide(): void;
  50876. private _render;
  50877. /**
  50878. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  50879. * @param mesh Defines the mesh we want the helper attached to
  50880. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  50881. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  50882. * @param length Defines the length of the ray
  50883. */
  50884. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  50885. /**
  50886. * Detach the ray helper from the mesh it has previously been attached to.
  50887. */
  50888. detachFromMesh(): void;
  50889. private _updateToMesh;
  50890. /**
  50891. * Dispose the helper and release its associated resources.
  50892. */
  50893. dispose(): void;
  50894. }
  50895. }
  50896. declare module BABYLON {
  50897. /**
  50898. * Defines the options associated with the creation of a SkeletonViewer.
  50899. */
  50900. export interface ISkeletonViewerOptions {
  50901. /** Should the system pause animations before building the Viewer? */
  50902. pauseAnimations: boolean;
  50903. /** Should the system return the skeleton to rest before building? */
  50904. returnToRest: boolean;
  50905. /** public Display Mode of the Viewer */
  50906. displayMode: number;
  50907. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  50908. displayOptions: ISkeletonViewerDisplayOptions;
  50909. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  50910. computeBonesUsingShaders: boolean;
  50911. }
  50912. /**
  50913. * Defines how to display the various bone meshes for the viewer.
  50914. */
  50915. export interface ISkeletonViewerDisplayOptions {
  50916. /** How far down to start tapering the bone spurs */
  50917. midStep?: number;
  50918. /** How big is the midStep? */
  50919. midStepFactor?: number;
  50920. /** Base for the Sphere Size */
  50921. sphereBaseSize?: number;
  50922. /** The ratio of the sphere to the longest bone in units */
  50923. sphereScaleUnit?: number;
  50924. /** Ratio for the Sphere Size */
  50925. sphereFactor?: number;
  50926. }
  50927. }
  50928. declare module BABYLON {
  50929. /**
  50930. * Class containing static functions to help procedurally build meshes
  50931. */
  50932. export class RibbonBuilder {
  50933. /**
  50934. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50935. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50936. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50937. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50938. * * 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
  50939. * * 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
  50940. * * 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
  50941. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50942. * * 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
  50943. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50944. * * 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
  50945. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50946. * * 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
  50947. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50949. * @param name defines the name of the mesh
  50950. * @param options defines the options used to create the mesh
  50951. * @param scene defines the hosting scene
  50952. * @returns the ribbon mesh
  50953. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50954. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50955. */
  50956. static CreateRibbon(name: string, options: {
  50957. pathArray: Vector3[][];
  50958. closeArray?: boolean;
  50959. closePath?: boolean;
  50960. offset?: number;
  50961. updatable?: boolean;
  50962. sideOrientation?: number;
  50963. frontUVs?: Vector4;
  50964. backUVs?: Vector4;
  50965. instance?: Mesh;
  50966. invertUV?: boolean;
  50967. uvs?: Vector2[];
  50968. colors?: Color4[];
  50969. }, scene?: Nullable<Scene>): Mesh;
  50970. }
  50971. }
  50972. declare module BABYLON {
  50973. /**
  50974. * Class containing static functions to help procedurally build meshes
  50975. */
  50976. export class ShapeBuilder {
  50977. /**
  50978. * 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.
  50979. * * 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.
  50980. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50981. * * 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.
  50982. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50983. * * 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
  50984. * * 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
  50985. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50986. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50987. * * 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
  50988. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50990. * @param name defines the name of the mesh
  50991. * @param options defines the options used to create the mesh
  50992. * @param scene defines the hosting scene
  50993. * @returns the extruded shape mesh
  50994. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50995. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50996. */
  50997. static ExtrudeShape(name: string, options: {
  50998. shape: Vector3[];
  50999. path: Vector3[];
  51000. scale?: number;
  51001. rotation?: number;
  51002. cap?: number;
  51003. updatable?: boolean;
  51004. sideOrientation?: number;
  51005. frontUVs?: Vector4;
  51006. backUVs?: Vector4;
  51007. instance?: Mesh;
  51008. invertUV?: boolean;
  51009. }, scene?: Nullable<Scene>): Mesh;
  51010. /**
  51011. * Creates an custom extruded shape mesh.
  51012. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51013. * * 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.
  51014. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51015. * * 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
  51016. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51017. * * 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
  51018. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51019. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51020. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51021. * * 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
  51022. * * 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
  51023. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51024. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51025. * * 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
  51026. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51027. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51028. * @param name defines the name of the mesh
  51029. * @param options defines the options used to create the mesh
  51030. * @param scene defines the hosting scene
  51031. * @returns the custom extruded shape mesh
  51032. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51033. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51034. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51035. */
  51036. static ExtrudeShapeCustom(name: string, options: {
  51037. shape: Vector3[];
  51038. path: Vector3[];
  51039. scaleFunction?: any;
  51040. rotationFunction?: any;
  51041. ribbonCloseArray?: boolean;
  51042. ribbonClosePath?: boolean;
  51043. cap?: number;
  51044. updatable?: boolean;
  51045. sideOrientation?: number;
  51046. frontUVs?: Vector4;
  51047. backUVs?: Vector4;
  51048. instance?: Mesh;
  51049. invertUV?: boolean;
  51050. }, scene?: Nullable<Scene>): Mesh;
  51051. private static _ExtrudeShapeGeneric;
  51052. }
  51053. }
  51054. declare module BABYLON.Debug {
  51055. /**
  51056. * Class used to render a debug view of a given skeleton
  51057. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  51058. */
  51059. export class SkeletonViewer {
  51060. /** defines the skeleton to render */
  51061. skeleton: Skeleton;
  51062. /** defines the mesh attached to the skeleton */
  51063. mesh: AbstractMesh;
  51064. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51065. autoUpdateBonesMatrices: boolean;
  51066. /** defines the rendering group id to use with the viewer */
  51067. renderingGroupId: number;
  51068. /** is the options for the viewer */
  51069. options: Partial<ISkeletonViewerOptions>;
  51070. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  51071. static readonly DISPLAY_LINES: number;
  51072. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  51073. static readonly DISPLAY_SPHERES: number;
  51074. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  51075. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  51076. /** If SkeletonViewer scene scope. */
  51077. private _scene;
  51078. /** Gets or sets the color used to render the skeleton */
  51079. color: Color3;
  51080. /** Array of the points of the skeleton fo the line view. */
  51081. private _debugLines;
  51082. /** The SkeletonViewers Mesh. */
  51083. private _debugMesh;
  51084. /** If SkeletonViewer is enabled. */
  51085. private _isEnabled;
  51086. /** If SkeletonViewer is ready. */
  51087. private _ready;
  51088. /** SkeletonViewer render observable. */
  51089. private _obs;
  51090. /** The Utility Layer to render the gizmos in. */
  51091. private _utilityLayer;
  51092. private _boneIndices;
  51093. /** Gets the Scene. */
  51094. get scene(): Scene;
  51095. /** Gets the utilityLayer. */
  51096. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  51097. /** Checks Ready Status. */
  51098. get isReady(): Boolean;
  51099. /** Sets Ready Status. */
  51100. set ready(value: boolean);
  51101. /** Gets the debugMesh */
  51102. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  51103. /** Sets the debugMesh */
  51104. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  51105. /** Gets the material */
  51106. get material(): StandardMaterial;
  51107. /** Sets the material */
  51108. set material(value: StandardMaterial);
  51109. /** Gets the material */
  51110. get displayMode(): number;
  51111. /** Sets the material */
  51112. set displayMode(value: number);
  51113. /**
  51114. * Creates a new SkeletonViewer
  51115. * @param skeleton defines the skeleton to render
  51116. * @param mesh defines the mesh attached to the skeleton
  51117. * @param scene defines the hosting scene
  51118. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  51119. * @param renderingGroupId defines the rendering group id to use with the viewer
  51120. * @param options All of the extra constructor options for the SkeletonViewer
  51121. */
  51122. constructor(
  51123. /** defines the skeleton to render */
  51124. skeleton: Skeleton,
  51125. /** defines the mesh attached to the skeleton */
  51126. mesh: AbstractMesh,
  51127. /** The Scene scope*/
  51128. scene: Scene,
  51129. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51130. autoUpdateBonesMatrices?: boolean,
  51131. /** defines the rendering group id to use with the viewer */
  51132. renderingGroupId?: number,
  51133. /** is the options for the viewer */
  51134. options?: Partial<ISkeletonViewerOptions>);
  51135. /** The Dynamic bindings for the update functions */
  51136. private _bindObs;
  51137. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  51138. update(): void;
  51139. /** Gets or sets a boolean indicating if the viewer is enabled */
  51140. set isEnabled(value: boolean);
  51141. get isEnabled(): boolean;
  51142. private _getBonePosition;
  51143. private _getLinesForBonesWithLength;
  51144. private _getLinesForBonesNoLength;
  51145. /** function to revert the mesh and scene back to the initial state. */
  51146. private _revert;
  51147. /** function to build and bind sphere joint points and spur bone representations. */
  51148. private _buildSpheresAndSpurs;
  51149. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  51150. private _displayLinesUpdate;
  51151. /** Changes the displayMode of the skeleton viewer
  51152. * @param mode The displayMode numerical value
  51153. */
  51154. changeDisplayMode(mode: number): void;
  51155. /** Changes the displayMode of the skeleton viewer
  51156. * @param option String of the option name
  51157. * @param value The numerical option value
  51158. */
  51159. changeDisplayOptions(option: string, value: number): void;
  51160. /** Release associated resources */
  51161. dispose(): void;
  51162. }
  51163. }
  51164. declare module BABYLON {
  51165. /**
  51166. * Enum for Device Types
  51167. */
  51168. export enum DeviceType {
  51169. /** Generic */
  51170. Generic = 0,
  51171. /** Keyboard */
  51172. Keyboard = 1,
  51173. /** Mouse */
  51174. Mouse = 2,
  51175. /** Touch Pointers */
  51176. Touch = 3,
  51177. /** PS4 Dual Shock */
  51178. DualShock = 4,
  51179. /** Xbox */
  51180. Xbox = 5,
  51181. /** Switch Controller */
  51182. Switch = 6
  51183. }
  51184. /**
  51185. * Enum for All Pointers (Touch/Mouse)
  51186. */
  51187. export enum PointerInput {
  51188. /** Horizontal Axis */
  51189. Horizontal = 0,
  51190. /** Vertical Axis */
  51191. Vertical = 1,
  51192. /** Left Click or Touch */
  51193. LeftClick = 2,
  51194. /** Middle Click */
  51195. MiddleClick = 3,
  51196. /** Right Click */
  51197. RightClick = 4,
  51198. /** Browser Back */
  51199. BrowserBack = 5,
  51200. /** Browser Forward */
  51201. BrowserForward = 6
  51202. }
  51203. /**
  51204. * Enum for Dual Shock Gamepad
  51205. */
  51206. export enum DualShockInput {
  51207. /** Cross */
  51208. Cross = 0,
  51209. /** Circle */
  51210. Circle = 1,
  51211. /** Square */
  51212. Square = 2,
  51213. /** Triangle */
  51214. Triangle = 3,
  51215. /** L1 */
  51216. L1 = 4,
  51217. /** R1 */
  51218. R1 = 5,
  51219. /** L2 */
  51220. L2 = 6,
  51221. /** R2 */
  51222. R2 = 7,
  51223. /** Share */
  51224. Share = 8,
  51225. /** Options */
  51226. Options = 9,
  51227. /** L3 */
  51228. L3 = 10,
  51229. /** R3 */
  51230. R3 = 11,
  51231. /** DPadUp */
  51232. DPadUp = 12,
  51233. /** DPadDown */
  51234. DPadDown = 13,
  51235. /** DPadLeft */
  51236. DPadLeft = 14,
  51237. /** DRight */
  51238. DPadRight = 15,
  51239. /** Home */
  51240. Home = 16,
  51241. /** TouchPad */
  51242. TouchPad = 17,
  51243. /** LStickXAxis */
  51244. LStickXAxis = 18,
  51245. /** LStickYAxis */
  51246. LStickYAxis = 19,
  51247. /** RStickXAxis */
  51248. RStickXAxis = 20,
  51249. /** RStickYAxis */
  51250. RStickYAxis = 21
  51251. }
  51252. /**
  51253. * Enum for Xbox Gamepad
  51254. */
  51255. export enum XboxInput {
  51256. /** A */
  51257. A = 0,
  51258. /** B */
  51259. B = 1,
  51260. /** X */
  51261. X = 2,
  51262. /** Y */
  51263. Y = 3,
  51264. /** LB */
  51265. LB = 4,
  51266. /** RB */
  51267. RB = 5,
  51268. /** LT */
  51269. LT = 6,
  51270. /** RT */
  51271. RT = 7,
  51272. /** Back */
  51273. Back = 8,
  51274. /** Start */
  51275. Start = 9,
  51276. /** LS */
  51277. LS = 10,
  51278. /** RS */
  51279. RS = 11,
  51280. /** DPadUp */
  51281. DPadUp = 12,
  51282. /** DPadDown */
  51283. DPadDown = 13,
  51284. /** DPadLeft */
  51285. DPadLeft = 14,
  51286. /** DRight */
  51287. DPadRight = 15,
  51288. /** Home */
  51289. Home = 16,
  51290. /** LStickXAxis */
  51291. LStickXAxis = 17,
  51292. /** LStickYAxis */
  51293. LStickYAxis = 18,
  51294. /** RStickXAxis */
  51295. RStickXAxis = 19,
  51296. /** RStickYAxis */
  51297. RStickYAxis = 20
  51298. }
  51299. /**
  51300. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  51301. */
  51302. export enum SwitchInput {
  51303. /** B */
  51304. B = 0,
  51305. /** A */
  51306. A = 1,
  51307. /** Y */
  51308. Y = 2,
  51309. /** X */
  51310. X = 3,
  51311. /** L */
  51312. L = 4,
  51313. /** R */
  51314. R = 5,
  51315. /** ZL */
  51316. ZL = 6,
  51317. /** ZR */
  51318. ZR = 7,
  51319. /** Minus */
  51320. Minus = 8,
  51321. /** Plus */
  51322. Plus = 9,
  51323. /** LS */
  51324. LS = 10,
  51325. /** RS */
  51326. RS = 11,
  51327. /** DPadUp */
  51328. DPadUp = 12,
  51329. /** DPadDown */
  51330. DPadDown = 13,
  51331. /** DPadLeft */
  51332. DPadLeft = 14,
  51333. /** DRight */
  51334. DPadRight = 15,
  51335. /** Home */
  51336. Home = 16,
  51337. /** Capture */
  51338. Capture = 17,
  51339. /** LStickXAxis */
  51340. LStickXAxis = 18,
  51341. /** LStickYAxis */
  51342. LStickYAxis = 19,
  51343. /** RStickXAxis */
  51344. RStickXAxis = 20,
  51345. /** RStickYAxis */
  51346. RStickYAxis = 21
  51347. }
  51348. }
  51349. declare module BABYLON {
  51350. /**
  51351. * This class will take all inputs from Keyboard, Pointer, and
  51352. * any Gamepads and provide a polling system that all devices
  51353. * will use. This class assumes that there will only be one
  51354. * pointer device and one keyboard.
  51355. */
  51356. export class DeviceInputSystem implements IDisposable {
  51357. /**
  51358. * Callback to be triggered when a device is connected
  51359. */
  51360. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51361. /**
  51362. * Callback to be triggered when a device is disconnected
  51363. */
  51364. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51365. /**
  51366. * Callback to be triggered when event driven input is updated
  51367. */
  51368. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  51369. private _inputs;
  51370. private _gamepads;
  51371. private _keyboardActive;
  51372. private _pointerActive;
  51373. private _elementToAttachTo;
  51374. private _keyboardDownEvent;
  51375. private _keyboardUpEvent;
  51376. private _pointerMoveEvent;
  51377. private _pointerDownEvent;
  51378. private _pointerUpEvent;
  51379. private _gamepadConnectedEvent;
  51380. private _gamepadDisconnectedEvent;
  51381. private static _MAX_KEYCODES;
  51382. private static _MAX_POINTER_INPUTS;
  51383. private constructor();
  51384. /**
  51385. * Creates a new DeviceInputSystem instance
  51386. * @param engine Engine to pull input element from
  51387. * @returns The new instance
  51388. */
  51389. static Create(engine: Engine): DeviceInputSystem;
  51390. /**
  51391. * Checks for current device input value, given an id and input index
  51392. * @param deviceName Id of connected device
  51393. * @param inputIndex Index of device input
  51394. * @returns Current value of input
  51395. */
  51396. /**
  51397. * Checks for current device input value, given an id and input index
  51398. * @param deviceType Enum specifiying device type
  51399. * @param deviceSlot "Slot" or index that device is referenced in
  51400. * @param inputIndex Id of input to be checked
  51401. * @returns Current value of input
  51402. */
  51403. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  51404. /**
  51405. * Dispose of all the eventlisteners
  51406. */
  51407. dispose(): void;
  51408. /**
  51409. * Add device and inputs to device array
  51410. * @param deviceType Enum specifiying device type
  51411. * @param deviceSlot "Slot" or index that device is referenced in
  51412. * @param numberOfInputs Number of input entries to create for given device
  51413. */
  51414. private _registerDevice;
  51415. /**
  51416. * Given a specific device name, remove that device from the device map
  51417. * @param deviceType Enum specifiying device type
  51418. * @param deviceSlot "Slot" or index that device is referenced in
  51419. */
  51420. private _unregisterDevice;
  51421. /**
  51422. * Handle all actions that come from keyboard interaction
  51423. */
  51424. private _handleKeyActions;
  51425. /**
  51426. * Handle all actions that come from pointer interaction
  51427. */
  51428. private _handlePointerActions;
  51429. /**
  51430. * Handle all actions that come from gamepad interaction
  51431. */
  51432. private _handleGamepadActions;
  51433. /**
  51434. * Update all non-event based devices with each frame
  51435. * @param deviceType Enum specifiying device type
  51436. * @param deviceSlot "Slot" or index that device is referenced in
  51437. * @param inputIndex Id of input to be checked
  51438. */
  51439. private _updateDevice;
  51440. /**
  51441. * Gets DeviceType from the device name
  51442. * @param deviceName Name of Device from DeviceInputSystem
  51443. * @returns DeviceType enum value
  51444. */
  51445. private _getGamepadDeviceType;
  51446. }
  51447. }
  51448. declare module BABYLON {
  51449. /**
  51450. * Type to handle enforcement of inputs
  51451. */
  51452. 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;
  51453. }
  51454. declare module BABYLON {
  51455. /**
  51456. * Class that handles all input for a specific device
  51457. */
  51458. export class DeviceSource<T extends DeviceType> {
  51459. /** Type of device */
  51460. readonly deviceType: DeviceType;
  51461. /** "Slot" or index that device is referenced in */
  51462. readonly deviceSlot: number;
  51463. /**
  51464. * Observable to handle device input changes per device
  51465. */
  51466. readonly onInputChangedObservable: Observable<{
  51467. inputIndex: DeviceInput<T>;
  51468. previousState: Nullable<number>;
  51469. currentState: Nullable<number>;
  51470. }>;
  51471. private readonly _deviceInputSystem;
  51472. /**
  51473. * Default Constructor
  51474. * @param deviceInputSystem Reference to DeviceInputSystem
  51475. * @param deviceType Type of device
  51476. * @param deviceSlot "Slot" or index that device is referenced in
  51477. */
  51478. constructor(deviceInputSystem: DeviceInputSystem,
  51479. /** Type of device */
  51480. deviceType: DeviceType,
  51481. /** "Slot" or index that device is referenced in */
  51482. deviceSlot?: number);
  51483. /**
  51484. * Get input for specific input
  51485. * @param inputIndex index of specific input on device
  51486. * @returns Input value from DeviceInputSystem
  51487. */
  51488. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  51489. }
  51490. /**
  51491. * Class to keep track of devices
  51492. */
  51493. export class DeviceSourceManager implements IDisposable {
  51494. /**
  51495. * Observable to be triggered when before a device is connected
  51496. */
  51497. readonly onBeforeDeviceConnectedObservable: Observable<{
  51498. deviceType: DeviceType;
  51499. deviceSlot: number;
  51500. }>;
  51501. /**
  51502. * Observable to be triggered when before a device is disconnected
  51503. */
  51504. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  51505. deviceType: DeviceType;
  51506. deviceSlot: number;
  51507. }>;
  51508. /**
  51509. * Observable to be triggered when after a device is connected
  51510. */
  51511. readonly onAfterDeviceConnectedObservable: Observable<{
  51512. deviceType: DeviceType;
  51513. deviceSlot: number;
  51514. }>;
  51515. /**
  51516. * Observable to be triggered when after a device is disconnected
  51517. */
  51518. readonly onAfterDeviceDisconnectedObservable: Observable<{
  51519. deviceType: DeviceType;
  51520. deviceSlot: number;
  51521. }>;
  51522. private readonly _devices;
  51523. private readonly _firstDevice;
  51524. private readonly _deviceInputSystem;
  51525. /**
  51526. * Default Constructor
  51527. * @param engine engine to pull input element from
  51528. */
  51529. constructor(engine: Engine);
  51530. /**
  51531. * Gets a DeviceSource, given a type and slot
  51532. * @param deviceType Enum specifying device type
  51533. * @param deviceSlot "Slot" or index that device is referenced in
  51534. * @returns DeviceSource object
  51535. */
  51536. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  51537. /**
  51538. * Gets an array of DeviceSource objects for a given device type
  51539. * @param deviceType Enum specifying device type
  51540. * @returns Array of DeviceSource objects
  51541. */
  51542. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  51543. /**
  51544. * Dispose of DeviceInputSystem and other parts
  51545. */
  51546. dispose(): void;
  51547. /**
  51548. * Function to add device name to device list
  51549. * @param deviceType Enum specifying device type
  51550. * @param deviceSlot "Slot" or index that device is referenced in
  51551. */
  51552. private _addDevice;
  51553. /**
  51554. * Function to remove device name to device list
  51555. * @param deviceType Enum specifying device type
  51556. * @param deviceSlot "Slot" or index that device is referenced in
  51557. */
  51558. private _removeDevice;
  51559. /**
  51560. * Updates array storing first connected device of each type
  51561. * @param type Type of Device
  51562. */
  51563. private _updateFirstDevices;
  51564. }
  51565. }
  51566. declare module BABYLON {
  51567. /**
  51568. * Options to create the null engine
  51569. */
  51570. export class NullEngineOptions {
  51571. /**
  51572. * Render width (Default: 512)
  51573. */
  51574. renderWidth: number;
  51575. /**
  51576. * Render height (Default: 256)
  51577. */
  51578. renderHeight: number;
  51579. /**
  51580. * Texture size (Default: 512)
  51581. */
  51582. textureSize: number;
  51583. /**
  51584. * If delta time between frames should be constant
  51585. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51586. */
  51587. deterministicLockstep: boolean;
  51588. /**
  51589. * Maximum about of steps between frames (Default: 4)
  51590. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51591. */
  51592. lockstepMaxSteps: number;
  51593. /**
  51594. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  51595. */
  51596. useHighPrecisionMatrix?: boolean;
  51597. }
  51598. /**
  51599. * The null engine class provides support for headless version of babylon.js.
  51600. * This can be used in server side scenario or for testing purposes
  51601. */
  51602. export class NullEngine extends Engine {
  51603. private _options;
  51604. /**
  51605. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  51606. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51607. * @returns true if engine is in deterministic lock step mode
  51608. */
  51609. isDeterministicLockStep(): boolean;
  51610. /**
  51611. * Gets the max steps when engine is running in deterministic lock step
  51612. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51613. * @returns the max steps
  51614. */
  51615. getLockstepMaxSteps(): number;
  51616. /**
  51617. * Gets the current hardware scaling level.
  51618. * By default the hardware scaling level is computed from the window device ratio.
  51619. * 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.
  51620. * @returns a number indicating the current hardware scaling level
  51621. */
  51622. getHardwareScalingLevel(): number;
  51623. constructor(options?: NullEngineOptions);
  51624. /**
  51625. * Creates a vertex buffer
  51626. * @param vertices the data for the vertex buffer
  51627. * @returns the new WebGL static buffer
  51628. */
  51629. createVertexBuffer(vertices: FloatArray): DataBuffer;
  51630. /**
  51631. * Creates a new index buffer
  51632. * @param indices defines the content of the index buffer
  51633. * @param updatable defines if the index buffer must be updatable
  51634. * @returns a new webGL buffer
  51635. */
  51636. createIndexBuffer(indices: IndicesArray): DataBuffer;
  51637. /**
  51638. * Clear the current render buffer or the current render target (if any is set up)
  51639. * @param color defines the color to use
  51640. * @param backBuffer defines if the back buffer must be cleared
  51641. * @param depth defines if the depth buffer must be cleared
  51642. * @param stencil defines if the stencil buffer must be cleared
  51643. */
  51644. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51645. /**
  51646. * Gets the current render width
  51647. * @param useScreen defines if screen size must be used (or the current render target if any)
  51648. * @returns a number defining the current render width
  51649. */
  51650. getRenderWidth(useScreen?: boolean): number;
  51651. /**
  51652. * Gets the current render height
  51653. * @param useScreen defines if screen size must be used (or the current render target if any)
  51654. * @returns a number defining the current render height
  51655. */
  51656. getRenderHeight(useScreen?: boolean): number;
  51657. /**
  51658. * Set the WebGL's viewport
  51659. * @param viewport defines the viewport element to be used
  51660. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  51661. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  51662. */
  51663. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  51664. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  51665. /**
  51666. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  51667. * @param pipelineContext defines the pipeline context to use
  51668. * @param uniformsNames defines the list of uniform names
  51669. * @returns an array of webGL uniform locations
  51670. */
  51671. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  51672. /**
  51673. * Gets the lsit of active attributes for a given webGL program
  51674. * @param pipelineContext defines the pipeline context to use
  51675. * @param attributesNames defines the list of attribute names to get
  51676. * @returns an array of indices indicating the offset of each attribute
  51677. */
  51678. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51679. /**
  51680. * Binds an effect to the webGL context
  51681. * @param effect defines the effect to bind
  51682. */
  51683. bindSamplers(effect: Effect): void;
  51684. /**
  51685. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  51686. * @param effect defines the effect to activate
  51687. */
  51688. enableEffect(effect: Effect): void;
  51689. /**
  51690. * Set various states to the webGL context
  51691. * @param culling defines backface culling state
  51692. * @param zOffset defines the value to apply to zOffset (0 by default)
  51693. * @param force defines if states must be applied even if cache is up to date
  51694. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  51695. */
  51696. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51697. /**
  51698. * Set the value of an uniform to an array of int32
  51699. * @param uniform defines the webGL uniform location where to store the value
  51700. * @param array defines the array of int32 to store
  51701. */
  51702. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51703. /**
  51704. * Set the value of an uniform to an array of int32 (stored as vec2)
  51705. * @param uniform defines the webGL uniform location where to store the value
  51706. * @param array defines the array of int32 to store
  51707. */
  51708. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51709. /**
  51710. * Set the value of an uniform to an array of int32 (stored as vec3)
  51711. * @param uniform defines the webGL uniform location where to store the value
  51712. * @param array defines the array of int32 to store
  51713. */
  51714. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51715. /**
  51716. * Set the value of an uniform to an array of int32 (stored as vec4)
  51717. * @param uniform defines the webGL uniform location where to store the value
  51718. * @param array defines the array of int32 to store
  51719. */
  51720. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51721. /**
  51722. * Set the value of an uniform to an array of float32
  51723. * @param uniform defines the webGL uniform location where to store the value
  51724. * @param array defines the array of float32 to store
  51725. */
  51726. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51727. /**
  51728. * Set the value of an uniform to an array of float32 (stored as vec2)
  51729. * @param uniform defines the webGL uniform location where to store the value
  51730. * @param array defines the array of float32 to store
  51731. */
  51732. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51733. /**
  51734. * Set the value of an uniform to an array of float32 (stored as vec3)
  51735. * @param uniform defines the webGL uniform location where to store the value
  51736. * @param array defines the array of float32 to store
  51737. */
  51738. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51739. /**
  51740. * Set the value of an uniform to an array of float32 (stored as vec4)
  51741. * @param uniform defines the webGL uniform location where to store the value
  51742. * @param array defines the array of float32 to store
  51743. */
  51744. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51745. /**
  51746. * Set the value of an uniform to an array of number
  51747. * @param uniform defines the webGL uniform location where to store the value
  51748. * @param array defines the array of number to store
  51749. */
  51750. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51751. /**
  51752. * Set the value of an uniform to an array of number (stored as vec2)
  51753. * @param uniform defines the webGL uniform location where to store the value
  51754. * @param array defines the array of number to store
  51755. */
  51756. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51757. /**
  51758. * Set the value of an uniform to an array of number (stored as vec3)
  51759. * @param uniform defines the webGL uniform location where to store the value
  51760. * @param array defines the array of number to store
  51761. */
  51762. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51763. /**
  51764. * Set the value of an uniform to an array of number (stored as vec4)
  51765. * @param uniform defines the webGL uniform location where to store the value
  51766. * @param array defines the array of number to store
  51767. */
  51768. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51769. /**
  51770. * Set the value of an uniform to an array of float32 (stored as matrices)
  51771. * @param uniform defines the webGL uniform location where to store the value
  51772. * @param matrices defines the array of float32 to store
  51773. */
  51774. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51775. /**
  51776. * Set the value of an uniform to a matrix (3x3)
  51777. * @param uniform defines the webGL uniform location where to store the value
  51778. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  51779. */
  51780. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51781. /**
  51782. * Set the value of an uniform to a matrix (2x2)
  51783. * @param uniform defines the webGL uniform location where to store the value
  51784. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  51785. */
  51786. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51787. /**
  51788. * Set the value of an uniform to a number (float)
  51789. * @param uniform defines the webGL uniform location where to store the value
  51790. * @param value defines the float number to store
  51791. */
  51792. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51793. /**
  51794. * Set the value of an uniform to a vec2
  51795. * @param uniform defines the webGL uniform location where to store the value
  51796. * @param x defines the 1st component of the value
  51797. * @param y defines the 2nd component of the value
  51798. */
  51799. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51800. /**
  51801. * Set the value of an uniform to a vec3
  51802. * @param uniform defines the webGL uniform location where to store the value
  51803. * @param x defines the 1st component of the value
  51804. * @param y defines the 2nd component of the value
  51805. * @param z defines the 3rd component of the value
  51806. */
  51807. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51808. /**
  51809. * Set the value of an uniform to a boolean
  51810. * @param uniform defines the webGL uniform location where to store the value
  51811. * @param bool defines the boolean to store
  51812. */
  51813. setBool(uniform: WebGLUniformLocation, bool: number): void;
  51814. /**
  51815. * Set the value of an uniform to a vec4
  51816. * @param uniform defines the webGL uniform location where to store the value
  51817. * @param x defines the 1st component of the value
  51818. * @param y defines the 2nd component of the value
  51819. * @param z defines the 3rd component of the value
  51820. * @param w defines the 4th component of the value
  51821. */
  51822. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51823. /**
  51824. * Sets the current alpha mode
  51825. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  51826. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51827. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51828. */
  51829. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51830. /**
  51831. * Bind webGl buffers directly to the webGL context
  51832. * @param vertexBuffers defines the vertex buffer to bind
  51833. * @param indexBuffer defines the index buffer to bind
  51834. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  51835. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  51836. * @param effect defines the effect associated with the vertex buffer
  51837. */
  51838. bindBuffers(vertexBuffers: {
  51839. [key: string]: VertexBuffer;
  51840. }, indexBuffer: DataBuffer, effect: Effect): void;
  51841. /**
  51842. * Force the entire cache to be cleared
  51843. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  51844. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  51845. */
  51846. wipeCaches(bruteForce?: boolean): void;
  51847. /**
  51848. * Send a draw order
  51849. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  51850. * @param indexStart defines the starting index
  51851. * @param indexCount defines the number of index to draw
  51852. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51853. */
  51854. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  51855. /**
  51856. * Draw a list of indexed primitives
  51857. * @param fillMode defines the primitive to use
  51858. * @param indexStart defines the starting index
  51859. * @param indexCount defines the number of index to draw
  51860. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51861. */
  51862. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51863. /**
  51864. * Draw a list of unindexed primitives
  51865. * @param fillMode defines the primitive to use
  51866. * @param verticesStart defines the index of first vertex to draw
  51867. * @param verticesCount defines the count of vertices to draw
  51868. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51869. */
  51870. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51871. /** @hidden */
  51872. _createTexture(): WebGLTexture;
  51873. /** @hidden */
  51874. _releaseTexture(texture: InternalTexture): void;
  51875. /**
  51876. * Usually called from Texture.ts.
  51877. * Passed information to create a WebGLTexture
  51878. * @param urlArg defines a value which contains one of the following:
  51879. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51880. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51881. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51882. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51883. * @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)
  51884. * @param scene needed for loading to the correct scene
  51885. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51886. * @param onLoad optional callback to be called upon successful completion
  51887. * @param onError optional callback to be called upon failure
  51888. * @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
  51889. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51890. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51891. * @param forcedExtension defines the extension to use to pick the right loader
  51892. * @param mimeType defines an optional mime type
  51893. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51894. */
  51895. 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;
  51896. /**
  51897. * Creates a new render target texture
  51898. * @param size defines the size of the texture
  51899. * @param options defines the options used to create the texture
  51900. * @returns a new render target texture stored in an InternalTexture
  51901. */
  51902. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  51903. /**
  51904. * Update the sampling mode of a given texture
  51905. * @param samplingMode defines the required sampling mode
  51906. * @param texture defines the texture to update
  51907. */
  51908. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51909. /**
  51910. * Binds the frame buffer to the specified texture.
  51911. * @param texture The texture to render to or null for the default canvas
  51912. * @param faceIndex The face of the texture to render to in case of cube texture
  51913. * @param requiredWidth The width of the target to render to
  51914. * @param requiredHeight The height of the target to render to
  51915. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  51916. * @param lodLevel defines le lod level to bind to the frame buffer
  51917. */
  51918. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51919. /**
  51920. * Unbind the current render target texture from the webGL context
  51921. * @param texture defines the render target texture to unbind
  51922. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  51923. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  51924. */
  51925. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51926. /**
  51927. * Creates a dynamic vertex buffer
  51928. * @param vertices the data for the dynamic vertex buffer
  51929. * @returns the new WebGL dynamic buffer
  51930. */
  51931. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  51932. /**
  51933. * Update the content of a dynamic texture
  51934. * @param texture defines the texture to update
  51935. * @param canvas defines the canvas containing the source
  51936. * @param invertY defines if data must be stored with Y axis inverted
  51937. * @param premulAlpha defines if alpha is stored as premultiplied
  51938. * @param format defines the format of the data
  51939. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  51940. */
  51941. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  51942. /**
  51943. * Gets a boolean indicating if all created effects are ready
  51944. * @returns true if all effects are ready
  51945. */
  51946. areAllEffectsReady(): boolean;
  51947. /**
  51948. * @hidden
  51949. * Get the current error code of the webGL context
  51950. * @returns the error code
  51951. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  51952. */
  51953. getError(): number;
  51954. /** @hidden */
  51955. _getUnpackAlignement(): number;
  51956. /** @hidden */
  51957. _unpackFlipY(value: boolean): void;
  51958. /**
  51959. * Update a dynamic index buffer
  51960. * @param indexBuffer defines the target index buffer
  51961. * @param indices defines the data to update
  51962. * @param offset defines the offset in the target index buffer where update should start
  51963. */
  51964. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  51965. /**
  51966. * Updates a dynamic vertex buffer.
  51967. * @param vertexBuffer the vertex buffer to update
  51968. * @param vertices the data used to update the vertex buffer
  51969. * @param byteOffset the byte offset of the data (optional)
  51970. * @param byteLength the byte length of the data (optional)
  51971. */
  51972. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  51973. /** @hidden */
  51974. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  51975. /** @hidden */
  51976. _bindTexture(channel: number, texture: InternalTexture): void;
  51977. protected _deleteBuffer(buffer: WebGLBuffer): void;
  51978. /**
  51979. * 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
  51980. */
  51981. releaseEffects(): void;
  51982. displayLoadingUI(): void;
  51983. hideLoadingUI(): void;
  51984. /** @hidden */
  51985. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51986. /** @hidden */
  51987. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51988. /** @hidden */
  51989. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51990. /** @hidden */
  51991. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51992. }
  51993. }
  51994. declare module BABYLON {
  51995. /**
  51996. * @hidden
  51997. **/
  51998. export class _TimeToken {
  51999. _startTimeQuery: Nullable<WebGLQuery>;
  52000. _endTimeQuery: Nullable<WebGLQuery>;
  52001. _timeElapsedQuery: Nullable<WebGLQuery>;
  52002. _timeElapsedQueryEnded: boolean;
  52003. }
  52004. }
  52005. declare module BABYLON {
  52006. /** @hidden */
  52007. export class _OcclusionDataStorage {
  52008. /** @hidden */
  52009. occlusionInternalRetryCounter: number;
  52010. /** @hidden */
  52011. isOcclusionQueryInProgress: boolean;
  52012. /** @hidden */
  52013. isOccluded: boolean;
  52014. /** @hidden */
  52015. occlusionRetryCount: number;
  52016. /** @hidden */
  52017. occlusionType: number;
  52018. /** @hidden */
  52019. occlusionQueryAlgorithmType: number;
  52020. }
  52021. interface Engine {
  52022. /**
  52023. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  52024. * @return the new query
  52025. */
  52026. createQuery(): WebGLQuery;
  52027. /**
  52028. * Delete and release a webGL query
  52029. * @param query defines the query to delete
  52030. * @return the current engine
  52031. */
  52032. deleteQuery(query: WebGLQuery): Engine;
  52033. /**
  52034. * Check if a given query has resolved and got its value
  52035. * @param query defines the query to check
  52036. * @returns true if the query got its value
  52037. */
  52038. isQueryResultAvailable(query: WebGLQuery): boolean;
  52039. /**
  52040. * Gets the value of a given query
  52041. * @param query defines the query to check
  52042. * @returns the value of the query
  52043. */
  52044. getQueryResult(query: WebGLQuery): number;
  52045. /**
  52046. * Initiates an occlusion query
  52047. * @param algorithmType defines the algorithm to use
  52048. * @param query defines the query to use
  52049. * @returns the current engine
  52050. * @see https://doc.babylonjs.com/features/occlusionquery
  52051. */
  52052. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  52053. /**
  52054. * Ends an occlusion query
  52055. * @see https://doc.babylonjs.com/features/occlusionquery
  52056. * @param algorithmType defines the algorithm to use
  52057. * @returns the current engine
  52058. */
  52059. endOcclusionQuery(algorithmType: number): Engine;
  52060. /**
  52061. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  52062. * Please note that only one query can be issued at a time
  52063. * @returns a time token used to track the time span
  52064. */
  52065. startTimeQuery(): Nullable<_TimeToken>;
  52066. /**
  52067. * Ends a time query
  52068. * @param token defines the token used to measure the time span
  52069. * @returns the time spent (in ns)
  52070. */
  52071. endTimeQuery(token: _TimeToken): int;
  52072. /** @hidden */
  52073. _currentNonTimestampToken: Nullable<_TimeToken>;
  52074. /** @hidden */
  52075. _createTimeQuery(): WebGLQuery;
  52076. /** @hidden */
  52077. _deleteTimeQuery(query: WebGLQuery): void;
  52078. /** @hidden */
  52079. _getGlAlgorithmType(algorithmType: number): number;
  52080. /** @hidden */
  52081. _getTimeQueryResult(query: WebGLQuery): any;
  52082. /** @hidden */
  52083. _getTimeQueryAvailability(query: WebGLQuery): any;
  52084. }
  52085. interface AbstractMesh {
  52086. /**
  52087. * Backing filed
  52088. * @hidden
  52089. */
  52090. __occlusionDataStorage: _OcclusionDataStorage;
  52091. /**
  52092. * Access property
  52093. * @hidden
  52094. */
  52095. _occlusionDataStorage: _OcclusionDataStorage;
  52096. /**
  52097. * 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.
  52098. * The default value is -1 which means don't break the query and wait till the result
  52099. * @see https://doc.babylonjs.com/features/occlusionquery
  52100. */
  52101. occlusionRetryCount: number;
  52102. /**
  52103. * 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:
  52104. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  52105. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  52106. * * 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.
  52107. * @see https://doc.babylonjs.com/features/occlusionquery
  52108. */
  52109. occlusionType: number;
  52110. /**
  52111. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  52112. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  52113. * * 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.
  52114. * @see https://doc.babylonjs.com/features/occlusionquery
  52115. */
  52116. occlusionQueryAlgorithmType: number;
  52117. /**
  52118. * 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
  52119. * @see https://doc.babylonjs.com/features/occlusionquery
  52120. */
  52121. isOccluded: boolean;
  52122. /**
  52123. * Flag to check the progress status of the query
  52124. * @see https://doc.babylonjs.com/features/occlusionquery
  52125. */
  52126. isOcclusionQueryInProgress: boolean;
  52127. }
  52128. }
  52129. declare module BABYLON {
  52130. /** @hidden */
  52131. export var _forceTransformFeedbackToBundle: boolean;
  52132. interface Engine {
  52133. /**
  52134. * Creates a webGL transform feedback object
  52135. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  52136. * @returns the webGL transform feedback object
  52137. */
  52138. createTransformFeedback(): WebGLTransformFeedback;
  52139. /**
  52140. * Delete a webGL transform feedback object
  52141. * @param value defines the webGL transform feedback object to delete
  52142. */
  52143. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  52144. /**
  52145. * Bind a webGL transform feedback object to the webgl context
  52146. * @param value defines the webGL transform feedback object to bind
  52147. */
  52148. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  52149. /**
  52150. * Begins a transform feedback operation
  52151. * @param usePoints defines if points or triangles must be used
  52152. */
  52153. beginTransformFeedback(usePoints: boolean): void;
  52154. /**
  52155. * Ends a transform feedback operation
  52156. */
  52157. endTransformFeedback(): void;
  52158. /**
  52159. * Specify the varyings to use with transform feedback
  52160. * @param program defines the associated webGL program
  52161. * @param value defines the list of strings representing the varying names
  52162. */
  52163. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  52164. /**
  52165. * Bind a webGL buffer for a transform feedback operation
  52166. * @param value defines the webGL buffer to bind
  52167. */
  52168. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  52169. }
  52170. }
  52171. declare module BABYLON {
  52172. /**
  52173. * Class used to define an additional view for the engine
  52174. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52175. */
  52176. export class EngineView {
  52177. /** Defines the canvas where to render the view */
  52178. target: HTMLCanvasElement;
  52179. /** Defines an optional camera used to render the view (will use active camera else) */
  52180. camera?: Camera;
  52181. }
  52182. interface Engine {
  52183. /**
  52184. * Gets or sets the HTML element to use for attaching events
  52185. */
  52186. inputElement: Nullable<HTMLElement>;
  52187. /**
  52188. * Gets the current engine view
  52189. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52190. */
  52191. activeView: Nullable<EngineView>;
  52192. /** Gets or sets the list of views */
  52193. views: EngineView[];
  52194. /**
  52195. * Register a new child canvas
  52196. * @param canvas defines the canvas to register
  52197. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  52198. * @returns the associated view
  52199. */
  52200. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  52201. /**
  52202. * Remove a registered child canvas
  52203. * @param canvas defines the canvas to remove
  52204. * @returns the current engine
  52205. */
  52206. unRegisterView(canvas: HTMLCanvasElement): Engine;
  52207. }
  52208. }
  52209. declare module BABYLON {
  52210. interface Engine {
  52211. /** @hidden */
  52212. _excludedCompressedTextures: string[];
  52213. /** @hidden */
  52214. _textureFormatInUse: string;
  52215. /**
  52216. * Gets the list of texture formats supported
  52217. */
  52218. readonly texturesSupported: Array<string>;
  52219. /**
  52220. * Gets the texture format in use
  52221. */
  52222. readonly textureFormatInUse: Nullable<string>;
  52223. /**
  52224. * Set the compressed texture extensions or file names to skip.
  52225. *
  52226. * @param skippedFiles defines the list of those texture files you want to skip
  52227. * Example: [".dds", ".env", "myfile.png"]
  52228. */
  52229. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  52230. /**
  52231. * Set the compressed texture format to use, based on the formats you have, and the formats
  52232. * supported by the hardware / browser.
  52233. *
  52234. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  52235. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  52236. * to API arguments needed to compressed textures. This puts the burden on the container
  52237. * generator to house the arcane code for determining these for current & future formats.
  52238. *
  52239. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52240. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52241. *
  52242. * Note: The result of this call is not taken into account when a texture is base64.
  52243. *
  52244. * @param formatsAvailable defines the list of those format families you have created
  52245. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  52246. *
  52247. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  52248. * @returns The extension selected.
  52249. */
  52250. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  52251. }
  52252. }
  52253. declare module BABYLON {
  52254. /**
  52255. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  52256. */
  52257. export interface CubeMapInfo {
  52258. /**
  52259. * The pixel array for the front face.
  52260. * This is stored in format, left to right, up to down format.
  52261. */
  52262. front: Nullable<ArrayBufferView>;
  52263. /**
  52264. * The pixel array for the back face.
  52265. * This is stored in format, left to right, up to down format.
  52266. */
  52267. back: Nullable<ArrayBufferView>;
  52268. /**
  52269. * The pixel array for the left face.
  52270. * This is stored in format, left to right, up to down format.
  52271. */
  52272. left: Nullable<ArrayBufferView>;
  52273. /**
  52274. * The pixel array for the right face.
  52275. * This is stored in format, left to right, up to down format.
  52276. */
  52277. right: Nullable<ArrayBufferView>;
  52278. /**
  52279. * The pixel array for the up face.
  52280. * This is stored in format, left to right, up to down format.
  52281. */
  52282. up: Nullable<ArrayBufferView>;
  52283. /**
  52284. * The pixel array for the down face.
  52285. * This is stored in format, left to right, up to down format.
  52286. */
  52287. down: Nullable<ArrayBufferView>;
  52288. /**
  52289. * The size of the cubemap stored.
  52290. *
  52291. * Each faces will be size * size pixels.
  52292. */
  52293. size: number;
  52294. /**
  52295. * The format of the texture.
  52296. *
  52297. * RGBA, RGB.
  52298. */
  52299. format: number;
  52300. /**
  52301. * The type of the texture data.
  52302. *
  52303. * UNSIGNED_INT, FLOAT.
  52304. */
  52305. type: number;
  52306. /**
  52307. * Specifies whether the texture is in gamma space.
  52308. */
  52309. gammaSpace: boolean;
  52310. }
  52311. /**
  52312. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  52313. */
  52314. export class PanoramaToCubeMapTools {
  52315. private static FACE_LEFT;
  52316. private static FACE_RIGHT;
  52317. private static FACE_FRONT;
  52318. private static FACE_BACK;
  52319. private static FACE_DOWN;
  52320. private static FACE_UP;
  52321. /**
  52322. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  52323. *
  52324. * @param float32Array The source data.
  52325. * @param inputWidth The width of the input panorama.
  52326. * @param inputHeight The height of the input panorama.
  52327. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  52328. * @return The cubemap data
  52329. */
  52330. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  52331. private static CreateCubemapTexture;
  52332. private static CalcProjectionSpherical;
  52333. }
  52334. }
  52335. declare module BABYLON {
  52336. /**
  52337. * Helper class dealing with the extraction of spherical polynomial dataArray
  52338. * from a cube map.
  52339. */
  52340. export class CubeMapToSphericalPolynomialTools {
  52341. private static FileFaces;
  52342. /**
  52343. * Converts a texture to the according Spherical Polynomial data.
  52344. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52345. *
  52346. * @param texture The texture to extract the information from.
  52347. * @return The Spherical Polynomial data.
  52348. */
  52349. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  52350. /**
  52351. * Converts a cubemap to the according Spherical Polynomial data.
  52352. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52353. *
  52354. * @param cubeInfo The Cube map to extract the information from.
  52355. * @return The Spherical Polynomial data.
  52356. */
  52357. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  52358. }
  52359. }
  52360. declare module BABYLON {
  52361. interface BaseTexture {
  52362. /**
  52363. * Get the polynomial representation of the texture data.
  52364. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  52365. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  52366. */
  52367. sphericalPolynomial: Nullable<SphericalPolynomial>;
  52368. }
  52369. }
  52370. declare module BABYLON {
  52371. /** @hidden */
  52372. export var rgbdEncodePixelShader: {
  52373. name: string;
  52374. shader: string;
  52375. };
  52376. }
  52377. declare module BABYLON {
  52378. /** @hidden */
  52379. export var rgbdDecodePixelShader: {
  52380. name: string;
  52381. shader: string;
  52382. };
  52383. }
  52384. declare module BABYLON {
  52385. /**
  52386. * Raw texture data and descriptor sufficient for WebGL texture upload
  52387. */
  52388. export interface EnvironmentTextureInfo {
  52389. /**
  52390. * Version of the environment map
  52391. */
  52392. version: number;
  52393. /**
  52394. * Width of image
  52395. */
  52396. width: number;
  52397. /**
  52398. * Irradiance information stored in the file.
  52399. */
  52400. irradiance: any;
  52401. /**
  52402. * Specular information stored in the file.
  52403. */
  52404. specular: any;
  52405. }
  52406. /**
  52407. * Defines One Image in the file. It requires only the position in the file
  52408. * as well as the length.
  52409. */
  52410. interface BufferImageData {
  52411. /**
  52412. * Length of the image data.
  52413. */
  52414. length: number;
  52415. /**
  52416. * Position of the data from the null terminator delimiting the end of the JSON.
  52417. */
  52418. position: number;
  52419. }
  52420. /**
  52421. * Defines the specular data enclosed in the file.
  52422. * This corresponds to the version 1 of the data.
  52423. */
  52424. export interface EnvironmentTextureSpecularInfoV1 {
  52425. /**
  52426. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  52427. */
  52428. specularDataPosition?: number;
  52429. /**
  52430. * This contains all the images data needed to reconstruct the cubemap.
  52431. */
  52432. mipmaps: Array<BufferImageData>;
  52433. /**
  52434. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  52435. */
  52436. lodGenerationScale: number;
  52437. }
  52438. /**
  52439. * Sets of helpers addressing the serialization and deserialization of environment texture
  52440. * stored in a BabylonJS env file.
  52441. * Those files are usually stored as .env files.
  52442. */
  52443. export class EnvironmentTextureTools {
  52444. /**
  52445. * Magic number identifying the env file.
  52446. */
  52447. private static _MagicBytes;
  52448. /**
  52449. * Gets the environment info from an env file.
  52450. * @param data The array buffer containing the .env bytes.
  52451. * @returns the environment file info (the json header) if successfully parsed.
  52452. */
  52453. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  52454. /**
  52455. * Creates an environment texture from a loaded cube texture.
  52456. * @param texture defines the cube texture to convert in env file
  52457. * @return a promise containing the environment data if succesfull.
  52458. */
  52459. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  52460. /**
  52461. * Creates a JSON representation of the spherical data.
  52462. * @param texture defines the texture containing the polynomials
  52463. * @return the JSON representation of the spherical info
  52464. */
  52465. private static _CreateEnvTextureIrradiance;
  52466. /**
  52467. * Creates the ArrayBufferViews used for initializing environment texture image data.
  52468. * @param data the image data
  52469. * @param info parameters that determine what views will be created for accessing the underlying buffer
  52470. * @return the views described by info providing access to the underlying buffer
  52471. */
  52472. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  52473. /**
  52474. * Uploads the texture info contained in the env file to the GPU.
  52475. * @param texture defines the internal texture to upload to
  52476. * @param data defines the data to load
  52477. * @param info defines the texture info retrieved through the GetEnvInfo method
  52478. * @returns a promise
  52479. */
  52480. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  52481. private static _OnImageReadyAsync;
  52482. /**
  52483. * Uploads the levels of image data to the GPU.
  52484. * @param texture defines the internal texture to upload to
  52485. * @param imageData defines the array buffer views of image data [mipmap][face]
  52486. * @returns a promise
  52487. */
  52488. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  52489. /**
  52490. * Uploads spherical polynomials information to the texture.
  52491. * @param texture defines the texture we are trying to upload the information to
  52492. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  52493. */
  52494. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  52495. /** @hidden */
  52496. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52497. }
  52498. }
  52499. declare module BABYLON {
  52500. /**
  52501. * Class used to inline functions in shader code
  52502. */
  52503. export class ShaderCodeInliner {
  52504. private static readonly _RegexpFindFunctionNameAndType;
  52505. private _sourceCode;
  52506. private _functionDescr;
  52507. private _numMaxIterations;
  52508. /** Gets or sets the token used to mark the functions to inline */
  52509. inlineToken: string;
  52510. /** Gets or sets the debug mode */
  52511. debug: boolean;
  52512. /** Gets the code after the inlining process */
  52513. get code(): string;
  52514. /**
  52515. * Initializes the inliner
  52516. * @param sourceCode shader code source to inline
  52517. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  52518. */
  52519. constructor(sourceCode: string, numMaxIterations?: number);
  52520. /**
  52521. * Start the processing of the shader code
  52522. */
  52523. processCode(): void;
  52524. private _collectFunctions;
  52525. private _processInlining;
  52526. private _extractBetweenMarkers;
  52527. private _skipWhitespaces;
  52528. private _removeComments;
  52529. private _replaceFunctionCallsByCode;
  52530. private _findBackward;
  52531. private _escapeRegExp;
  52532. private _replaceNames;
  52533. }
  52534. }
  52535. declare module BABYLON {
  52536. /**
  52537. * Container for accessors for natively-stored mesh data buffers.
  52538. */
  52539. class NativeDataBuffer extends DataBuffer {
  52540. /**
  52541. * Accessor value used to identify/retrieve a natively-stored index buffer.
  52542. */
  52543. nativeIndexBuffer?: any;
  52544. /**
  52545. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  52546. */
  52547. nativeVertexBuffer?: any;
  52548. }
  52549. /** @hidden */
  52550. class NativeTexture extends InternalTexture {
  52551. getInternalTexture(): InternalTexture;
  52552. getViewCount(): number;
  52553. }
  52554. /** @hidden */
  52555. export class NativeEngine extends Engine {
  52556. private readonly _native;
  52557. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  52558. private readonly INVALID_HANDLE;
  52559. private _boundBuffersVertexArray;
  52560. getHardwareScalingLevel(): number;
  52561. constructor();
  52562. dispose(): void;
  52563. /**
  52564. * Can be used to override the current requestAnimationFrame requester.
  52565. * @hidden
  52566. */
  52567. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  52568. /**
  52569. * Override default engine behavior.
  52570. * @param color
  52571. * @param backBuffer
  52572. * @param depth
  52573. * @param stencil
  52574. */
  52575. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  52576. /**
  52577. * Gets host document
  52578. * @returns the host document object
  52579. */
  52580. getHostDocument(): Nullable<Document>;
  52581. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52582. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  52583. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  52584. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  52585. [key: string]: VertexBuffer;
  52586. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52587. bindBuffers(vertexBuffers: {
  52588. [key: string]: VertexBuffer;
  52589. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52590. recordVertexArrayObject(vertexBuffers: {
  52591. [key: string]: VertexBuffer;
  52592. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  52593. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52594. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52595. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52596. /**
  52597. * Draw a list of indexed primitives
  52598. * @param fillMode defines the primitive to use
  52599. * @param indexStart defines the starting index
  52600. * @param indexCount defines the number of index to draw
  52601. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52602. */
  52603. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52604. /**
  52605. * Draw a list of unindexed primitives
  52606. * @param fillMode defines the primitive to use
  52607. * @param verticesStart defines the index of first vertex to draw
  52608. * @param verticesCount defines the count of vertices to draw
  52609. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52610. */
  52611. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52612. createPipelineContext(): IPipelineContext;
  52613. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  52614. /** @hidden */
  52615. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  52616. /** @hidden */
  52617. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  52618. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52619. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52620. protected _setProgram(program: WebGLProgram): void;
  52621. _releaseEffect(effect: Effect): void;
  52622. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  52623. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  52624. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  52625. bindSamplers(effect: Effect): void;
  52626. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  52627. getRenderWidth(useScreen?: boolean): number;
  52628. getRenderHeight(useScreen?: boolean): number;
  52629. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  52630. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52631. /**
  52632. * Set the z offset to apply to current rendering
  52633. * @param value defines the offset to apply
  52634. */
  52635. setZOffset(value: number): void;
  52636. /**
  52637. * Gets the current value of the zOffset
  52638. * @returns the current zOffset state
  52639. */
  52640. getZOffset(): number;
  52641. /**
  52642. * Enable or disable depth buffering
  52643. * @param enable defines the state to set
  52644. */
  52645. setDepthBuffer(enable: boolean): void;
  52646. /**
  52647. * Gets a boolean indicating if depth writing is enabled
  52648. * @returns the current depth writing state
  52649. */
  52650. getDepthWrite(): boolean;
  52651. /**
  52652. * Enable or disable depth writing
  52653. * @param enable defines the state to set
  52654. */
  52655. setDepthWrite(enable: boolean): void;
  52656. /**
  52657. * Enable or disable color writing
  52658. * @param enable defines the state to set
  52659. */
  52660. setColorWrite(enable: boolean): void;
  52661. /**
  52662. * Gets a boolean indicating if color writing is enabled
  52663. * @returns the current color writing state
  52664. */
  52665. getColorWrite(): boolean;
  52666. /**
  52667. * Sets alpha constants used by some alpha blending modes
  52668. * @param r defines the red component
  52669. * @param g defines the green component
  52670. * @param b defines the blue component
  52671. * @param a defines the alpha component
  52672. */
  52673. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  52674. /**
  52675. * Sets the current alpha mode
  52676. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  52677. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52678. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52679. */
  52680. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52681. /**
  52682. * Gets the current alpha mode
  52683. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52684. * @returns the current alpha mode
  52685. */
  52686. getAlphaMode(): number;
  52687. setInt(uniform: WebGLUniformLocation, int: number): void;
  52688. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52689. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52690. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52691. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52692. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52693. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52694. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52695. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52696. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52697. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52698. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52699. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52700. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52701. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52702. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52703. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52704. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52705. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52706. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52707. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  52708. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  52709. wipeCaches(bruteForce?: boolean): void;
  52710. _createTexture(): WebGLTexture;
  52711. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  52712. /**
  52713. * Usually called from Texture.ts.
  52714. * Passed information to create a WebGLTexture
  52715. * @param url defines a value which contains one of the following:
  52716. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52717. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52718. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52719. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52720. * @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)
  52721. * @param scene needed for loading to the correct scene
  52722. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52723. * @param onLoad optional callback to be called upon successful completion
  52724. * @param onError optional callback to be called upon failure
  52725. * @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
  52726. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52727. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52728. * @param forcedExtension defines the extension to use to pick the right loader
  52729. * @param mimeType defines an optional mime type
  52730. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52731. */
  52732. 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;
  52733. /**
  52734. * Creates a cube texture
  52735. * @param rootUrl defines the url where the files to load is located
  52736. * @param scene defines the current scene
  52737. * @param files defines the list of files to load (1 per face)
  52738. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  52739. * @param onLoad defines an optional callback raised when the texture is loaded
  52740. * @param onError defines an optional callback raised if there is an issue to load the texture
  52741. * @param format defines the format of the data
  52742. * @param forcedExtension defines the extension to use to pick the right loader
  52743. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  52744. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52745. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52746. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  52747. * @returns the cube texture as an InternalTexture
  52748. */
  52749. 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;
  52750. private _getSamplingFilter;
  52751. private static _GetNativeTextureFormat;
  52752. createRenderTargetTexture(size: number | {
  52753. width: number;
  52754. height: number;
  52755. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  52756. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52757. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52758. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52759. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  52760. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  52761. /**
  52762. * Updates a dynamic vertex buffer.
  52763. * @param vertexBuffer the vertex buffer to update
  52764. * @param data the data used to update the vertex buffer
  52765. * @param byteOffset the byte offset of the data (optional)
  52766. * @param byteLength the byte length of the data (optional)
  52767. */
  52768. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  52769. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  52770. private _updateAnisotropicLevel;
  52771. private _getAddressMode;
  52772. /** @hidden */
  52773. _bindTexture(channel: number, texture: InternalTexture): void;
  52774. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  52775. releaseEffects(): void;
  52776. /** @hidden */
  52777. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52778. /** @hidden */
  52779. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52780. /** @hidden */
  52781. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52782. /** @hidden */
  52783. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52784. }
  52785. }
  52786. declare module BABYLON {
  52787. /**
  52788. * Gather the list of clipboard event types as constants.
  52789. */
  52790. export class ClipboardEventTypes {
  52791. /**
  52792. * The clipboard event is fired when a copy command is active (pressed).
  52793. */
  52794. static readonly COPY: number;
  52795. /**
  52796. * The clipboard event is fired when a cut command is active (pressed).
  52797. */
  52798. static readonly CUT: number;
  52799. /**
  52800. * The clipboard event is fired when a paste command is active (pressed).
  52801. */
  52802. static readonly PASTE: number;
  52803. }
  52804. /**
  52805. * This class is used to store clipboard related info for the onClipboardObservable event.
  52806. */
  52807. export class ClipboardInfo {
  52808. /**
  52809. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52810. */
  52811. type: number;
  52812. /**
  52813. * Defines the related dom event
  52814. */
  52815. event: ClipboardEvent;
  52816. /**
  52817. *Creates an instance of ClipboardInfo.
  52818. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  52819. * @param event Defines the related dom event
  52820. */
  52821. constructor(
  52822. /**
  52823. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52824. */
  52825. type: number,
  52826. /**
  52827. * Defines the related dom event
  52828. */
  52829. event: ClipboardEvent);
  52830. /**
  52831. * Get the clipboard event's type from the keycode.
  52832. * @param keyCode Defines the keyCode for the current keyboard event.
  52833. * @return {number}
  52834. */
  52835. static GetTypeFromCharacter(keyCode: number): number;
  52836. }
  52837. }
  52838. declare module BABYLON {
  52839. /**
  52840. * Google Daydream controller
  52841. */
  52842. export class DaydreamController extends WebVRController {
  52843. /**
  52844. * Base Url for the controller model.
  52845. */
  52846. static MODEL_BASE_URL: string;
  52847. /**
  52848. * File name for the controller model.
  52849. */
  52850. static MODEL_FILENAME: string;
  52851. /**
  52852. * Gamepad Id prefix used to identify Daydream Controller.
  52853. */
  52854. static readonly GAMEPAD_ID_PREFIX: string;
  52855. /**
  52856. * Creates a new DaydreamController from a gamepad
  52857. * @param vrGamepad the gamepad that the controller should be created from
  52858. */
  52859. constructor(vrGamepad: any);
  52860. /**
  52861. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52862. * @param scene scene in which to add meshes
  52863. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52864. */
  52865. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52866. /**
  52867. * Called once for each button that changed state since the last frame
  52868. * @param buttonIdx Which button index changed
  52869. * @param state New state of the button
  52870. * @param changes Which properties on the state changed since last frame
  52871. */
  52872. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52873. }
  52874. }
  52875. declare module BABYLON {
  52876. /**
  52877. * Gear VR Controller
  52878. */
  52879. export class GearVRController extends WebVRController {
  52880. /**
  52881. * Base Url for the controller model.
  52882. */
  52883. static MODEL_BASE_URL: string;
  52884. /**
  52885. * File name for the controller model.
  52886. */
  52887. static MODEL_FILENAME: string;
  52888. /**
  52889. * Gamepad Id prefix used to identify this controller.
  52890. */
  52891. static readonly GAMEPAD_ID_PREFIX: string;
  52892. private readonly _buttonIndexToObservableNameMap;
  52893. /**
  52894. * Creates a new GearVRController from a gamepad
  52895. * @param vrGamepad the gamepad that the controller should be created from
  52896. */
  52897. constructor(vrGamepad: any);
  52898. /**
  52899. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52900. * @param scene scene in which to add meshes
  52901. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52902. */
  52903. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52904. /**
  52905. * Called once for each button that changed state since the last frame
  52906. * @param buttonIdx Which button index changed
  52907. * @param state New state of the button
  52908. * @param changes Which properties on the state changed since last frame
  52909. */
  52910. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52911. }
  52912. }
  52913. declare module BABYLON {
  52914. /**
  52915. * Generic Controller
  52916. */
  52917. export class GenericController extends WebVRController {
  52918. /**
  52919. * Base Url for the controller model.
  52920. */
  52921. static readonly MODEL_BASE_URL: string;
  52922. /**
  52923. * File name for the controller model.
  52924. */
  52925. static readonly MODEL_FILENAME: string;
  52926. /**
  52927. * Creates a new GenericController from a gamepad
  52928. * @param vrGamepad the gamepad that the controller should be created from
  52929. */
  52930. constructor(vrGamepad: any);
  52931. /**
  52932. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52933. * @param scene scene in which to add meshes
  52934. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52935. */
  52936. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52937. /**
  52938. * Called once for each button that changed state since the last frame
  52939. * @param buttonIdx Which button index changed
  52940. * @param state New state of the button
  52941. * @param changes Which properties on the state changed since last frame
  52942. */
  52943. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52944. }
  52945. }
  52946. declare module BABYLON {
  52947. /**
  52948. * Oculus Touch Controller
  52949. */
  52950. export class OculusTouchController extends WebVRController {
  52951. /**
  52952. * Base Url for the controller model.
  52953. */
  52954. static MODEL_BASE_URL: string;
  52955. /**
  52956. * File name for the left controller model.
  52957. */
  52958. static MODEL_LEFT_FILENAME: string;
  52959. /**
  52960. * File name for the right controller model.
  52961. */
  52962. static MODEL_RIGHT_FILENAME: string;
  52963. /**
  52964. * Base Url for the Quest controller model.
  52965. */
  52966. static QUEST_MODEL_BASE_URL: string;
  52967. /**
  52968. * @hidden
  52969. * If the controllers are running on a device that needs the updated Quest controller models
  52970. */
  52971. static _IsQuest: boolean;
  52972. /**
  52973. * Fired when the secondary trigger on this controller is modified
  52974. */
  52975. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  52976. /**
  52977. * Fired when the thumb rest on this controller is modified
  52978. */
  52979. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  52980. /**
  52981. * Creates a new OculusTouchController from a gamepad
  52982. * @param vrGamepad the gamepad that the controller should be created from
  52983. */
  52984. constructor(vrGamepad: any);
  52985. /**
  52986. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52987. * @param scene scene in which to add meshes
  52988. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52989. */
  52990. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52991. /**
  52992. * Fired when the A button on this controller is modified
  52993. */
  52994. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52995. /**
  52996. * Fired when the B button on this controller is modified
  52997. */
  52998. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52999. /**
  53000. * Fired when the X button on this controller is modified
  53001. */
  53002. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53003. /**
  53004. * Fired when the Y button on this controller is modified
  53005. */
  53006. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53007. /**
  53008. * Called once for each button that changed state since the last frame
  53009. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  53010. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  53011. * 2) secondary trigger (same)
  53012. * 3) A (right) X (left), touch, pressed = value
  53013. * 4) B / Y
  53014. * 5) thumb rest
  53015. * @param buttonIdx Which button index changed
  53016. * @param state New state of the button
  53017. * @param changes Which properties on the state changed since last frame
  53018. */
  53019. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53020. }
  53021. }
  53022. declare module BABYLON {
  53023. /**
  53024. * Vive Controller
  53025. */
  53026. export class ViveController extends WebVRController {
  53027. /**
  53028. * Base Url for the controller model.
  53029. */
  53030. static MODEL_BASE_URL: string;
  53031. /**
  53032. * File name for the controller model.
  53033. */
  53034. static MODEL_FILENAME: string;
  53035. /**
  53036. * Creates a new ViveController from a gamepad
  53037. * @param vrGamepad the gamepad that the controller should be created from
  53038. */
  53039. constructor(vrGamepad: any);
  53040. /**
  53041. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53042. * @param scene scene in which to add meshes
  53043. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53044. */
  53045. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53046. /**
  53047. * Fired when the left button on this controller is modified
  53048. */
  53049. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53050. /**
  53051. * Fired when the right button on this controller is modified
  53052. */
  53053. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53054. /**
  53055. * Fired when the menu button on this controller is modified
  53056. */
  53057. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53058. /**
  53059. * Called once for each button that changed state since the last frame
  53060. * Vive mapping:
  53061. * 0: touchpad
  53062. * 1: trigger
  53063. * 2: left AND right buttons
  53064. * 3: menu button
  53065. * @param buttonIdx Which button index changed
  53066. * @param state New state of the button
  53067. * @param changes Which properties on the state changed since last frame
  53068. */
  53069. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53070. }
  53071. }
  53072. declare module BABYLON {
  53073. /**
  53074. * Defines the WindowsMotionController object that the state of the windows motion controller
  53075. */
  53076. export class WindowsMotionController extends WebVRController {
  53077. /**
  53078. * The base url used to load the left and right controller models
  53079. */
  53080. static MODEL_BASE_URL: string;
  53081. /**
  53082. * The name of the left controller model file
  53083. */
  53084. static MODEL_LEFT_FILENAME: string;
  53085. /**
  53086. * The name of the right controller model file
  53087. */
  53088. static MODEL_RIGHT_FILENAME: string;
  53089. /**
  53090. * The controller name prefix for this controller type
  53091. */
  53092. static readonly GAMEPAD_ID_PREFIX: string;
  53093. /**
  53094. * The controller id pattern for this controller type
  53095. */
  53096. private static readonly GAMEPAD_ID_PATTERN;
  53097. private _loadedMeshInfo;
  53098. protected readonly _mapping: {
  53099. buttons: string[];
  53100. buttonMeshNames: {
  53101. trigger: string;
  53102. menu: string;
  53103. grip: string;
  53104. thumbstick: string;
  53105. trackpad: string;
  53106. };
  53107. buttonObservableNames: {
  53108. trigger: string;
  53109. menu: string;
  53110. grip: string;
  53111. thumbstick: string;
  53112. trackpad: string;
  53113. };
  53114. axisMeshNames: string[];
  53115. pointingPoseMeshName: string;
  53116. };
  53117. /**
  53118. * Fired when the trackpad on this controller is clicked
  53119. */
  53120. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53121. /**
  53122. * Fired when the trackpad on this controller is modified
  53123. */
  53124. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53125. /**
  53126. * The current x and y values of this controller's trackpad
  53127. */
  53128. trackpad: StickValues;
  53129. /**
  53130. * Creates a new WindowsMotionController from a gamepad
  53131. * @param vrGamepad the gamepad that the controller should be created from
  53132. */
  53133. constructor(vrGamepad: any);
  53134. /**
  53135. * Fired when the trigger on this controller is modified
  53136. */
  53137. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53138. /**
  53139. * Fired when the menu button on this controller is modified
  53140. */
  53141. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53142. /**
  53143. * Fired when the grip button on this controller is modified
  53144. */
  53145. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53146. /**
  53147. * Fired when the thumbstick button on this controller is modified
  53148. */
  53149. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53150. /**
  53151. * Fired when the touchpad button on this controller is modified
  53152. */
  53153. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53154. /**
  53155. * Fired when the touchpad values on this controller are modified
  53156. */
  53157. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  53158. protected _updateTrackpad(): void;
  53159. /**
  53160. * Called once per frame by the engine.
  53161. */
  53162. update(): void;
  53163. /**
  53164. * Called once for each button that changed state since the last frame
  53165. * @param buttonIdx Which button index changed
  53166. * @param state New state of the button
  53167. * @param changes Which properties on the state changed since last frame
  53168. */
  53169. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53170. /**
  53171. * Moves the buttons on the controller mesh based on their current state
  53172. * @param buttonName the name of the button to move
  53173. * @param buttonValue the value of the button which determines the buttons new position
  53174. */
  53175. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  53176. /**
  53177. * Moves the axis on the controller mesh based on its current state
  53178. * @param axis the index of the axis
  53179. * @param axisValue the value of the axis which determines the meshes new position
  53180. * @hidden
  53181. */
  53182. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  53183. /**
  53184. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53185. * @param scene scene in which to add meshes
  53186. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53187. */
  53188. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  53189. /**
  53190. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  53191. * can be transformed by button presses and axes values, based on this._mapping.
  53192. *
  53193. * @param scene scene in which the meshes exist
  53194. * @param meshes list of meshes that make up the controller model to process
  53195. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  53196. */
  53197. private processModel;
  53198. private createMeshInfo;
  53199. /**
  53200. * Gets the ray of the controller in the direction the controller is pointing
  53201. * @param length the length the resulting ray should be
  53202. * @returns a ray in the direction the controller is pointing
  53203. */
  53204. getForwardRay(length?: number): Ray;
  53205. /**
  53206. * Disposes of the controller
  53207. */
  53208. dispose(): void;
  53209. }
  53210. /**
  53211. * This class represents a new windows motion controller in XR.
  53212. */
  53213. export class XRWindowsMotionController extends WindowsMotionController {
  53214. /**
  53215. * Changing the original WIndowsMotionController mapping to fir the new mapping
  53216. */
  53217. protected readonly _mapping: {
  53218. buttons: string[];
  53219. buttonMeshNames: {
  53220. trigger: string;
  53221. menu: string;
  53222. grip: string;
  53223. thumbstick: string;
  53224. trackpad: string;
  53225. };
  53226. buttonObservableNames: {
  53227. trigger: string;
  53228. menu: string;
  53229. grip: string;
  53230. thumbstick: string;
  53231. trackpad: string;
  53232. };
  53233. axisMeshNames: string[];
  53234. pointingPoseMeshName: string;
  53235. };
  53236. /**
  53237. * Construct a new XR-Based windows motion controller
  53238. *
  53239. * @param gamepadInfo the gamepad object from the browser
  53240. */
  53241. constructor(gamepadInfo: any);
  53242. /**
  53243. * holds the thumbstick values (X,Y)
  53244. */
  53245. thumbstickValues: StickValues;
  53246. /**
  53247. * Fired when the thumbstick on this controller is clicked
  53248. */
  53249. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  53250. /**
  53251. * Fired when the thumbstick on this controller is modified
  53252. */
  53253. onThumbstickValuesChangedObservable: Observable<StickValues>;
  53254. /**
  53255. * Fired when the touchpad button on this controller is modified
  53256. */
  53257. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53258. /**
  53259. * Fired when the touchpad values on this controller are modified
  53260. */
  53261. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53262. /**
  53263. * Fired when the thumbstick button on this controller is modified
  53264. * here to prevent breaking changes
  53265. */
  53266. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53267. /**
  53268. * updating the thumbstick(!) and not the trackpad.
  53269. * This is named this way due to the difference between WebVR and XR and to avoid
  53270. * changing the parent class.
  53271. */
  53272. protected _updateTrackpad(): void;
  53273. /**
  53274. * Disposes the class with joy
  53275. */
  53276. dispose(): void;
  53277. }
  53278. }
  53279. declare module BABYLON {
  53280. /**
  53281. * Class containing static functions to help procedurally build meshes
  53282. */
  53283. export class PolyhedronBuilder {
  53284. /**
  53285. * Creates a polyhedron mesh
  53286. * * 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
  53287. * * The parameter `size` (positive float, default 1) sets the polygon size
  53288. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53289. * * 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`
  53290. * * 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
  53291. * * 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)`)
  53292. * * 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
  53293. * * 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
  53294. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53295. * * 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
  53296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53297. * @param name defines the name of the mesh
  53298. * @param options defines the options used to create the mesh
  53299. * @param scene defines the hosting scene
  53300. * @returns the polyhedron mesh
  53301. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53302. */
  53303. static CreatePolyhedron(name: string, options: {
  53304. type?: number;
  53305. size?: number;
  53306. sizeX?: number;
  53307. sizeY?: number;
  53308. sizeZ?: number;
  53309. custom?: any;
  53310. faceUV?: Vector4[];
  53311. faceColors?: Color4[];
  53312. flat?: boolean;
  53313. updatable?: boolean;
  53314. sideOrientation?: number;
  53315. frontUVs?: Vector4;
  53316. backUVs?: Vector4;
  53317. }, scene?: Nullable<Scene>): Mesh;
  53318. }
  53319. }
  53320. declare module BABYLON {
  53321. /**
  53322. * Gizmo that enables scaling a mesh along 3 axis
  53323. */
  53324. export class ScaleGizmo extends Gizmo {
  53325. /**
  53326. * Internal gizmo used for interactions on the x axis
  53327. */
  53328. xGizmo: AxisScaleGizmo;
  53329. /**
  53330. * Internal gizmo used for interactions on the y axis
  53331. */
  53332. yGizmo: AxisScaleGizmo;
  53333. /**
  53334. * Internal gizmo used for interactions on the z axis
  53335. */
  53336. zGizmo: AxisScaleGizmo;
  53337. /**
  53338. * Internal gizmo used to scale all axis equally
  53339. */
  53340. uniformScaleGizmo: AxisScaleGizmo;
  53341. private _meshAttached;
  53342. private _nodeAttached;
  53343. private _updateGizmoRotationToMatchAttachedMesh;
  53344. private _snapDistance;
  53345. private _scaleRatio;
  53346. private _uniformScalingMesh;
  53347. private _octahedron;
  53348. private _sensitivity;
  53349. /** Fires an event when any of it's sub gizmos are dragged */
  53350. onDragStartObservable: Observable<unknown>;
  53351. /** Fires an event when any of it's sub gizmos are released from dragging */
  53352. onDragEndObservable: Observable<unknown>;
  53353. get attachedMesh(): Nullable<AbstractMesh>;
  53354. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53355. get attachedNode(): Nullable<Node>;
  53356. set attachedNode(node: Nullable<Node>);
  53357. /**
  53358. * Creates a ScaleGizmo
  53359. * @param gizmoLayer The utility layer the gizmo will be added to
  53360. * @param thickness display gizmo axis thickness
  53361. */
  53362. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53363. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53364. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53365. /**
  53366. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53367. */
  53368. set snapDistance(value: number);
  53369. get snapDistance(): number;
  53370. /**
  53371. * Ratio for the scale of the gizmo (Default: 1)
  53372. */
  53373. set scaleRatio(value: number);
  53374. get scaleRatio(): number;
  53375. /**
  53376. * Sensitivity factor for dragging (Default: 1)
  53377. */
  53378. set sensitivity(value: number);
  53379. get sensitivity(): number;
  53380. /**
  53381. * Disposes of the gizmo
  53382. */
  53383. dispose(): void;
  53384. }
  53385. }
  53386. declare module BABYLON {
  53387. /**
  53388. * Single axis scale gizmo
  53389. */
  53390. export class AxisScaleGizmo extends Gizmo {
  53391. /**
  53392. * Drag behavior responsible for the gizmos dragging interactions
  53393. */
  53394. dragBehavior: PointerDragBehavior;
  53395. private _pointerObserver;
  53396. /**
  53397. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53398. */
  53399. snapDistance: number;
  53400. /**
  53401. * Event that fires each time the gizmo snaps to a new location.
  53402. * * snapDistance is the the change in distance
  53403. */
  53404. onSnapObservable: Observable<{
  53405. snapDistance: number;
  53406. }>;
  53407. /**
  53408. * If the scaling operation should be done on all axis (default: false)
  53409. */
  53410. uniformScaling: boolean;
  53411. /**
  53412. * Custom sensitivity value for the drag strength
  53413. */
  53414. sensitivity: number;
  53415. private _isEnabled;
  53416. private _parent;
  53417. private _arrow;
  53418. private _coloredMaterial;
  53419. private _hoverMaterial;
  53420. /**
  53421. * Creates an AxisScaleGizmo
  53422. * @param gizmoLayer The utility layer the gizmo will be added to
  53423. * @param dragAxis The axis which the gizmo will be able to scale on
  53424. * @param color The color of the gizmo
  53425. * @param thickness display gizmo axis thickness
  53426. */
  53427. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  53428. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53429. /**
  53430. * If the gizmo is enabled
  53431. */
  53432. set isEnabled(value: boolean);
  53433. get isEnabled(): boolean;
  53434. /**
  53435. * Disposes of the gizmo
  53436. */
  53437. dispose(): void;
  53438. /**
  53439. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53440. * @param mesh The mesh to replace the default mesh of the gizmo
  53441. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  53442. */
  53443. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  53444. }
  53445. }
  53446. declare module BABYLON {
  53447. /**
  53448. * Bounding box gizmo
  53449. */
  53450. export class BoundingBoxGizmo extends Gizmo {
  53451. private _lineBoundingBox;
  53452. private _rotateSpheresParent;
  53453. private _scaleBoxesParent;
  53454. private _boundingDimensions;
  53455. private _renderObserver;
  53456. private _pointerObserver;
  53457. private _scaleDragSpeed;
  53458. private _tmpQuaternion;
  53459. private _tmpVector;
  53460. private _tmpRotationMatrix;
  53461. /**
  53462. * 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)
  53463. */
  53464. ignoreChildren: boolean;
  53465. /**
  53466. * 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)
  53467. */
  53468. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  53469. /**
  53470. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  53471. */
  53472. rotationSphereSize: number;
  53473. /**
  53474. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  53475. */
  53476. scaleBoxSize: number;
  53477. /**
  53478. * 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)
  53479. */
  53480. fixedDragMeshScreenSize: boolean;
  53481. /**
  53482. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  53483. */
  53484. fixedDragMeshScreenSizeDistanceFactor: number;
  53485. /**
  53486. * Fired when a rotation sphere or scale box is dragged
  53487. */
  53488. onDragStartObservable: Observable<{}>;
  53489. /**
  53490. * Fired when a scale box is dragged
  53491. */
  53492. onScaleBoxDragObservable: Observable<{}>;
  53493. /**
  53494. * Fired when a scale box drag is ended
  53495. */
  53496. onScaleBoxDragEndObservable: Observable<{}>;
  53497. /**
  53498. * Fired when a rotation sphere is dragged
  53499. */
  53500. onRotationSphereDragObservable: Observable<{}>;
  53501. /**
  53502. * Fired when a rotation sphere drag is ended
  53503. */
  53504. onRotationSphereDragEndObservable: Observable<{}>;
  53505. /**
  53506. * 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)
  53507. */
  53508. scalePivot: Nullable<Vector3>;
  53509. /**
  53510. * Mesh used as a pivot to rotate the attached node
  53511. */
  53512. private _anchorMesh;
  53513. private _existingMeshScale;
  53514. private _dragMesh;
  53515. private pointerDragBehavior;
  53516. private coloredMaterial;
  53517. private hoverColoredMaterial;
  53518. /**
  53519. * Sets the color of the bounding box gizmo
  53520. * @param color the color to set
  53521. */
  53522. setColor(color: Color3): void;
  53523. /**
  53524. * Creates an BoundingBoxGizmo
  53525. * @param gizmoLayer The utility layer the gizmo will be added to
  53526. * @param color The color of the gizmo
  53527. */
  53528. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  53529. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  53530. private _selectNode;
  53531. /**
  53532. * Updates the bounding box information for the Gizmo
  53533. */
  53534. updateBoundingBox(): void;
  53535. private _updateRotationSpheres;
  53536. private _updateScaleBoxes;
  53537. /**
  53538. * Enables rotation on the specified axis and disables rotation on the others
  53539. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  53540. */
  53541. setEnabledRotationAxis(axis: string): void;
  53542. /**
  53543. * Enables/disables scaling
  53544. * @param enable if scaling should be enabled
  53545. * @param homogeneousScaling defines if scaling should only be homogeneous
  53546. */
  53547. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  53548. private _updateDummy;
  53549. /**
  53550. * Enables a pointer drag behavior on the bounding box of the gizmo
  53551. */
  53552. enableDragBehavior(): void;
  53553. /**
  53554. * Disposes of the gizmo
  53555. */
  53556. dispose(): void;
  53557. /**
  53558. * 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)
  53559. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  53560. * @returns the bounding box mesh with the passed in mesh as a child
  53561. */
  53562. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  53563. /**
  53564. * CustomMeshes are not supported by this gizmo
  53565. * @param mesh The mesh to replace the default mesh of the gizmo
  53566. */
  53567. setCustomMesh(mesh: Mesh): void;
  53568. }
  53569. }
  53570. declare module BABYLON {
  53571. /**
  53572. * Single plane rotation gizmo
  53573. */
  53574. export class PlaneRotationGizmo extends Gizmo {
  53575. /**
  53576. * Drag behavior responsible for the gizmos dragging interactions
  53577. */
  53578. dragBehavior: PointerDragBehavior;
  53579. private _pointerObserver;
  53580. /**
  53581. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  53582. */
  53583. snapDistance: number;
  53584. /**
  53585. * Event that fires each time the gizmo snaps to a new location.
  53586. * * snapDistance is the the change in distance
  53587. */
  53588. onSnapObservable: Observable<{
  53589. snapDistance: number;
  53590. }>;
  53591. private _isEnabled;
  53592. private _parent;
  53593. /**
  53594. * Creates a PlaneRotationGizmo
  53595. * @param gizmoLayer The utility layer the gizmo will be added to
  53596. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  53597. * @param color The color of the gizmo
  53598. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53599. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53600. * @param thickness display gizmo axis thickness
  53601. */
  53602. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  53603. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53604. /**
  53605. * If the gizmo is enabled
  53606. */
  53607. set isEnabled(value: boolean);
  53608. get isEnabled(): boolean;
  53609. /**
  53610. * Disposes of the gizmo
  53611. */
  53612. dispose(): void;
  53613. }
  53614. }
  53615. declare module BABYLON {
  53616. /**
  53617. * Gizmo that enables rotating a mesh along 3 axis
  53618. */
  53619. export class RotationGizmo extends Gizmo {
  53620. /**
  53621. * Internal gizmo used for interactions on the x axis
  53622. */
  53623. xGizmo: PlaneRotationGizmo;
  53624. /**
  53625. * Internal gizmo used for interactions on the y axis
  53626. */
  53627. yGizmo: PlaneRotationGizmo;
  53628. /**
  53629. * Internal gizmo used for interactions on the z axis
  53630. */
  53631. zGizmo: PlaneRotationGizmo;
  53632. /** Fires an event when any of it's sub gizmos are dragged */
  53633. onDragStartObservable: Observable<unknown>;
  53634. /** Fires an event when any of it's sub gizmos are released from dragging */
  53635. onDragEndObservable: Observable<unknown>;
  53636. private _meshAttached;
  53637. private _nodeAttached;
  53638. get attachedMesh(): Nullable<AbstractMesh>;
  53639. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53640. get attachedNode(): Nullable<Node>;
  53641. set attachedNode(node: Nullable<Node>);
  53642. /**
  53643. * Creates a RotationGizmo
  53644. * @param gizmoLayer The utility layer the gizmo will be added to
  53645. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53646. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53647. * @param thickness display gizmo axis thickness
  53648. */
  53649. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  53650. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53651. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53652. /**
  53653. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53654. */
  53655. set snapDistance(value: number);
  53656. get snapDistance(): number;
  53657. /**
  53658. * Ratio for the scale of the gizmo (Default: 1)
  53659. */
  53660. set scaleRatio(value: number);
  53661. get scaleRatio(): number;
  53662. /**
  53663. * Disposes of the gizmo
  53664. */
  53665. dispose(): void;
  53666. /**
  53667. * CustomMeshes are not supported by this gizmo
  53668. * @param mesh The mesh to replace the default mesh of the gizmo
  53669. */
  53670. setCustomMesh(mesh: Mesh): void;
  53671. }
  53672. }
  53673. declare module BABYLON {
  53674. /**
  53675. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  53676. */
  53677. export class GizmoManager implements IDisposable {
  53678. private scene;
  53679. /**
  53680. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  53681. */
  53682. gizmos: {
  53683. positionGizmo: Nullable<PositionGizmo>;
  53684. rotationGizmo: Nullable<RotationGizmo>;
  53685. scaleGizmo: Nullable<ScaleGizmo>;
  53686. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  53687. };
  53688. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  53689. clearGizmoOnEmptyPointerEvent: boolean;
  53690. /** Fires an event when the manager is attached to a mesh */
  53691. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  53692. /** Fires an event when the manager is attached to a node */
  53693. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  53694. private _gizmosEnabled;
  53695. private _pointerObserver;
  53696. private _attachedMesh;
  53697. private _attachedNode;
  53698. private _boundingBoxColor;
  53699. private _defaultUtilityLayer;
  53700. private _defaultKeepDepthUtilityLayer;
  53701. private _thickness;
  53702. /**
  53703. * When bounding box gizmo is enabled, this can be used to track drag/end events
  53704. */
  53705. boundingBoxDragBehavior: SixDofDragBehavior;
  53706. /**
  53707. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  53708. */
  53709. attachableMeshes: Nullable<Array<AbstractMesh>>;
  53710. /**
  53711. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  53712. */
  53713. attachableNodes: Nullable<Array<Node>>;
  53714. /**
  53715. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  53716. */
  53717. usePointerToAttachGizmos: boolean;
  53718. /**
  53719. * Utility layer that the bounding box gizmo belongs to
  53720. */
  53721. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  53722. /**
  53723. * Utility layer that all gizmos besides bounding box belong to
  53724. */
  53725. get utilityLayer(): UtilityLayerRenderer;
  53726. /**
  53727. * Instatiates a gizmo manager
  53728. * @param scene the scene to overlay the gizmos on top of
  53729. * @param thickness display gizmo axis thickness
  53730. */
  53731. constructor(scene: Scene, thickness?: number);
  53732. /**
  53733. * Attaches a set of gizmos to the specified mesh
  53734. * @param mesh The mesh the gizmo's should be attached to
  53735. */
  53736. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53737. /**
  53738. * Attaches a set of gizmos to the specified node
  53739. * @param node The node the gizmo's should be attached to
  53740. */
  53741. attachToNode(node: Nullable<Node>): void;
  53742. /**
  53743. * If the position gizmo is enabled
  53744. */
  53745. set positionGizmoEnabled(value: boolean);
  53746. get positionGizmoEnabled(): boolean;
  53747. /**
  53748. * If the rotation gizmo is enabled
  53749. */
  53750. set rotationGizmoEnabled(value: boolean);
  53751. get rotationGizmoEnabled(): boolean;
  53752. /**
  53753. * If the scale gizmo is enabled
  53754. */
  53755. set scaleGizmoEnabled(value: boolean);
  53756. get scaleGizmoEnabled(): boolean;
  53757. /**
  53758. * If the boundingBox gizmo is enabled
  53759. */
  53760. set boundingBoxGizmoEnabled(value: boolean);
  53761. get boundingBoxGizmoEnabled(): boolean;
  53762. /**
  53763. * Disposes of the gizmo manager
  53764. */
  53765. dispose(): void;
  53766. }
  53767. }
  53768. declare module BABYLON {
  53769. /**
  53770. * A directional light is defined by a direction (what a surprise!).
  53771. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  53772. * 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.
  53773. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53774. */
  53775. export class DirectionalLight extends ShadowLight {
  53776. private _shadowFrustumSize;
  53777. /**
  53778. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  53779. */
  53780. get shadowFrustumSize(): number;
  53781. /**
  53782. * Specifies a fix frustum size for the shadow generation.
  53783. */
  53784. set shadowFrustumSize(value: number);
  53785. private _shadowOrthoScale;
  53786. /**
  53787. * Gets the shadow projection scale against the optimal computed one.
  53788. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  53789. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  53790. */
  53791. get shadowOrthoScale(): number;
  53792. /**
  53793. * Sets the shadow projection scale against the optimal computed one.
  53794. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  53795. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  53796. */
  53797. set shadowOrthoScale(value: number);
  53798. /**
  53799. * Automatically compute the projection matrix to best fit (including all the casters)
  53800. * on each frame.
  53801. */
  53802. autoUpdateExtends: boolean;
  53803. /**
  53804. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  53805. * on each frame. autoUpdateExtends must be set to true for this to work
  53806. */
  53807. autoCalcShadowZBounds: boolean;
  53808. private _orthoLeft;
  53809. private _orthoRight;
  53810. private _orthoTop;
  53811. private _orthoBottom;
  53812. /**
  53813. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  53814. * The directional light is emitted from everywhere in the given direction.
  53815. * It can cast shadows.
  53816. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53817. * @param name The friendly name of the light
  53818. * @param direction The direction of the light
  53819. * @param scene The scene the light belongs to
  53820. */
  53821. constructor(name: string, direction: Vector3, scene: Scene);
  53822. /**
  53823. * Returns the string "DirectionalLight".
  53824. * @return The class name
  53825. */
  53826. getClassName(): string;
  53827. /**
  53828. * Returns the integer 1.
  53829. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53830. */
  53831. getTypeID(): number;
  53832. /**
  53833. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  53834. * Returns the DirectionalLight Shadow projection matrix.
  53835. */
  53836. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53837. /**
  53838. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  53839. * Returns the DirectionalLight Shadow projection matrix.
  53840. */
  53841. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  53842. /**
  53843. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  53844. * Returns the DirectionalLight Shadow projection matrix.
  53845. */
  53846. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53847. protected _buildUniformLayout(): void;
  53848. /**
  53849. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  53850. * @param effect The effect to update
  53851. * @param lightIndex The index of the light in the effect to update
  53852. * @returns The directional light
  53853. */
  53854. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  53855. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  53856. /**
  53857. * Gets the minZ used for shadow according to both the scene and the light.
  53858. *
  53859. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  53860. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  53861. * @param activeCamera The camera we are returning the min for
  53862. * @returns the depth min z
  53863. */
  53864. getDepthMinZ(activeCamera: Camera): number;
  53865. /**
  53866. * Gets the maxZ used for shadow according to both the scene and the light.
  53867. *
  53868. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  53869. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  53870. * @param activeCamera The camera we are returning the max for
  53871. * @returns the depth max z
  53872. */
  53873. getDepthMaxZ(activeCamera: Camera): number;
  53874. /**
  53875. * Prepares the list of defines specific to the light type.
  53876. * @param defines the list of defines
  53877. * @param lightIndex defines the index of the light for the effect
  53878. */
  53879. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53880. }
  53881. }
  53882. declare module BABYLON {
  53883. /**
  53884. * Class containing static functions to help procedurally build meshes
  53885. */
  53886. export class HemisphereBuilder {
  53887. /**
  53888. * Creates a hemisphere mesh
  53889. * @param name defines the name of the mesh
  53890. * @param options defines the options used to create the mesh
  53891. * @param scene defines the hosting scene
  53892. * @returns the hemisphere mesh
  53893. */
  53894. static CreateHemisphere(name: string, options: {
  53895. segments?: number;
  53896. diameter?: number;
  53897. sideOrientation?: number;
  53898. }, scene: any): Mesh;
  53899. }
  53900. }
  53901. declare module BABYLON {
  53902. /**
  53903. * A spot light is defined by a position, a direction, an angle, and an exponent.
  53904. * These values define a cone of light starting from the position, emitting toward the direction.
  53905. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  53906. * and the exponent defines the speed of the decay of the light with distance (reach).
  53907. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53908. */
  53909. export class SpotLight extends ShadowLight {
  53910. private _angle;
  53911. private _innerAngle;
  53912. private _cosHalfAngle;
  53913. private _lightAngleScale;
  53914. private _lightAngleOffset;
  53915. /**
  53916. * Gets the cone angle of the spot light in Radians.
  53917. */
  53918. get angle(): number;
  53919. /**
  53920. * Sets the cone angle of the spot light in Radians.
  53921. */
  53922. set angle(value: number);
  53923. /**
  53924. * Only used in gltf falloff mode, this defines the angle where
  53925. * the directional falloff will start before cutting at angle which could be seen
  53926. * as outer angle.
  53927. */
  53928. get innerAngle(): number;
  53929. /**
  53930. * Only used in gltf falloff mode, this defines the angle where
  53931. * the directional falloff will start before cutting at angle which could be seen
  53932. * as outer angle.
  53933. */
  53934. set innerAngle(value: number);
  53935. private _shadowAngleScale;
  53936. /**
  53937. * Allows scaling the angle of the light for shadow generation only.
  53938. */
  53939. get shadowAngleScale(): number;
  53940. /**
  53941. * Allows scaling the angle of the light for shadow generation only.
  53942. */
  53943. set shadowAngleScale(value: number);
  53944. /**
  53945. * The light decay speed with the distance from the emission spot.
  53946. */
  53947. exponent: number;
  53948. private _projectionTextureMatrix;
  53949. /**
  53950. * Allows reading the projecton texture
  53951. */
  53952. get projectionTextureMatrix(): Matrix;
  53953. protected _projectionTextureLightNear: number;
  53954. /**
  53955. * Gets the near clip of the Spotlight for texture projection.
  53956. */
  53957. get projectionTextureLightNear(): number;
  53958. /**
  53959. * Sets the near clip of the Spotlight for texture projection.
  53960. */
  53961. set projectionTextureLightNear(value: number);
  53962. protected _projectionTextureLightFar: number;
  53963. /**
  53964. * Gets the far clip of the Spotlight for texture projection.
  53965. */
  53966. get projectionTextureLightFar(): number;
  53967. /**
  53968. * Sets the far clip of the Spotlight for texture projection.
  53969. */
  53970. set projectionTextureLightFar(value: number);
  53971. protected _projectionTextureUpDirection: Vector3;
  53972. /**
  53973. * Gets the Up vector of the Spotlight for texture projection.
  53974. */
  53975. get projectionTextureUpDirection(): Vector3;
  53976. /**
  53977. * Sets the Up vector of the Spotlight for texture projection.
  53978. */
  53979. set projectionTextureUpDirection(value: Vector3);
  53980. private _projectionTexture;
  53981. /**
  53982. * Gets the projection texture of the light.
  53983. */
  53984. get projectionTexture(): Nullable<BaseTexture>;
  53985. /**
  53986. * Sets the projection texture of the light.
  53987. */
  53988. set projectionTexture(value: Nullable<BaseTexture>);
  53989. private _projectionTextureViewLightDirty;
  53990. private _projectionTextureProjectionLightDirty;
  53991. private _projectionTextureDirty;
  53992. private _projectionTextureViewTargetVector;
  53993. private _projectionTextureViewLightMatrix;
  53994. private _projectionTextureProjectionLightMatrix;
  53995. private _projectionTextureScalingMatrix;
  53996. /**
  53997. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  53998. * It can cast shadows.
  53999. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54000. * @param name The light friendly name
  54001. * @param position The position of the spot light in the scene
  54002. * @param direction The direction of the light in the scene
  54003. * @param angle The cone angle of the light in Radians
  54004. * @param exponent The light decay speed with the distance from the emission spot
  54005. * @param scene The scene the lights belongs to
  54006. */
  54007. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  54008. /**
  54009. * Returns the string "SpotLight".
  54010. * @returns the class name
  54011. */
  54012. getClassName(): string;
  54013. /**
  54014. * Returns the integer 2.
  54015. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54016. */
  54017. getTypeID(): number;
  54018. /**
  54019. * Overrides the direction setter to recompute the projection texture view light Matrix.
  54020. */
  54021. protected _setDirection(value: Vector3): void;
  54022. /**
  54023. * Overrides the position setter to recompute the projection texture view light Matrix.
  54024. */
  54025. protected _setPosition(value: Vector3): void;
  54026. /**
  54027. * 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.
  54028. * Returns the SpotLight.
  54029. */
  54030. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54031. protected _computeProjectionTextureViewLightMatrix(): void;
  54032. protected _computeProjectionTextureProjectionLightMatrix(): void;
  54033. /**
  54034. * Main function for light texture projection matrix computing.
  54035. */
  54036. protected _computeProjectionTextureMatrix(): void;
  54037. protected _buildUniformLayout(): void;
  54038. private _computeAngleValues;
  54039. /**
  54040. * Sets the passed Effect "effect" with the Light textures.
  54041. * @param effect The effect to update
  54042. * @param lightIndex The index of the light in the effect to update
  54043. * @returns The light
  54044. */
  54045. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  54046. /**
  54047. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  54048. * @param effect The effect to update
  54049. * @param lightIndex The index of the light in the effect to update
  54050. * @returns The spot light
  54051. */
  54052. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  54053. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54054. /**
  54055. * Disposes the light and the associated resources.
  54056. */
  54057. dispose(): void;
  54058. /**
  54059. * Prepares the list of defines specific to the light type.
  54060. * @param defines the list of defines
  54061. * @param lightIndex defines the index of the light for the effect
  54062. */
  54063. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54064. }
  54065. }
  54066. declare module BABYLON {
  54067. /**
  54068. * Gizmo that enables viewing a light
  54069. */
  54070. export class LightGizmo extends Gizmo {
  54071. private _lightMesh;
  54072. private _material;
  54073. private _cachedPosition;
  54074. private _cachedForward;
  54075. private _attachedMeshParent;
  54076. /**
  54077. * Creates a LightGizmo
  54078. * @param gizmoLayer The utility layer the gizmo will be added to
  54079. */
  54080. constructor(gizmoLayer?: UtilityLayerRenderer);
  54081. private _light;
  54082. /**
  54083. * The light that the gizmo is attached to
  54084. */
  54085. set light(light: Nullable<Light>);
  54086. get light(): Nullable<Light>;
  54087. /**
  54088. * Gets the material used to render the light gizmo
  54089. */
  54090. get material(): StandardMaterial;
  54091. /**
  54092. * @hidden
  54093. * Updates the gizmo to match the attached mesh's position/rotation
  54094. */
  54095. protected _update(): void;
  54096. private static _Scale;
  54097. /**
  54098. * Creates the lines for a light mesh
  54099. */
  54100. private static _CreateLightLines;
  54101. /**
  54102. * Disposes of the light gizmo
  54103. */
  54104. dispose(): void;
  54105. private static _CreateHemisphericLightMesh;
  54106. private static _CreatePointLightMesh;
  54107. private static _CreateSpotLightMesh;
  54108. private static _CreateDirectionalLightMesh;
  54109. }
  54110. }
  54111. declare module BABYLON {
  54112. /**
  54113. * Gizmo that enables viewing a camera
  54114. */
  54115. export class CameraGizmo extends Gizmo {
  54116. private _cameraMesh;
  54117. private _cameraLinesMesh;
  54118. private _material;
  54119. /**
  54120. * Creates a CameraGizmo
  54121. * @param gizmoLayer The utility layer the gizmo will be added to
  54122. */
  54123. constructor(gizmoLayer?: UtilityLayerRenderer);
  54124. private _camera;
  54125. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  54126. get displayFrustum(): boolean;
  54127. set displayFrustum(value: boolean);
  54128. /**
  54129. * The camera that the gizmo is attached to
  54130. */
  54131. set camera(camera: Nullable<Camera>);
  54132. get camera(): Nullable<Camera>;
  54133. /**
  54134. * Gets the material used to render the camera gizmo
  54135. */
  54136. get material(): StandardMaterial;
  54137. /**
  54138. * @hidden
  54139. * Updates the gizmo to match the attached mesh's position/rotation
  54140. */
  54141. protected _update(): void;
  54142. private static _Scale;
  54143. private _invProjection;
  54144. /**
  54145. * Disposes of the camera gizmo
  54146. */
  54147. dispose(): void;
  54148. private static _CreateCameraMesh;
  54149. private static _CreateCameraFrustum;
  54150. }
  54151. }
  54152. declare module BABYLON {
  54153. /** @hidden */
  54154. export var backgroundFragmentDeclaration: {
  54155. name: string;
  54156. shader: string;
  54157. };
  54158. }
  54159. declare module BABYLON {
  54160. /** @hidden */
  54161. export var backgroundUboDeclaration: {
  54162. name: string;
  54163. shader: string;
  54164. };
  54165. }
  54166. declare module BABYLON {
  54167. /** @hidden */
  54168. export var backgroundPixelShader: {
  54169. name: string;
  54170. shader: string;
  54171. };
  54172. }
  54173. declare module BABYLON {
  54174. /** @hidden */
  54175. export var backgroundVertexDeclaration: {
  54176. name: string;
  54177. shader: string;
  54178. };
  54179. }
  54180. declare module BABYLON {
  54181. /** @hidden */
  54182. export var backgroundVertexShader: {
  54183. name: string;
  54184. shader: string;
  54185. };
  54186. }
  54187. declare module BABYLON {
  54188. /**
  54189. * Background material used to create an efficient environement around your scene.
  54190. */
  54191. export class BackgroundMaterial extends PushMaterial {
  54192. /**
  54193. * Standard reflectance value at parallel view angle.
  54194. */
  54195. static StandardReflectance0: number;
  54196. /**
  54197. * Standard reflectance value at grazing angle.
  54198. */
  54199. static StandardReflectance90: number;
  54200. protected _primaryColor: Color3;
  54201. /**
  54202. * Key light Color (multiply against the environement texture)
  54203. */
  54204. primaryColor: Color3;
  54205. protected __perceptualColor: Nullable<Color3>;
  54206. /**
  54207. * Experimental Internal Use Only.
  54208. *
  54209. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  54210. * This acts as a helper to set the primary color to a more "human friendly" value.
  54211. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  54212. * output color as close as possible from the chosen value.
  54213. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  54214. * part of lighting setup.)
  54215. */
  54216. get _perceptualColor(): Nullable<Color3>;
  54217. set _perceptualColor(value: Nullable<Color3>);
  54218. protected _primaryColorShadowLevel: float;
  54219. /**
  54220. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  54221. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  54222. */
  54223. get primaryColorShadowLevel(): float;
  54224. set primaryColorShadowLevel(value: float);
  54225. protected _primaryColorHighlightLevel: float;
  54226. /**
  54227. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  54228. * The primary color is used at the level chosen to define what the white area would look.
  54229. */
  54230. get primaryColorHighlightLevel(): float;
  54231. set primaryColorHighlightLevel(value: float);
  54232. protected _reflectionTexture: Nullable<BaseTexture>;
  54233. /**
  54234. * Reflection Texture used in the material.
  54235. * Should be author in a specific way for the best result (refer to the documentation).
  54236. */
  54237. reflectionTexture: Nullable<BaseTexture>;
  54238. protected _reflectionBlur: float;
  54239. /**
  54240. * Reflection Texture level of blur.
  54241. *
  54242. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  54243. * texture twice.
  54244. */
  54245. reflectionBlur: float;
  54246. protected _diffuseTexture: Nullable<BaseTexture>;
  54247. /**
  54248. * Diffuse Texture used in the material.
  54249. * Should be author in a specific way for the best result (refer to the documentation).
  54250. */
  54251. diffuseTexture: Nullable<BaseTexture>;
  54252. protected _shadowLights: Nullable<IShadowLight[]>;
  54253. /**
  54254. * Specify the list of lights casting shadow on the material.
  54255. * All scene shadow lights will be included if null.
  54256. */
  54257. shadowLights: Nullable<IShadowLight[]>;
  54258. protected _shadowLevel: float;
  54259. /**
  54260. * Helps adjusting the shadow to a softer level if required.
  54261. * 0 means black shadows and 1 means no shadows.
  54262. */
  54263. shadowLevel: float;
  54264. protected _sceneCenter: Vector3;
  54265. /**
  54266. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  54267. * It is usually zero but might be interesting to modify according to your setup.
  54268. */
  54269. sceneCenter: Vector3;
  54270. protected _opacityFresnel: boolean;
  54271. /**
  54272. * This helps specifying that the material is falling off to the sky box at grazing angle.
  54273. * This helps ensuring a nice transition when the camera goes under the ground.
  54274. */
  54275. opacityFresnel: boolean;
  54276. protected _reflectionFresnel: boolean;
  54277. /**
  54278. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  54279. * This helps adding a mirror texture on the ground.
  54280. */
  54281. reflectionFresnel: boolean;
  54282. protected _reflectionFalloffDistance: number;
  54283. /**
  54284. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  54285. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  54286. */
  54287. reflectionFalloffDistance: number;
  54288. protected _reflectionAmount: number;
  54289. /**
  54290. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  54291. */
  54292. reflectionAmount: number;
  54293. protected _reflectionReflectance0: number;
  54294. /**
  54295. * This specifies the weight of the reflection at grazing angle.
  54296. */
  54297. reflectionReflectance0: number;
  54298. protected _reflectionReflectance90: number;
  54299. /**
  54300. * This specifies the weight of the reflection at a perpendicular point of view.
  54301. */
  54302. reflectionReflectance90: number;
  54303. /**
  54304. * Sets the reflection reflectance fresnel values according to the default standard
  54305. * empirically know to work well :-)
  54306. */
  54307. set reflectionStandardFresnelWeight(value: number);
  54308. protected _useRGBColor: boolean;
  54309. /**
  54310. * Helps to directly use the maps channels instead of their level.
  54311. */
  54312. useRGBColor: boolean;
  54313. protected _enableNoise: boolean;
  54314. /**
  54315. * This helps reducing the banding effect that could occur on the background.
  54316. */
  54317. enableNoise: boolean;
  54318. /**
  54319. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54320. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  54321. * Recommended to be keep at 1.0 except for special cases.
  54322. */
  54323. get fovMultiplier(): number;
  54324. set fovMultiplier(value: number);
  54325. private _fovMultiplier;
  54326. /**
  54327. * Enable the FOV adjustment feature controlled by fovMultiplier.
  54328. */
  54329. useEquirectangularFOV: boolean;
  54330. private _maxSimultaneousLights;
  54331. /**
  54332. * Number of Simultaneous lights allowed on the material.
  54333. */
  54334. maxSimultaneousLights: int;
  54335. private _shadowOnly;
  54336. /**
  54337. * Make the material only render shadows
  54338. */
  54339. shadowOnly: boolean;
  54340. /**
  54341. * Default configuration related to image processing available in the Background Material.
  54342. */
  54343. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54344. /**
  54345. * Keep track of the image processing observer to allow dispose and replace.
  54346. */
  54347. private _imageProcessingObserver;
  54348. /**
  54349. * Attaches a new image processing configuration to the PBR Material.
  54350. * @param configuration (if null the scene configuration will be use)
  54351. */
  54352. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54353. /**
  54354. * Gets the image processing configuration used either in this material.
  54355. */
  54356. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  54357. /**
  54358. * Sets the Default image processing configuration used either in the this material.
  54359. *
  54360. * If sets to null, the scene one is in use.
  54361. */
  54362. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  54363. /**
  54364. * Gets wether the color curves effect is enabled.
  54365. */
  54366. get cameraColorCurvesEnabled(): boolean;
  54367. /**
  54368. * Sets wether the color curves effect is enabled.
  54369. */
  54370. set cameraColorCurvesEnabled(value: boolean);
  54371. /**
  54372. * Gets wether the color grading effect is enabled.
  54373. */
  54374. get cameraColorGradingEnabled(): boolean;
  54375. /**
  54376. * Gets wether the color grading effect is enabled.
  54377. */
  54378. set cameraColorGradingEnabled(value: boolean);
  54379. /**
  54380. * Gets wether tonemapping is enabled or not.
  54381. */
  54382. get cameraToneMappingEnabled(): boolean;
  54383. /**
  54384. * Sets wether tonemapping is enabled or not
  54385. */
  54386. set cameraToneMappingEnabled(value: boolean);
  54387. /**
  54388. * The camera exposure used on this material.
  54389. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54390. * This corresponds to a photographic exposure.
  54391. */
  54392. get cameraExposure(): float;
  54393. /**
  54394. * The camera exposure used on this material.
  54395. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54396. * This corresponds to a photographic exposure.
  54397. */
  54398. set cameraExposure(value: float);
  54399. /**
  54400. * Gets The camera contrast used on this material.
  54401. */
  54402. get cameraContrast(): float;
  54403. /**
  54404. * Sets The camera contrast used on this material.
  54405. */
  54406. set cameraContrast(value: float);
  54407. /**
  54408. * Gets the Color Grading 2D Lookup Texture.
  54409. */
  54410. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54411. /**
  54412. * Sets the Color Grading 2D Lookup Texture.
  54413. */
  54414. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54415. /**
  54416. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54417. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54418. * 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;
  54419. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54420. */
  54421. get cameraColorCurves(): Nullable<ColorCurves>;
  54422. /**
  54423. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54424. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54425. * 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;
  54426. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54427. */
  54428. set cameraColorCurves(value: Nullable<ColorCurves>);
  54429. /**
  54430. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  54431. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  54432. */
  54433. switchToBGR: boolean;
  54434. private _renderTargets;
  54435. private _reflectionControls;
  54436. private _white;
  54437. private _primaryShadowColor;
  54438. private _primaryHighlightColor;
  54439. /**
  54440. * Instantiates a Background Material in the given scene
  54441. * @param name The friendly name of the material
  54442. * @param scene The scene to add the material to
  54443. */
  54444. constructor(name: string, scene: Scene);
  54445. /**
  54446. * Gets a boolean indicating that current material needs to register RTT
  54447. */
  54448. get hasRenderTargetTextures(): boolean;
  54449. /**
  54450. * The entire material has been created in order to prevent overdraw.
  54451. * @returns false
  54452. */
  54453. needAlphaTesting(): boolean;
  54454. /**
  54455. * The entire material has been created in order to prevent overdraw.
  54456. * @returns true if blending is enable
  54457. */
  54458. needAlphaBlending(): boolean;
  54459. /**
  54460. * Checks wether the material is ready to be rendered for a given mesh.
  54461. * @param mesh The mesh to render
  54462. * @param subMesh The submesh to check against
  54463. * @param useInstances Specify wether or not the material is used with instances
  54464. * @returns true if all the dependencies are ready (Textures, Effects...)
  54465. */
  54466. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54467. /**
  54468. * Compute the primary color according to the chosen perceptual color.
  54469. */
  54470. private _computePrimaryColorFromPerceptualColor;
  54471. /**
  54472. * Compute the highlights and shadow colors according to their chosen levels.
  54473. */
  54474. private _computePrimaryColors;
  54475. /**
  54476. * Build the uniform buffer used in the material.
  54477. */
  54478. buildUniformLayout(): void;
  54479. /**
  54480. * Unbind the material.
  54481. */
  54482. unbind(): void;
  54483. /**
  54484. * Bind only the world matrix to the material.
  54485. * @param world The world matrix to bind.
  54486. */
  54487. bindOnlyWorldMatrix(world: Matrix): void;
  54488. /**
  54489. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  54490. * @param world The world matrix to bind.
  54491. * @param subMesh The submesh to bind for.
  54492. */
  54493. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54494. /**
  54495. * Checks to see if a texture is used in the material.
  54496. * @param texture - Base texture to use.
  54497. * @returns - Boolean specifying if a texture is used in the material.
  54498. */
  54499. hasTexture(texture: BaseTexture): boolean;
  54500. /**
  54501. * Dispose the material.
  54502. * @param forceDisposeEffect Force disposal of the associated effect.
  54503. * @param forceDisposeTextures Force disposal of the associated textures.
  54504. */
  54505. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54506. /**
  54507. * Clones the material.
  54508. * @param name The cloned name.
  54509. * @returns The cloned material.
  54510. */
  54511. clone(name: string): BackgroundMaterial;
  54512. /**
  54513. * Serializes the current material to its JSON representation.
  54514. * @returns The JSON representation.
  54515. */
  54516. serialize(): any;
  54517. /**
  54518. * Gets the class name of the material
  54519. * @returns "BackgroundMaterial"
  54520. */
  54521. getClassName(): string;
  54522. /**
  54523. * Parse a JSON input to create back a background material.
  54524. * @param source The JSON data to parse
  54525. * @param scene The scene to create the parsed material in
  54526. * @param rootUrl The root url of the assets the material depends upon
  54527. * @returns the instantiated BackgroundMaterial.
  54528. */
  54529. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  54530. }
  54531. }
  54532. declare module BABYLON {
  54533. /**
  54534. * Represents the different options available during the creation of
  54535. * a Environment helper.
  54536. *
  54537. * This can control the default ground, skybox and image processing setup of your scene.
  54538. */
  54539. export interface IEnvironmentHelperOptions {
  54540. /**
  54541. * Specifies whether or not to create a ground.
  54542. * True by default.
  54543. */
  54544. createGround: boolean;
  54545. /**
  54546. * Specifies the ground size.
  54547. * 15 by default.
  54548. */
  54549. groundSize: number;
  54550. /**
  54551. * The texture used on the ground for the main color.
  54552. * Comes from the BabylonJS CDN by default.
  54553. *
  54554. * Remarks: Can be either a texture or a url.
  54555. */
  54556. groundTexture: string | BaseTexture;
  54557. /**
  54558. * The color mixed in the ground texture by default.
  54559. * BabylonJS clearColor by default.
  54560. */
  54561. groundColor: Color3;
  54562. /**
  54563. * Specifies the ground opacity.
  54564. * 1 by default.
  54565. */
  54566. groundOpacity: number;
  54567. /**
  54568. * Enables the ground to receive shadows.
  54569. * True by default.
  54570. */
  54571. enableGroundShadow: boolean;
  54572. /**
  54573. * Helps preventing the shadow to be fully black on the ground.
  54574. * 0.5 by default.
  54575. */
  54576. groundShadowLevel: number;
  54577. /**
  54578. * Creates a mirror texture attach to the ground.
  54579. * false by default.
  54580. */
  54581. enableGroundMirror: boolean;
  54582. /**
  54583. * Specifies the ground mirror size ratio.
  54584. * 0.3 by default as the default kernel is 64.
  54585. */
  54586. groundMirrorSizeRatio: number;
  54587. /**
  54588. * Specifies the ground mirror blur kernel size.
  54589. * 64 by default.
  54590. */
  54591. groundMirrorBlurKernel: number;
  54592. /**
  54593. * Specifies the ground mirror visibility amount.
  54594. * 1 by default
  54595. */
  54596. groundMirrorAmount: number;
  54597. /**
  54598. * Specifies the ground mirror reflectance weight.
  54599. * This uses the standard weight of the background material to setup the fresnel effect
  54600. * of the mirror.
  54601. * 1 by default.
  54602. */
  54603. groundMirrorFresnelWeight: number;
  54604. /**
  54605. * Specifies the ground mirror Falloff distance.
  54606. * This can helps reducing the size of the reflection.
  54607. * 0 by Default.
  54608. */
  54609. groundMirrorFallOffDistance: number;
  54610. /**
  54611. * Specifies the ground mirror texture type.
  54612. * Unsigned Int by Default.
  54613. */
  54614. groundMirrorTextureType: number;
  54615. /**
  54616. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  54617. * the shown objects.
  54618. */
  54619. groundYBias: number;
  54620. /**
  54621. * Specifies whether or not to create a skybox.
  54622. * True by default.
  54623. */
  54624. createSkybox: boolean;
  54625. /**
  54626. * Specifies the skybox size.
  54627. * 20 by default.
  54628. */
  54629. skyboxSize: number;
  54630. /**
  54631. * The texture used on the skybox for the main color.
  54632. * Comes from the BabylonJS CDN by default.
  54633. *
  54634. * Remarks: Can be either a texture or a url.
  54635. */
  54636. skyboxTexture: string | BaseTexture;
  54637. /**
  54638. * The color mixed in the skybox texture by default.
  54639. * BabylonJS clearColor by default.
  54640. */
  54641. skyboxColor: Color3;
  54642. /**
  54643. * The background rotation around the Y axis of the scene.
  54644. * This helps aligning the key lights of your scene with the background.
  54645. * 0 by default.
  54646. */
  54647. backgroundYRotation: number;
  54648. /**
  54649. * Compute automatically the size of the elements to best fit with the scene.
  54650. */
  54651. sizeAuto: boolean;
  54652. /**
  54653. * Default position of the rootMesh if autoSize is not true.
  54654. */
  54655. rootPosition: Vector3;
  54656. /**
  54657. * Sets up the image processing in the scene.
  54658. * true by default.
  54659. */
  54660. setupImageProcessing: boolean;
  54661. /**
  54662. * The texture used as your environment texture in the scene.
  54663. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  54664. *
  54665. * Remarks: Can be either a texture or a url.
  54666. */
  54667. environmentTexture: string | BaseTexture;
  54668. /**
  54669. * The value of the exposure to apply to the scene.
  54670. * 0.6 by default if setupImageProcessing is true.
  54671. */
  54672. cameraExposure: number;
  54673. /**
  54674. * The value of the contrast to apply to the scene.
  54675. * 1.6 by default if setupImageProcessing is true.
  54676. */
  54677. cameraContrast: number;
  54678. /**
  54679. * Specifies whether or not tonemapping should be enabled in the scene.
  54680. * true by default if setupImageProcessing is true.
  54681. */
  54682. toneMappingEnabled: boolean;
  54683. }
  54684. /**
  54685. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  54686. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  54687. * It also helps with the default setup of your imageProcessing configuration.
  54688. */
  54689. export class EnvironmentHelper {
  54690. /**
  54691. * Default ground texture URL.
  54692. */
  54693. private static _groundTextureCDNUrl;
  54694. /**
  54695. * Default skybox texture URL.
  54696. */
  54697. private static _skyboxTextureCDNUrl;
  54698. /**
  54699. * Default environment texture URL.
  54700. */
  54701. private static _environmentTextureCDNUrl;
  54702. /**
  54703. * Creates the default options for the helper.
  54704. */
  54705. private static _getDefaultOptions;
  54706. private _rootMesh;
  54707. /**
  54708. * Gets the root mesh created by the helper.
  54709. */
  54710. get rootMesh(): Mesh;
  54711. private _skybox;
  54712. /**
  54713. * Gets the skybox created by the helper.
  54714. */
  54715. get skybox(): Nullable<Mesh>;
  54716. private _skyboxTexture;
  54717. /**
  54718. * Gets the skybox texture created by the helper.
  54719. */
  54720. get skyboxTexture(): Nullable<BaseTexture>;
  54721. private _skyboxMaterial;
  54722. /**
  54723. * Gets the skybox material created by the helper.
  54724. */
  54725. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  54726. private _ground;
  54727. /**
  54728. * Gets the ground mesh created by the helper.
  54729. */
  54730. get ground(): Nullable<Mesh>;
  54731. private _groundTexture;
  54732. /**
  54733. * Gets the ground texture created by the helper.
  54734. */
  54735. get groundTexture(): Nullable<BaseTexture>;
  54736. private _groundMirror;
  54737. /**
  54738. * Gets the ground mirror created by the helper.
  54739. */
  54740. get groundMirror(): Nullable<MirrorTexture>;
  54741. /**
  54742. * Gets the ground mirror render list to helps pushing the meshes
  54743. * you wish in the ground reflection.
  54744. */
  54745. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  54746. private _groundMaterial;
  54747. /**
  54748. * Gets the ground material created by the helper.
  54749. */
  54750. get groundMaterial(): Nullable<BackgroundMaterial>;
  54751. /**
  54752. * Stores the creation options.
  54753. */
  54754. private readonly _scene;
  54755. private _options;
  54756. /**
  54757. * This observable will be notified with any error during the creation of the environment,
  54758. * mainly texture creation errors.
  54759. */
  54760. onErrorObservable: Observable<{
  54761. message?: string;
  54762. exception?: any;
  54763. }>;
  54764. /**
  54765. * constructor
  54766. * @param options Defines the options we want to customize the helper
  54767. * @param scene The scene to add the material to
  54768. */
  54769. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  54770. /**
  54771. * Updates the background according to the new options
  54772. * @param options
  54773. */
  54774. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  54775. /**
  54776. * Sets the primary color of all the available elements.
  54777. * @param color the main color to affect to the ground and the background
  54778. */
  54779. setMainColor(color: Color3): void;
  54780. /**
  54781. * Setup the image processing according to the specified options.
  54782. */
  54783. private _setupImageProcessing;
  54784. /**
  54785. * Setup the environment texture according to the specified options.
  54786. */
  54787. private _setupEnvironmentTexture;
  54788. /**
  54789. * Setup the background according to the specified options.
  54790. */
  54791. private _setupBackground;
  54792. /**
  54793. * Get the scene sizes according to the setup.
  54794. */
  54795. private _getSceneSize;
  54796. /**
  54797. * Setup the ground according to the specified options.
  54798. */
  54799. private _setupGround;
  54800. /**
  54801. * Setup the ground material according to the specified options.
  54802. */
  54803. private _setupGroundMaterial;
  54804. /**
  54805. * Setup the ground diffuse texture according to the specified options.
  54806. */
  54807. private _setupGroundDiffuseTexture;
  54808. /**
  54809. * Setup the ground mirror texture according to the specified options.
  54810. */
  54811. private _setupGroundMirrorTexture;
  54812. /**
  54813. * Setup the ground to receive the mirror texture.
  54814. */
  54815. private _setupMirrorInGroundMaterial;
  54816. /**
  54817. * Setup the skybox according to the specified options.
  54818. */
  54819. private _setupSkybox;
  54820. /**
  54821. * Setup the skybox material according to the specified options.
  54822. */
  54823. private _setupSkyboxMaterial;
  54824. /**
  54825. * Setup the skybox reflection texture according to the specified options.
  54826. */
  54827. private _setupSkyboxReflectionTexture;
  54828. private _errorHandler;
  54829. /**
  54830. * Dispose all the elements created by the Helper.
  54831. */
  54832. dispose(): void;
  54833. }
  54834. }
  54835. declare module BABYLON {
  54836. /**
  54837. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  54838. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  54839. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  54840. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54841. */
  54842. export class PhotoDome extends TransformNode {
  54843. /**
  54844. * Define the image as a Monoscopic panoramic 360 image.
  54845. */
  54846. static readonly MODE_MONOSCOPIC: number;
  54847. /**
  54848. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  54849. */
  54850. static readonly MODE_TOPBOTTOM: number;
  54851. /**
  54852. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  54853. */
  54854. static readonly MODE_SIDEBYSIDE: number;
  54855. private _useDirectMapping;
  54856. /**
  54857. * The texture being displayed on the sphere
  54858. */
  54859. protected _photoTexture: Texture;
  54860. /**
  54861. * Gets or sets the texture being displayed on the sphere
  54862. */
  54863. get photoTexture(): Texture;
  54864. set photoTexture(value: Texture);
  54865. /**
  54866. * Observable raised when an error occured while loading the 360 image
  54867. */
  54868. onLoadErrorObservable: Observable<string>;
  54869. /**
  54870. * The skybox material
  54871. */
  54872. protected _material: BackgroundMaterial;
  54873. /**
  54874. * The surface used for the skybox
  54875. */
  54876. protected _mesh: Mesh;
  54877. /**
  54878. * Gets the mesh used for the skybox.
  54879. */
  54880. get mesh(): Mesh;
  54881. /**
  54882. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54883. * Also see the options.resolution property.
  54884. */
  54885. get fovMultiplier(): number;
  54886. set fovMultiplier(value: number);
  54887. private _imageMode;
  54888. /**
  54889. * Gets or set the current video mode for the video. It can be:
  54890. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  54891. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  54892. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  54893. */
  54894. get imageMode(): number;
  54895. set imageMode(value: number);
  54896. /**
  54897. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  54898. * @param name Element's name, child elements will append suffixes for their own names.
  54899. * @param urlsOfPhoto defines the url of the photo to display
  54900. * @param options defines an object containing optional or exposed sub element properties
  54901. * @param onError defines a callback called when an error occured while loading the texture
  54902. */
  54903. constructor(name: string, urlOfPhoto: string, options: {
  54904. resolution?: number;
  54905. size?: number;
  54906. useDirectMapping?: boolean;
  54907. faceForward?: boolean;
  54908. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  54909. private _onBeforeCameraRenderObserver;
  54910. private _changeImageMode;
  54911. /**
  54912. * Releases resources associated with this node.
  54913. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54914. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54915. */
  54916. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54917. }
  54918. }
  54919. declare module BABYLON {
  54920. /**
  54921. * Class used to host RGBD texture specific utilities
  54922. */
  54923. export class RGBDTextureTools {
  54924. /**
  54925. * Expand the RGBD Texture from RGBD to Half Float if possible.
  54926. * @param texture the texture to expand.
  54927. */
  54928. static ExpandRGBDTexture(texture: Texture): void;
  54929. }
  54930. }
  54931. declare module BABYLON {
  54932. /**
  54933. * Class used to host texture specific utilities
  54934. */
  54935. export class BRDFTextureTools {
  54936. /**
  54937. * Prevents texture cache collision
  54938. */
  54939. private static _instanceNumber;
  54940. /**
  54941. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  54942. * @param scene defines the hosting scene
  54943. * @returns the environment BRDF texture
  54944. */
  54945. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  54946. private static _environmentBRDFBase64Texture;
  54947. }
  54948. }
  54949. declare module BABYLON {
  54950. /**
  54951. * @hidden
  54952. */
  54953. export interface IMaterialClearCoatDefines {
  54954. CLEARCOAT: boolean;
  54955. CLEARCOAT_DEFAULTIOR: boolean;
  54956. CLEARCOAT_TEXTURE: boolean;
  54957. CLEARCOAT_TEXTUREDIRECTUV: number;
  54958. CLEARCOAT_BUMP: boolean;
  54959. CLEARCOAT_BUMPDIRECTUV: number;
  54960. CLEARCOAT_TINT: boolean;
  54961. CLEARCOAT_TINT_TEXTURE: boolean;
  54962. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  54963. /** @hidden */
  54964. _areTexturesDirty: boolean;
  54965. }
  54966. /**
  54967. * Define the code related to the clear coat parameters of the pbr material.
  54968. */
  54969. export class PBRClearCoatConfiguration {
  54970. /**
  54971. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  54972. * The default fits with a polyurethane material.
  54973. */
  54974. private static readonly _DefaultIndexOfRefraction;
  54975. private _isEnabled;
  54976. /**
  54977. * Defines if the clear coat is enabled in the material.
  54978. */
  54979. isEnabled: boolean;
  54980. /**
  54981. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  54982. */
  54983. intensity: number;
  54984. /**
  54985. * Defines the clear coat layer roughness.
  54986. */
  54987. roughness: number;
  54988. private _indexOfRefraction;
  54989. /**
  54990. * Defines the index of refraction of the clear coat.
  54991. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  54992. * The default fits with a polyurethane material.
  54993. * Changing the default value is more performance intensive.
  54994. */
  54995. indexOfRefraction: number;
  54996. private _texture;
  54997. /**
  54998. * Stores the clear coat values in a texture.
  54999. */
  55000. texture: Nullable<BaseTexture>;
  55001. private _bumpTexture;
  55002. /**
  55003. * Define the clear coat specific bump texture.
  55004. */
  55005. bumpTexture: Nullable<BaseTexture>;
  55006. private _isTintEnabled;
  55007. /**
  55008. * Defines if the clear coat tint is enabled in the material.
  55009. */
  55010. isTintEnabled: boolean;
  55011. /**
  55012. * Defines the clear coat tint of the material.
  55013. * This is only use if tint is enabled
  55014. */
  55015. tintColor: Color3;
  55016. /**
  55017. * Defines the distance at which the tint color should be found in the
  55018. * clear coat media.
  55019. * This is only use if tint is enabled
  55020. */
  55021. tintColorAtDistance: number;
  55022. /**
  55023. * Defines the clear coat layer thickness.
  55024. * This is only use if tint is enabled
  55025. */
  55026. tintThickness: number;
  55027. private _tintTexture;
  55028. /**
  55029. * Stores the clear tint values in a texture.
  55030. * rgb is tint
  55031. * a is a thickness factor
  55032. */
  55033. tintTexture: Nullable<BaseTexture>;
  55034. /** @hidden */
  55035. private _internalMarkAllSubMeshesAsTexturesDirty;
  55036. /** @hidden */
  55037. _markAllSubMeshesAsTexturesDirty(): void;
  55038. /**
  55039. * Instantiate a new istance of clear coat configuration.
  55040. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55041. */
  55042. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55043. /**
  55044. * Gets wehter the submesh is ready to be used or not.
  55045. * @param defines the list of "defines" to update.
  55046. * @param scene defines the scene the material belongs to.
  55047. * @param engine defines the engine the material belongs to.
  55048. * @param disableBumpMap defines wether the material disables bump or not.
  55049. * @returns - boolean indicating that the submesh is ready or not.
  55050. */
  55051. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  55052. /**
  55053. * Checks to see if a texture is used in the material.
  55054. * @param defines the list of "defines" to update.
  55055. * @param scene defines the scene to the material belongs to.
  55056. */
  55057. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  55058. /**
  55059. * Binds the material data.
  55060. * @param uniformBuffer defines the Uniform buffer to fill in.
  55061. * @param scene defines the scene the material belongs to.
  55062. * @param engine defines the engine the material belongs to.
  55063. * @param disableBumpMap defines wether the material disables bump or not.
  55064. * @param isFrozen defines wether the material is frozen or not.
  55065. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55066. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55067. */
  55068. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  55069. /**
  55070. * Checks to see if a texture is used in the material.
  55071. * @param texture - Base texture to use.
  55072. * @returns - Boolean specifying if a texture is used in the material.
  55073. */
  55074. hasTexture(texture: BaseTexture): boolean;
  55075. /**
  55076. * Returns an array of the actively used textures.
  55077. * @param activeTextures Array of BaseTextures
  55078. */
  55079. getActiveTextures(activeTextures: BaseTexture[]): void;
  55080. /**
  55081. * Returns the animatable textures.
  55082. * @param animatables Array of animatable textures.
  55083. */
  55084. getAnimatables(animatables: IAnimatable[]): void;
  55085. /**
  55086. * Disposes the resources of the material.
  55087. * @param forceDisposeTextures - Forces the disposal of all textures.
  55088. */
  55089. dispose(forceDisposeTextures?: boolean): void;
  55090. /**
  55091. * Get the current class name of the texture useful for serialization or dynamic coding.
  55092. * @returns "PBRClearCoatConfiguration"
  55093. */
  55094. getClassName(): string;
  55095. /**
  55096. * Add fallbacks to the effect fallbacks list.
  55097. * @param defines defines the Base texture to use.
  55098. * @param fallbacks defines the current fallback list.
  55099. * @param currentRank defines the current fallback rank.
  55100. * @returns the new fallback rank.
  55101. */
  55102. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55103. /**
  55104. * Add the required uniforms to the current list.
  55105. * @param uniforms defines the current uniform list.
  55106. */
  55107. static AddUniforms(uniforms: string[]): void;
  55108. /**
  55109. * Add the required samplers to the current list.
  55110. * @param samplers defines the current sampler list.
  55111. */
  55112. static AddSamplers(samplers: string[]): void;
  55113. /**
  55114. * Add the required uniforms to the current buffer.
  55115. * @param uniformBuffer defines the current uniform buffer.
  55116. */
  55117. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55118. /**
  55119. * Makes a duplicate of the current configuration into another one.
  55120. * @param clearCoatConfiguration define the config where to copy the info
  55121. */
  55122. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  55123. /**
  55124. * Serializes this clear coat configuration.
  55125. * @returns - An object with the serialized config.
  55126. */
  55127. serialize(): any;
  55128. /**
  55129. * Parses a anisotropy Configuration from a serialized object.
  55130. * @param source - Serialized object.
  55131. * @param scene Defines the scene we are parsing for
  55132. * @param rootUrl Defines the rootUrl to load from
  55133. */
  55134. parse(source: any, scene: Scene, rootUrl: string): void;
  55135. }
  55136. }
  55137. declare module BABYLON {
  55138. /**
  55139. * @hidden
  55140. */
  55141. export interface IMaterialAnisotropicDefines {
  55142. ANISOTROPIC: boolean;
  55143. ANISOTROPIC_TEXTURE: boolean;
  55144. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55145. MAINUV1: boolean;
  55146. _areTexturesDirty: boolean;
  55147. _needUVs: boolean;
  55148. }
  55149. /**
  55150. * Define the code related to the anisotropic parameters of the pbr material.
  55151. */
  55152. export class PBRAnisotropicConfiguration {
  55153. private _isEnabled;
  55154. /**
  55155. * Defines if the anisotropy is enabled in the material.
  55156. */
  55157. isEnabled: boolean;
  55158. /**
  55159. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  55160. */
  55161. intensity: number;
  55162. /**
  55163. * Defines if the effect is along the tangents, bitangents or in between.
  55164. * By default, the effect is "strectching" the highlights along the tangents.
  55165. */
  55166. direction: Vector2;
  55167. private _texture;
  55168. /**
  55169. * Stores the anisotropy values in a texture.
  55170. * rg is direction (like normal from -1 to 1)
  55171. * b is a intensity
  55172. */
  55173. texture: Nullable<BaseTexture>;
  55174. /** @hidden */
  55175. private _internalMarkAllSubMeshesAsTexturesDirty;
  55176. /** @hidden */
  55177. _markAllSubMeshesAsTexturesDirty(): void;
  55178. /**
  55179. * Instantiate a new istance of anisotropy configuration.
  55180. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55181. */
  55182. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55183. /**
  55184. * Specifies that the submesh is ready to be used.
  55185. * @param defines the list of "defines" to update.
  55186. * @param scene defines the scene the material belongs to.
  55187. * @returns - boolean indicating that the submesh is ready or not.
  55188. */
  55189. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  55190. /**
  55191. * Checks to see if a texture is used in the material.
  55192. * @param defines the list of "defines" to update.
  55193. * @param mesh the mesh we are preparing the defines for.
  55194. * @param scene defines the scene the material belongs to.
  55195. */
  55196. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  55197. /**
  55198. * Binds the material data.
  55199. * @param uniformBuffer defines the Uniform buffer to fill in.
  55200. * @param scene defines the scene the material belongs to.
  55201. * @param isFrozen defines wether the material is frozen or not.
  55202. */
  55203. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55204. /**
  55205. * Checks to see if a texture is used in the material.
  55206. * @param texture - Base texture to use.
  55207. * @returns - Boolean specifying if a texture is used in the material.
  55208. */
  55209. hasTexture(texture: BaseTexture): boolean;
  55210. /**
  55211. * Returns an array of the actively used textures.
  55212. * @param activeTextures Array of BaseTextures
  55213. */
  55214. getActiveTextures(activeTextures: BaseTexture[]): void;
  55215. /**
  55216. * Returns the animatable textures.
  55217. * @param animatables Array of animatable textures.
  55218. */
  55219. getAnimatables(animatables: IAnimatable[]): void;
  55220. /**
  55221. * Disposes the resources of the material.
  55222. * @param forceDisposeTextures - Forces the disposal of all textures.
  55223. */
  55224. dispose(forceDisposeTextures?: boolean): void;
  55225. /**
  55226. * Get the current class name of the texture useful for serialization or dynamic coding.
  55227. * @returns "PBRAnisotropicConfiguration"
  55228. */
  55229. getClassName(): string;
  55230. /**
  55231. * Add fallbacks to the effect fallbacks list.
  55232. * @param defines defines the Base texture to use.
  55233. * @param fallbacks defines the current fallback list.
  55234. * @param currentRank defines the current fallback rank.
  55235. * @returns the new fallback rank.
  55236. */
  55237. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55238. /**
  55239. * Add the required uniforms to the current list.
  55240. * @param uniforms defines the current uniform list.
  55241. */
  55242. static AddUniforms(uniforms: string[]): void;
  55243. /**
  55244. * Add the required uniforms to the current buffer.
  55245. * @param uniformBuffer defines the current uniform buffer.
  55246. */
  55247. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55248. /**
  55249. * Add the required samplers to the current list.
  55250. * @param samplers defines the current sampler list.
  55251. */
  55252. static AddSamplers(samplers: string[]): void;
  55253. /**
  55254. * Makes a duplicate of the current configuration into another one.
  55255. * @param anisotropicConfiguration define the config where to copy the info
  55256. */
  55257. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  55258. /**
  55259. * Serializes this anisotropy configuration.
  55260. * @returns - An object with the serialized config.
  55261. */
  55262. serialize(): any;
  55263. /**
  55264. * Parses a anisotropy Configuration from a serialized object.
  55265. * @param source - Serialized object.
  55266. * @param scene Defines the scene we are parsing for
  55267. * @param rootUrl Defines the rootUrl to load from
  55268. */
  55269. parse(source: any, scene: Scene, rootUrl: string): void;
  55270. }
  55271. }
  55272. declare module BABYLON {
  55273. /**
  55274. * @hidden
  55275. */
  55276. export interface IMaterialBRDFDefines {
  55277. BRDF_V_HEIGHT_CORRELATED: boolean;
  55278. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55279. SPHERICAL_HARMONICS: boolean;
  55280. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55281. /** @hidden */
  55282. _areMiscDirty: boolean;
  55283. }
  55284. /**
  55285. * Define the code related to the BRDF parameters of the pbr material.
  55286. */
  55287. export class PBRBRDFConfiguration {
  55288. /**
  55289. * Default value used for the energy conservation.
  55290. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55291. */
  55292. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  55293. /**
  55294. * Default value used for the Smith Visibility Height Correlated mode.
  55295. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55296. */
  55297. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  55298. /**
  55299. * Default value used for the IBL diffuse part.
  55300. * This can help switching back to the polynomials mode globally which is a tiny bit
  55301. * less GPU intensive at the drawback of a lower quality.
  55302. */
  55303. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  55304. /**
  55305. * Default value used for activating energy conservation for the specular workflow.
  55306. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55307. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55308. */
  55309. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  55310. private _useEnergyConservation;
  55311. /**
  55312. * Defines if the material uses energy conservation.
  55313. */
  55314. useEnergyConservation: boolean;
  55315. private _useSmithVisibilityHeightCorrelated;
  55316. /**
  55317. * LEGACY Mode set to false
  55318. * Defines if the material uses height smith correlated visibility term.
  55319. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  55320. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  55321. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  55322. * Not relying on height correlated will also disable energy conservation.
  55323. */
  55324. useSmithVisibilityHeightCorrelated: boolean;
  55325. private _useSphericalHarmonics;
  55326. /**
  55327. * LEGACY Mode set to false
  55328. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  55329. * diffuse part of the IBL.
  55330. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  55331. * to the ground truth.
  55332. */
  55333. useSphericalHarmonics: boolean;
  55334. private _useSpecularGlossinessInputEnergyConservation;
  55335. /**
  55336. * Defines if the material uses energy conservation, when the specular workflow is active.
  55337. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55338. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55339. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  55340. */
  55341. useSpecularGlossinessInputEnergyConservation: boolean;
  55342. /** @hidden */
  55343. private _internalMarkAllSubMeshesAsMiscDirty;
  55344. /** @hidden */
  55345. _markAllSubMeshesAsMiscDirty(): void;
  55346. /**
  55347. * Instantiate a new istance of clear coat configuration.
  55348. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  55349. */
  55350. constructor(markAllSubMeshesAsMiscDirty: () => void);
  55351. /**
  55352. * Checks to see if a texture is used in the material.
  55353. * @param defines the list of "defines" to update.
  55354. */
  55355. prepareDefines(defines: IMaterialBRDFDefines): void;
  55356. /**
  55357. * Get the current class name of the texture useful for serialization or dynamic coding.
  55358. * @returns "PBRClearCoatConfiguration"
  55359. */
  55360. getClassName(): string;
  55361. /**
  55362. * Makes a duplicate of the current configuration into another one.
  55363. * @param brdfConfiguration define the config where to copy the info
  55364. */
  55365. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  55366. /**
  55367. * Serializes this BRDF configuration.
  55368. * @returns - An object with the serialized config.
  55369. */
  55370. serialize(): any;
  55371. /**
  55372. * Parses a anisotropy Configuration from a serialized object.
  55373. * @param source - Serialized object.
  55374. * @param scene Defines the scene we are parsing for
  55375. * @param rootUrl Defines the rootUrl to load from
  55376. */
  55377. parse(source: any, scene: Scene, rootUrl: string): void;
  55378. }
  55379. }
  55380. declare module BABYLON {
  55381. /**
  55382. * @hidden
  55383. */
  55384. export interface IMaterialSheenDefines {
  55385. SHEEN: boolean;
  55386. SHEEN_TEXTURE: boolean;
  55387. SHEEN_TEXTUREDIRECTUV: number;
  55388. SHEEN_LINKWITHALBEDO: boolean;
  55389. SHEEN_ROUGHNESS: boolean;
  55390. SHEEN_ALBEDOSCALING: boolean;
  55391. /** @hidden */
  55392. _areTexturesDirty: boolean;
  55393. }
  55394. /**
  55395. * Define the code related to the Sheen parameters of the pbr material.
  55396. */
  55397. export class PBRSheenConfiguration {
  55398. private _isEnabled;
  55399. /**
  55400. * Defines if the material uses sheen.
  55401. */
  55402. isEnabled: boolean;
  55403. private _linkSheenWithAlbedo;
  55404. /**
  55405. * Defines if the sheen is linked to the sheen color.
  55406. */
  55407. linkSheenWithAlbedo: boolean;
  55408. /**
  55409. * Defines the sheen intensity.
  55410. */
  55411. intensity: number;
  55412. /**
  55413. * Defines the sheen color.
  55414. */
  55415. color: Color3;
  55416. private _texture;
  55417. /**
  55418. * Stores the sheen tint values in a texture.
  55419. * rgb is tint
  55420. * a is a intensity or roughness if roughness has been defined
  55421. */
  55422. texture: Nullable<BaseTexture>;
  55423. private _roughness;
  55424. /**
  55425. * Defines the sheen roughness.
  55426. * It is not taken into account if linkSheenWithAlbedo is true.
  55427. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  55428. */
  55429. roughness: Nullable<number>;
  55430. private _albedoScaling;
  55431. /**
  55432. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  55433. * It allows the strength of the sheen effect to not depend on the base color of the material,
  55434. * making it easier to setup and tweak the effect
  55435. */
  55436. albedoScaling: boolean;
  55437. /** @hidden */
  55438. private _internalMarkAllSubMeshesAsTexturesDirty;
  55439. /** @hidden */
  55440. _markAllSubMeshesAsTexturesDirty(): void;
  55441. /**
  55442. * Instantiate a new istance of clear coat configuration.
  55443. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55444. */
  55445. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55446. /**
  55447. * Specifies that the submesh is ready to be used.
  55448. * @param defines the list of "defines" to update.
  55449. * @param scene defines the scene the material belongs to.
  55450. * @returns - boolean indicating that the submesh is ready or not.
  55451. */
  55452. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  55453. /**
  55454. * Checks to see if a texture is used in the material.
  55455. * @param defines the list of "defines" to update.
  55456. * @param scene defines the scene the material belongs to.
  55457. */
  55458. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  55459. /**
  55460. * Binds the material data.
  55461. * @param uniformBuffer defines the Uniform buffer to fill in.
  55462. * @param scene defines the scene the material belongs to.
  55463. * @param isFrozen defines wether the material is frozen or not.
  55464. */
  55465. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55466. /**
  55467. * Checks to see if a texture is used in the material.
  55468. * @param texture - Base texture to use.
  55469. * @returns - Boolean specifying if a texture is used in the material.
  55470. */
  55471. hasTexture(texture: BaseTexture): boolean;
  55472. /**
  55473. * Returns an array of the actively used textures.
  55474. * @param activeTextures Array of BaseTextures
  55475. */
  55476. getActiveTextures(activeTextures: BaseTexture[]): void;
  55477. /**
  55478. * Returns the animatable textures.
  55479. * @param animatables Array of animatable textures.
  55480. */
  55481. getAnimatables(animatables: IAnimatable[]): void;
  55482. /**
  55483. * Disposes the resources of the material.
  55484. * @param forceDisposeTextures - Forces the disposal of all textures.
  55485. */
  55486. dispose(forceDisposeTextures?: boolean): void;
  55487. /**
  55488. * Get the current class name of the texture useful for serialization or dynamic coding.
  55489. * @returns "PBRSheenConfiguration"
  55490. */
  55491. getClassName(): string;
  55492. /**
  55493. * Add fallbacks to the effect fallbacks list.
  55494. * @param defines defines the Base texture to use.
  55495. * @param fallbacks defines the current fallback list.
  55496. * @param currentRank defines the current fallback rank.
  55497. * @returns the new fallback rank.
  55498. */
  55499. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55500. /**
  55501. * Add the required uniforms to the current list.
  55502. * @param uniforms defines the current uniform list.
  55503. */
  55504. static AddUniforms(uniforms: string[]): void;
  55505. /**
  55506. * Add the required uniforms to the current buffer.
  55507. * @param uniformBuffer defines the current uniform buffer.
  55508. */
  55509. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55510. /**
  55511. * Add the required samplers to the current list.
  55512. * @param samplers defines the current sampler list.
  55513. */
  55514. static AddSamplers(samplers: string[]): void;
  55515. /**
  55516. * Makes a duplicate of the current configuration into another one.
  55517. * @param sheenConfiguration define the config where to copy the info
  55518. */
  55519. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  55520. /**
  55521. * Serializes this BRDF configuration.
  55522. * @returns - An object with the serialized config.
  55523. */
  55524. serialize(): any;
  55525. /**
  55526. * Parses a anisotropy Configuration from a serialized object.
  55527. * @param source - Serialized object.
  55528. * @param scene Defines the scene we are parsing for
  55529. * @param rootUrl Defines the rootUrl to load from
  55530. */
  55531. parse(source: any, scene: Scene, rootUrl: string): void;
  55532. }
  55533. }
  55534. declare module BABYLON {
  55535. /**
  55536. * @hidden
  55537. */
  55538. export interface IMaterialSubSurfaceDefines {
  55539. SUBSURFACE: boolean;
  55540. SS_REFRACTION: boolean;
  55541. SS_TRANSLUCENCY: boolean;
  55542. SS_SCATTERING: boolean;
  55543. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55544. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55545. SS_REFRACTIONMAP_3D: boolean;
  55546. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55547. SS_LODINREFRACTIONALPHA: boolean;
  55548. SS_GAMMAREFRACTION: boolean;
  55549. SS_RGBDREFRACTION: boolean;
  55550. SS_LINEARSPECULARREFRACTION: boolean;
  55551. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55552. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55553. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55554. /** @hidden */
  55555. _areTexturesDirty: boolean;
  55556. }
  55557. /**
  55558. * Define the code related to the sub surface parameters of the pbr material.
  55559. */
  55560. export class PBRSubSurfaceConfiguration {
  55561. private _isRefractionEnabled;
  55562. /**
  55563. * Defines if the refraction is enabled in the material.
  55564. */
  55565. isRefractionEnabled: boolean;
  55566. private _isTranslucencyEnabled;
  55567. /**
  55568. * Defines if the translucency is enabled in the material.
  55569. */
  55570. isTranslucencyEnabled: boolean;
  55571. private _isScatteringEnabled;
  55572. /**
  55573. * Defines if the sub surface scattering is enabled in the material.
  55574. */
  55575. isScatteringEnabled: boolean;
  55576. private _scatteringDiffusionProfileIndex;
  55577. /**
  55578. * Diffusion profile for subsurface scattering.
  55579. * Useful for better scattering in the skins or foliages.
  55580. */
  55581. get scatteringDiffusionProfile(): Nullable<Color3>;
  55582. set scatteringDiffusionProfile(c: Nullable<Color3>);
  55583. /**
  55584. * Defines the refraction intensity of the material.
  55585. * The refraction when enabled replaces the Diffuse part of the material.
  55586. * The intensity helps transitionning between diffuse and refraction.
  55587. */
  55588. refractionIntensity: number;
  55589. /**
  55590. * Defines the translucency intensity of the material.
  55591. * When translucency has been enabled, this defines how much of the "translucency"
  55592. * is addded to the diffuse part of the material.
  55593. */
  55594. translucencyIntensity: number;
  55595. /**
  55596. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  55597. */
  55598. useAlbedoToTintRefraction: boolean;
  55599. private _thicknessTexture;
  55600. /**
  55601. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  55602. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  55603. * 0 would mean minimumThickness
  55604. * 1 would mean maximumThickness
  55605. * The other channels might be use as a mask to vary the different effects intensity.
  55606. */
  55607. thicknessTexture: Nullable<BaseTexture>;
  55608. private _refractionTexture;
  55609. /**
  55610. * Defines the texture to use for refraction.
  55611. */
  55612. refractionTexture: Nullable<BaseTexture>;
  55613. private _indexOfRefraction;
  55614. /**
  55615. * Index of refraction of the material base layer.
  55616. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55617. *
  55618. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55619. *
  55620. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55621. */
  55622. indexOfRefraction: number;
  55623. private _volumeIndexOfRefraction;
  55624. /**
  55625. * Index of refraction of the material's volume.
  55626. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55627. *
  55628. * This ONLY impacts refraction. If not provided or given a non-valid value,
  55629. * the volume will use the same IOR as the surface.
  55630. */
  55631. get volumeIndexOfRefraction(): number;
  55632. set volumeIndexOfRefraction(value: number);
  55633. private _invertRefractionY;
  55634. /**
  55635. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55636. */
  55637. invertRefractionY: boolean;
  55638. private _linkRefractionWithTransparency;
  55639. /**
  55640. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55641. * Materials half opaque for instance using refraction could benefit from this control.
  55642. */
  55643. linkRefractionWithTransparency: boolean;
  55644. /**
  55645. * Defines the minimum thickness stored in the thickness map.
  55646. * If no thickness map is defined, this value will be used to simulate thickness.
  55647. */
  55648. minimumThickness: number;
  55649. /**
  55650. * Defines the maximum thickness stored in the thickness map.
  55651. */
  55652. maximumThickness: number;
  55653. /**
  55654. * Defines the volume tint of the material.
  55655. * This is used for both translucency and scattering.
  55656. */
  55657. tintColor: Color3;
  55658. /**
  55659. * Defines the distance at which the tint color should be found in the media.
  55660. * This is used for refraction only.
  55661. */
  55662. tintColorAtDistance: number;
  55663. /**
  55664. * Defines how far each channel transmit through the media.
  55665. * It is defined as a color to simplify it selection.
  55666. */
  55667. diffusionDistance: Color3;
  55668. private _useMaskFromThicknessTexture;
  55669. /**
  55670. * Stores the intensity of the different subsurface effects in the thickness texture.
  55671. * * the green channel is the translucency intensity.
  55672. * * the blue channel is the scattering intensity.
  55673. * * the alpha channel is the refraction intensity.
  55674. */
  55675. useMaskFromThicknessTexture: boolean;
  55676. private _scene;
  55677. /** @hidden */
  55678. private _internalMarkAllSubMeshesAsTexturesDirty;
  55679. private _internalMarkScenePrePassDirty;
  55680. /** @hidden */
  55681. _markAllSubMeshesAsTexturesDirty(): void;
  55682. /** @hidden */
  55683. _markScenePrePassDirty(): void;
  55684. /**
  55685. * Instantiate a new istance of sub surface configuration.
  55686. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55687. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  55688. * @param scene The scene
  55689. */
  55690. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  55691. /**
  55692. * Gets wehter the submesh is ready to be used or not.
  55693. * @param defines the list of "defines" to update.
  55694. * @param scene defines the scene the material belongs to.
  55695. * @returns - boolean indicating that the submesh is ready or not.
  55696. */
  55697. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  55698. /**
  55699. * Checks to see if a texture is used in the material.
  55700. * @param defines the list of "defines" to update.
  55701. * @param scene defines the scene to the material belongs to.
  55702. */
  55703. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  55704. /**
  55705. * Binds the material data.
  55706. * @param uniformBuffer defines the Uniform buffer to fill in.
  55707. * @param scene defines the scene the material belongs to.
  55708. * @param engine defines the engine the material belongs to.
  55709. * @param isFrozen defines whether the material is frozen or not.
  55710. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  55711. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  55712. */
  55713. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  55714. /**
  55715. * Unbinds the material from the mesh.
  55716. * @param activeEffect defines the effect that should be unbound from.
  55717. * @returns true if unbound, otherwise false
  55718. */
  55719. unbind(activeEffect: Effect): boolean;
  55720. /**
  55721. * Returns the texture used for refraction or null if none is used.
  55722. * @param scene defines the scene the material belongs to.
  55723. * @returns - Refraction texture if present. If no refraction texture and refraction
  55724. * is linked with transparency, returns environment texture. Otherwise, returns null.
  55725. */
  55726. private _getRefractionTexture;
  55727. /**
  55728. * Returns true if alpha blending should be disabled.
  55729. */
  55730. get disableAlphaBlending(): boolean;
  55731. /**
  55732. * Fills the list of render target textures.
  55733. * @param renderTargets the list of render targets to update
  55734. */
  55735. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  55736. /**
  55737. * Checks to see if a texture is used in the material.
  55738. * @param texture - Base texture to use.
  55739. * @returns - Boolean specifying if a texture is used in the material.
  55740. */
  55741. hasTexture(texture: BaseTexture): boolean;
  55742. /**
  55743. * Gets a boolean indicating that current material needs to register RTT
  55744. * @returns true if this uses a render target otherwise false.
  55745. */
  55746. hasRenderTargetTextures(): boolean;
  55747. /**
  55748. * Returns an array of the actively used textures.
  55749. * @param activeTextures Array of BaseTextures
  55750. */
  55751. getActiveTextures(activeTextures: BaseTexture[]): void;
  55752. /**
  55753. * Returns the animatable textures.
  55754. * @param animatables Array of animatable textures.
  55755. */
  55756. getAnimatables(animatables: IAnimatable[]): void;
  55757. /**
  55758. * Disposes the resources of the material.
  55759. * @param forceDisposeTextures - Forces the disposal of all textures.
  55760. */
  55761. dispose(forceDisposeTextures?: boolean): void;
  55762. /**
  55763. * Get the current class name of the texture useful for serialization or dynamic coding.
  55764. * @returns "PBRSubSurfaceConfiguration"
  55765. */
  55766. getClassName(): string;
  55767. /**
  55768. * Add fallbacks to the effect fallbacks list.
  55769. * @param defines defines the Base texture to use.
  55770. * @param fallbacks defines the current fallback list.
  55771. * @param currentRank defines the current fallback rank.
  55772. * @returns the new fallback rank.
  55773. */
  55774. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55775. /**
  55776. * Add the required uniforms to the current list.
  55777. * @param uniforms defines the current uniform list.
  55778. */
  55779. static AddUniforms(uniforms: string[]): void;
  55780. /**
  55781. * Add the required samplers to the current list.
  55782. * @param samplers defines the current sampler list.
  55783. */
  55784. static AddSamplers(samplers: string[]): void;
  55785. /**
  55786. * Add the required uniforms to the current buffer.
  55787. * @param uniformBuffer defines the current uniform buffer.
  55788. */
  55789. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55790. /**
  55791. * Makes a duplicate of the current configuration into another one.
  55792. * @param configuration define the config where to copy the info
  55793. */
  55794. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  55795. /**
  55796. * Serializes this Sub Surface configuration.
  55797. * @returns - An object with the serialized config.
  55798. */
  55799. serialize(): any;
  55800. /**
  55801. * Parses a anisotropy Configuration from a serialized object.
  55802. * @param source - Serialized object.
  55803. * @param scene Defines the scene we are parsing for
  55804. * @param rootUrl Defines the rootUrl to load from
  55805. */
  55806. parse(source: any, scene: Scene, rootUrl: string): void;
  55807. }
  55808. }
  55809. declare module BABYLON {
  55810. /** @hidden */
  55811. export var pbrFragmentDeclaration: {
  55812. name: string;
  55813. shader: string;
  55814. };
  55815. }
  55816. declare module BABYLON {
  55817. /** @hidden */
  55818. export var pbrUboDeclaration: {
  55819. name: string;
  55820. shader: string;
  55821. };
  55822. }
  55823. declare module BABYLON {
  55824. /** @hidden */
  55825. export var pbrFragmentExtraDeclaration: {
  55826. name: string;
  55827. shader: string;
  55828. };
  55829. }
  55830. declare module BABYLON {
  55831. /** @hidden */
  55832. export var pbrFragmentSamplersDeclaration: {
  55833. name: string;
  55834. shader: string;
  55835. };
  55836. }
  55837. declare module BABYLON {
  55838. /** @hidden */
  55839. export var importanceSampling: {
  55840. name: string;
  55841. shader: string;
  55842. };
  55843. }
  55844. declare module BABYLON {
  55845. /** @hidden */
  55846. export var pbrHelperFunctions: {
  55847. name: string;
  55848. shader: string;
  55849. };
  55850. }
  55851. declare module BABYLON {
  55852. /** @hidden */
  55853. export var harmonicsFunctions: {
  55854. name: string;
  55855. shader: string;
  55856. };
  55857. }
  55858. declare module BABYLON {
  55859. /** @hidden */
  55860. export var pbrDirectLightingSetupFunctions: {
  55861. name: string;
  55862. shader: string;
  55863. };
  55864. }
  55865. declare module BABYLON {
  55866. /** @hidden */
  55867. export var pbrDirectLightingFalloffFunctions: {
  55868. name: string;
  55869. shader: string;
  55870. };
  55871. }
  55872. declare module BABYLON {
  55873. /** @hidden */
  55874. export var pbrBRDFFunctions: {
  55875. name: string;
  55876. shader: string;
  55877. };
  55878. }
  55879. declare module BABYLON {
  55880. /** @hidden */
  55881. export var hdrFilteringFunctions: {
  55882. name: string;
  55883. shader: string;
  55884. };
  55885. }
  55886. declare module BABYLON {
  55887. /** @hidden */
  55888. export var pbrDirectLightingFunctions: {
  55889. name: string;
  55890. shader: string;
  55891. };
  55892. }
  55893. declare module BABYLON {
  55894. /** @hidden */
  55895. export var pbrIBLFunctions: {
  55896. name: string;
  55897. shader: string;
  55898. };
  55899. }
  55900. declare module BABYLON {
  55901. /** @hidden */
  55902. export var pbrBlockAlbedoOpacity: {
  55903. name: string;
  55904. shader: string;
  55905. };
  55906. }
  55907. declare module BABYLON {
  55908. /** @hidden */
  55909. export var pbrBlockReflectivity: {
  55910. name: string;
  55911. shader: string;
  55912. };
  55913. }
  55914. declare module BABYLON {
  55915. /** @hidden */
  55916. export var pbrBlockAmbientOcclusion: {
  55917. name: string;
  55918. shader: string;
  55919. };
  55920. }
  55921. declare module BABYLON {
  55922. /** @hidden */
  55923. export var pbrBlockAlphaFresnel: {
  55924. name: string;
  55925. shader: string;
  55926. };
  55927. }
  55928. declare module BABYLON {
  55929. /** @hidden */
  55930. export var pbrBlockAnisotropic: {
  55931. name: string;
  55932. shader: string;
  55933. };
  55934. }
  55935. declare module BABYLON {
  55936. /** @hidden */
  55937. export var pbrBlockReflection: {
  55938. name: string;
  55939. shader: string;
  55940. };
  55941. }
  55942. declare module BABYLON {
  55943. /** @hidden */
  55944. export var pbrBlockSheen: {
  55945. name: string;
  55946. shader: string;
  55947. };
  55948. }
  55949. declare module BABYLON {
  55950. /** @hidden */
  55951. export var pbrBlockClearcoat: {
  55952. name: string;
  55953. shader: string;
  55954. };
  55955. }
  55956. declare module BABYLON {
  55957. /** @hidden */
  55958. export var pbrBlockSubSurface: {
  55959. name: string;
  55960. shader: string;
  55961. };
  55962. }
  55963. declare module BABYLON {
  55964. /** @hidden */
  55965. export var pbrBlockNormalGeometric: {
  55966. name: string;
  55967. shader: string;
  55968. };
  55969. }
  55970. declare module BABYLON {
  55971. /** @hidden */
  55972. export var pbrBlockNormalFinal: {
  55973. name: string;
  55974. shader: string;
  55975. };
  55976. }
  55977. declare module BABYLON {
  55978. /** @hidden */
  55979. export var pbrBlockLightmapInit: {
  55980. name: string;
  55981. shader: string;
  55982. };
  55983. }
  55984. declare module BABYLON {
  55985. /** @hidden */
  55986. export var pbrBlockGeometryInfo: {
  55987. name: string;
  55988. shader: string;
  55989. };
  55990. }
  55991. declare module BABYLON {
  55992. /** @hidden */
  55993. export var pbrBlockReflectance0: {
  55994. name: string;
  55995. shader: string;
  55996. };
  55997. }
  55998. declare module BABYLON {
  55999. /** @hidden */
  56000. export var pbrBlockReflectance: {
  56001. name: string;
  56002. shader: string;
  56003. };
  56004. }
  56005. declare module BABYLON {
  56006. /** @hidden */
  56007. export var pbrBlockDirectLighting: {
  56008. name: string;
  56009. shader: string;
  56010. };
  56011. }
  56012. declare module BABYLON {
  56013. /** @hidden */
  56014. export var pbrBlockFinalLitComponents: {
  56015. name: string;
  56016. shader: string;
  56017. };
  56018. }
  56019. declare module BABYLON {
  56020. /** @hidden */
  56021. export var pbrBlockFinalUnlitComponents: {
  56022. name: string;
  56023. shader: string;
  56024. };
  56025. }
  56026. declare module BABYLON {
  56027. /** @hidden */
  56028. export var pbrBlockFinalColorComposition: {
  56029. name: string;
  56030. shader: string;
  56031. };
  56032. }
  56033. declare module BABYLON {
  56034. /** @hidden */
  56035. export var pbrBlockImageProcessing: {
  56036. name: string;
  56037. shader: string;
  56038. };
  56039. }
  56040. declare module BABYLON {
  56041. /** @hidden */
  56042. export var pbrDebug: {
  56043. name: string;
  56044. shader: string;
  56045. };
  56046. }
  56047. declare module BABYLON {
  56048. /** @hidden */
  56049. export var pbrPixelShader: {
  56050. name: string;
  56051. shader: string;
  56052. };
  56053. }
  56054. declare module BABYLON {
  56055. /** @hidden */
  56056. export var pbrVertexDeclaration: {
  56057. name: string;
  56058. shader: string;
  56059. };
  56060. }
  56061. declare module BABYLON {
  56062. /** @hidden */
  56063. export var pbrVertexShader: {
  56064. name: string;
  56065. shader: string;
  56066. };
  56067. }
  56068. declare module BABYLON {
  56069. /**
  56070. * Manages the defines for the PBR Material.
  56071. * @hidden
  56072. */
  56073. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  56074. PBR: boolean;
  56075. NUM_SAMPLES: string;
  56076. REALTIME_FILTERING: boolean;
  56077. MAINUV1: boolean;
  56078. MAINUV2: boolean;
  56079. UV1: boolean;
  56080. UV2: boolean;
  56081. ALBEDO: boolean;
  56082. GAMMAALBEDO: boolean;
  56083. ALBEDODIRECTUV: number;
  56084. VERTEXCOLOR: boolean;
  56085. DETAIL: boolean;
  56086. DETAILDIRECTUV: number;
  56087. DETAIL_NORMALBLENDMETHOD: number;
  56088. AMBIENT: boolean;
  56089. AMBIENTDIRECTUV: number;
  56090. AMBIENTINGRAYSCALE: boolean;
  56091. OPACITY: boolean;
  56092. VERTEXALPHA: boolean;
  56093. OPACITYDIRECTUV: number;
  56094. OPACITYRGB: boolean;
  56095. ALPHATEST: boolean;
  56096. DEPTHPREPASS: boolean;
  56097. ALPHABLEND: boolean;
  56098. ALPHAFROMALBEDO: boolean;
  56099. ALPHATESTVALUE: string;
  56100. SPECULAROVERALPHA: boolean;
  56101. RADIANCEOVERALPHA: boolean;
  56102. ALPHAFRESNEL: boolean;
  56103. LINEARALPHAFRESNEL: boolean;
  56104. PREMULTIPLYALPHA: boolean;
  56105. EMISSIVE: boolean;
  56106. EMISSIVEDIRECTUV: number;
  56107. REFLECTIVITY: boolean;
  56108. REFLECTIVITYDIRECTUV: number;
  56109. SPECULARTERM: boolean;
  56110. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  56111. MICROSURFACEAUTOMATIC: boolean;
  56112. LODBASEDMICROSFURACE: boolean;
  56113. MICROSURFACEMAP: boolean;
  56114. MICROSURFACEMAPDIRECTUV: number;
  56115. METALLICWORKFLOW: boolean;
  56116. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  56117. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  56118. METALLNESSSTOREINMETALMAPBLUE: boolean;
  56119. AOSTOREINMETALMAPRED: boolean;
  56120. METALLIC_REFLECTANCE: boolean;
  56121. METALLIC_REFLECTANCEDIRECTUV: number;
  56122. ENVIRONMENTBRDF: boolean;
  56123. ENVIRONMENTBRDF_RGBD: boolean;
  56124. NORMAL: boolean;
  56125. TANGENT: boolean;
  56126. BUMP: boolean;
  56127. BUMPDIRECTUV: number;
  56128. OBJECTSPACE_NORMALMAP: boolean;
  56129. PARALLAX: boolean;
  56130. PARALLAXOCCLUSION: boolean;
  56131. NORMALXYSCALE: boolean;
  56132. LIGHTMAP: boolean;
  56133. LIGHTMAPDIRECTUV: number;
  56134. USELIGHTMAPASSHADOWMAP: boolean;
  56135. GAMMALIGHTMAP: boolean;
  56136. RGBDLIGHTMAP: boolean;
  56137. REFLECTION: boolean;
  56138. REFLECTIONMAP_3D: boolean;
  56139. REFLECTIONMAP_SPHERICAL: boolean;
  56140. REFLECTIONMAP_PLANAR: boolean;
  56141. REFLECTIONMAP_CUBIC: boolean;
  56142. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  56143. REFLECTIONMAP_PROJECTION: boolean;
  56144. REFLECTIONMAP_SKYBOX: boolean;
  56145. REFLECTIONMAP_EXPLICIT: boolean;
  56146. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  56147. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  56148. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  56149. INVERTCUBICMAP: boolean;
  56150. USESPHERICALFROMREFLECTIONMAP: boolean;
  56151. USEIRRADIANCEMAP: boolean;
  56152. SPHERICAL_HARMONICS: boolean;
  56153. USESPHERICALINVERTEX: boolean;
  56154. REFLECTIONMAP_OPPOSITEZ: boolean;
  56155. LODINREFLECTIONALPHA: boolean;
  56156. GAMMAREFLECTION: boolean;
  56157. RGBDREFLECTION: boolean;
  56158. LINEARSPECULARREFLECTION: boolean;
  56159. RADIANCEOCCLUSION: boolean;
  56160. HORIZONOCCLUSION: boolean;
  56161. INSTANCES: boolean;
  56162. THIN_INSTANCES: boolean;
  56163. PREPASS: boolean;
  56164. SCENE_MRT_COUNT: number;
  56165. NUM_BONE_INFLUENCERS: number;
  56166. BonesPerMesh: number;
  56167. BONETEXTURE: boolean;
  56168. NONUNIFORMSCALING: boolean;
  56169. MORPHTARGETS: boolean;
  56170. MORPHTARGETS_NORMAL: boolean;
  56171. MORPHTARGETS_TANGENT: boolean;
  56172. MORPHTARGETS_UV: boolean;
  56173. NUM_MORPH_INFLUENCERS: number;
  56174. IMAGEPROCESSING: boolean;
  56175. VIGNETTE: boolean;
  56176. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56177. VIGNETTEBLENDMODEOPAQUE: boolean;
  56178. TONEMAPPING: boolean;
  56179. TONEMAPPING_ACES: boolean;
  56180. CONTRAST: boolean;
  56181. COLORCURVES: boolean;
  56182. COLORGRADING: boolean;
  56183. COLORGRADING3D: boolean;
  56184. SAMPLER3DGREENDEPTH: boolean;
  56185. SAMPLER3DBGRMAP: boolean;
  56186. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56187. EXPOSURE: boolean;
  56188. MULTIVIEW: boolean;
  56189. USEPHYSICALLIGHTFALLOFF: boolean;
  56190. USEGLTFLIGHTFALLOFF: boolean;
  56191. TWOSIDEDLIGHTING: boolean;
  56192. SHADOWFLOAT: boolean;
  56193. CLIPPLANE: boolean;
  56194. CLIPPLANE2: boolean;
  56195. CLIPPLANE3: boolean;
  56196. CLIPPLANE4: boolean;
  56197. CLIPPLANE5: boolean;
  56198. CLIPPLANE6: boolean;
  56199. POINTSIZE: boolean;
  56200. FOG: boolean;
  56201. LOGARITHMICDEPTH: boolean;
  56202. FORCENORMALFORWARD: boolean;
  56203. SPECULARAA: boolean;
  56204. CLEARCOAT: boolean;
  56205. CLEARCOAT_DEFAULTIOR: boolean;
  56206. CLEARCOAT_TEXTURE: boolean;
  56207. CLEARCOAT_TEXTUREDIRECTUV: number;
  56208. CLEARCOAT_BUMP: boolean;
  56209. CLEARCOAT_BUMPDIRECTUV: number;
  56210. CLEARCOAT_TINT: boolean;
  56211. CLEARCOAT_TINT_TEXTURE: boolean;
  56212. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56213. ANISOTROPIC: boolean;
  56214. ANISOTROPIC_TEXTURE: boolean;
  56215. ANISOTROPIC_TEXTUREDIRECTUV: number;
  56216. BRDF_V_HEIGHT_CORRELATED: boolean;
  56217. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56218. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56219. SHEEN: boolean;
  56220. SHEEN_TEXTURE: boolean;
  56221. SHEEN_TEXTUREDIRECTUV: number;
  56222. SHEEN_LINKWITHALBEDO: boolean;
  56223. SHEEN_ROUGHNESS: boolean;
  56224. SHEEN_ALBEDOSCALING: boolean;
  56225. SUBSURFACE: boolean;
  56226. SS_REFRACTION: boolean;
  56227. SS_TRANSLUCENCY: boolean;
  56228. SS_SCATTERING: boolean;
  56229. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56230. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56231. SS_REFRACTIONMAP_3D: boolean;
  56232. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56233. SS_LODINREFRACTIONALPHA: boolean;
  56234. SS_GAMMAREFRACTION: boolean;
  56235. SS_RGBDREFRACTION: boolean;
  56236. SS_LINEARSPECULARREFRACTION: boolean;
  56237. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56238. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56239. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56240. UNLIT: boolean;
  56241. DEBUGMODE: number;
  56242. /**
  56243. * Initializes the PBR Material defines.
  56244. */
  56245. constructor();
  56246. /**
  56247. * Resets the PBR Material defines.
  56248. */
  56249. reset(): void;
  56250. }
  56251. /**
  56252. * The Physically based material base class of BJS.
  56253. *
  56254. * This offers the main features of a standard PBR material.
  56255. * For more information, please refer to the documentation :
  56256. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56257. */
  56258. export abstract class PBRBaseMaterial extends PushMaterial {
  56259. /**
  56260. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56261. */
  56262. static readonly PBRMATERIAL_OPAQUE: number;
  56263. /**
  56264. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56265. */
  56266. static readonly PBRMATERIAL_ALPHATEST: number;
  56267. /**
  56268. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56269. */
  56270. static readonly PBRMATERIAL_ALPHABLEND: number;
  56271. /**
  56272. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56273. * They are also discarded below the alpha cutoff threshold to improve performances.
  56274. */
  56275. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56276. /**
  56277. * Defines the default value of how much AO map is occluding the analytical lights
  56278. * (point spot...).
  56279. */
  56280. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56281. /**
  56282. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  56283. */
  56284. static readonly LIGHTFALLOFF_PHYSICAL: number;
  56285. /**
  56286. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  56287. * to enhance interoperability with other engines.
  56288. */
  56289. static readonly LIGHTFALLOFF_GLTF: number;
  56290. /**
  56291. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  56292. * to enhance interoperability with other materials.
  56293. */
  56294. static readonly LIGHTFALLOFF_STANDARD: number;
  56295. /**
  56296. * Intensity of the direct lights e.g. the four lights available in your scene.
  56297. * This impacts both the direct diffuse and specular highlights.
  56298. */
  56299. protected _directIntensity: number;
  56300. /**
  56301. * Intensity of the emissive part of the material.
  56302. * This helps controlling the emissive effect without modifying the emissive color.
  56303. */
  56304. protected _emissiveIntensity: number;
  56305. /**
  56306. * Intensity of the environment e.g. how much the environment will light the object
  56307. * either through harmonics for rough material or through the refelction for shiny ones.
  56308. */
  56309. protected _environmentIntensity: number;
  56310. /**
  56311. * This is a special control allowing the reduction of the specular highlights coming from the
  56312. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56313. */
  56314. protected _specularIntensity: number;
  56315. /**
  56316. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  56317. */
  56318. private _lightingInfos;
  56319. /**
  56320. * Debug Control allowing disabling the bump map on this material.
  56321. */
  56322. protected _disableBumpMap: boolean;
  56323. /**
  56324. * AKA Diffuse Texture in standard nomenclature.
  56325. */
  56326. protected _albedoTexture: Nullable<BaseTexture>;
  56327. /**
  56328. * AKA Occlusion Texture in other nomenclature.
  56329. */
  56330. protected _ambientTexture: Nullable<BaseTexture>;
  56331. /**
  56332. * AKA Occlusion Texture Intensity in other nomenclature.
  56333. */
  56334. protected _ambientTextureStrength: number;
  56335. /**
  56336. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56337. * 1 means it completely occludes it
  56338. * 0 mean it has no impact
  56339. */
  56340. protected _ambientTextureImpactOnAnalyticalLights: number;
  56341. /**
  56342. * Stores the alpha values in a texture.
  56343. */
  56344. protected _opacityTexture: Nullable<BaseTexture>;
  56345. /**
  56346. * Stores the reflection values in a texture.
  56347. */
  56348. protected _reflectionTexture: Nullable<BaseTexture>;
  56349. /**
  56350. * Stores the emissive values in a texture.
  56351. */
  56352. protected _emissiveTexture: Nullable<BaseTexture>;
  56353. /**
  56354. * AKA Specular texture in other nomenclature.
  56355. */
  56356. protected _reflectivityTexture: Nullable<BaseTexture>;
  56357. /**
  56358. * Used to switch from specular/glossiness to metallic/roughness workflow.
  56359. */
  56360. protected _metallicTexture: Nullable<BaseTexture>;
  56361. /**
  56362. * Specifies the metallic scalar of the metallic/roughness workflow.
  56363. * Can also be used to scale the metalness values of the metallic texture.
  56364. */
  56365. protected _metallic: Nullable<number>;
  56366. /**
  56367. * Specifies the roughness scalar of the metallic/roughness workflow.
  56368. * Can also be used to scale the roughness values of the metallic texture.
  56369. */
  56370. protected _roughness: Nullable<number>;
  56371. /**
  56372. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  56373. * By default the indexOfrefraction is used to compute F0;
  56374. *
  56375. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  56376. *
  56377. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  56378. * F90 = metallicReflectanceColor;
  56379. */
  56380. protected _metallicF0Factor: number;
  56381. /**
  56382. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  56383. * By default the F90 is always 1;
  56384. *
  56385. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  56386. *
  56387. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  56388. * F90 = metallicReflectanceColor;
  56389. */
  56390. protected _metallicReflectanceColor: Color3;
  56391. /**
  56392. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  56393. * This is multiply against the scalar values defined in the material.
  56394. */
  56395. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  56396. /**
  56397. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  56398. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  56399. */
  56400. protected _microSurfaceTexture: Nullable<BaseTexture>;
  56401. /**
  56402. * Stores surface normal data used to displace a mesh in a texture.
  56403. */
  56404. protected _bumpTexture: Nullable<BaseTexture>;
  56405. /**
  56406. * Stores the pre-calculated light information of a mesh in a texture.
  56407. */
  56408. protected _lightmapTexture: Nullable<BaseTexture>;
  56409. /**
  56410. * The color of a material in ambient lighting.
  56411. */
  56412. protected _ambientColor: Color3;
  56413. /**
  56414. * AKA Diffuse Color in other nomenclature.
  56415. */
  56416. protected _albedoColor: Color3;
  56417. /**
  56418. * AKA Specular Color in other nomenclature.
  56419. */
  56420. protected _reflectivityColor: Color3;
  56421. /**
  56422. * The color applied when light is reflected from a material.
  56423. */
  56424. protected _reflectionColor: Color3;
  56425. /**
  56426. * The color applied when light is emitted from a material.
  56427. */
  56428. protected _emissiveColor: Color3;
  56429. /**
  56430. * AKA Glossiness in other nomenclature.
  56431. */
  56432. protected _microSurface: number;
  56433. /**
  56434. * Specifies that the material will use the light map as a show map.
  56435. */
  56436. protected _useLightmapAsShadowmap: boolean;
  56437. /**
  56438. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56439. * makes the reflect vector face the model (under horizon).
  56440. */
  56441. protected _useHorizonOcclusion: boolean;
  56442. /**
  56443. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56444. * too much the area relying on ambient texture to define their ambient occlusion.
  56445. */
  56446. protected _useRadianceOcclusion: boolean;
  56447. /**
  56448. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56449. */
  56450. protected _useAlphaFromAlbedoTexture: boolean;
  56451. /**
  56452. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  56453. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56454. */
  56455. protected _useSpecularOverAlpha: boolean;
  56456. /**
  56457. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56458. */
  56459. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56460. /**
  56461. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56462. */
  56463. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  56464. /**
  56465. * Specifies if the metallic texture contains the roughness information in its green channel.
  56466. */
  56467. protected _useRoughnessFromMetallicTextureGreen: boolean;
  56468. /**
  56469. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56470. */
  56471. protected _useMetallnessFromMetallicTextureBlue: boolean;
  56472. /**
  56473. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56474. */
  56475. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  56476. /**
  56477. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56478. */
  56479. protected _useAmbientInGrayScale: boolean;
  56480. /**
  56481. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56482. * The material will try to infer what glossiness each pixel should be.
  56483. */
  56484. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  56485. /**
  56486. * Defines the falloff type used in this material.
  56487. * It by default is Physical.
  56488. */
  56489. protected _lightFalloff: number;
  56490. /**
  56491. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56492. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56493. */
  56494. protected _useRadianceOverAlpha: boolean;
  56495. /**
  56496. * Allows using an object space normal map (instead of tangent space).
  56497. */
  56498. protected _useObjectSpaceNormalMap: boolean;
  56499. /**
  56500. * Allows using the bump map in parallax mode.
  56501. */
  56502. protected _useParallax: boolean;
  56503. /**
  56504. * Allows using the bump map in parallax occlusion mode.
  56505. */
  56506. protected _useParallaxOcclusion: boolean;
  56507. /**
  56508. * Controls the scale bias of the parallax mode.
  56509. */
  56510. protected _parallaxScaleBias: number;
  56511. /**
  56512. * If sets to true, disables all the lights affecting the material.
  56513. */
  56514. protected _disableLighting: boolean;
  56515. /**
  56516. * Number of Simultaneous lights allowed on the material.
  56517. */
  56518. protected _maxSimultaneousLights: number;
  56519. /**
  56520. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56521. */
  56522. protected _invertNormalMapX: boolean;
  56523. /**
  56524. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56525. */
  56526. protected _invertNormalMapY: boolean;
  56527. /**
  56528. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56529. */
  56530. protected _twoSidedLighting: boolean;
  56531. /**
  56532. * Defines the alpha limits in alpha test mode.
  56533. */
  56534. protected _alphaCutOff: number;
  56535. /**
  56536. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56537. */
  56538. protected _forceAlphaTest: boolean;
  56539. /**
  56540. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56541. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56542. */
  56543. protected _useAlphaFresnel: boolean;
  56544. /**
  56545. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56546. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56547. */
  56548. protected _useLinearAlphaFresnel: boolean;
  56549. /**
  56550. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  56551. * from cos thetav and roughness:
  56552. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  56553. */
  56554. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  56555. /**
  56556. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56557. */
  56558. protected _forceIrradianceInFragment: boolean;
  56559. private _realTimeFiltering;
  56560. /**
  56561. * Enables realtime filtering on the texture.
  56562. */
  56563. get realTimeFiltering(): boolean;
  56564. set realTimeFiltering(b: boolean);
  56565. private _realTimeFilteringQuality;
  56566. /**
  56567. * Quality switch for realtime filtering
  56568. */
  56569. get realTimeFilteringQuality(): number;
  56570. set realTimeFilteringQuality(n: number);
  56571. /**
  56572. * Can this material render to several textures at once
  56573. */
  56574. get canRenderToMRT(): boolean;
  56575. /**
  56576. * Force normal to face away from face.
  56577. */
  56578. protected _forceNormalForward: boolean;
  56579. /**
  56580. * Enables specular anti aliasing in the PBR shader.
  56581. * It will both interacts on the Geometry for analytical and IBL lighting.
  56582. * It also prefilter the roughness map based on the bump values.
  56583. */
  56584. protected _enableSpecularAntiAliasing: boolean;
  56585. /**
  56586. * Default configuration related to image processing available in the PBR Material.
  56587. */
  56588. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56589. /**
  56590. * Keep track of the image processing observer to allow dispose and replace.
  56591. */
  56592. private _imageProcessingObserver;
  56593. /**
  56594. * Attaches a new image processing configuration to the PBR Material.
  56595. * @param configuration
  56596. */
  56597. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56598. /**
  56599. * Stores the available render targets.
  56600. */
  56601. private _renderTargets;
  56602. /**
  56603. * Sets the global ambient color for the material used in lighting calculations.
  56604. */
  56605. private _globalAmbientColor;
  56606. /**
  56607. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  56608. */
  56609. private _useLogarithmicDepth;
  56610. /**
  56611. * If set to true, no lighting calculations will be applied.
  56612. */
  56613. private _unlit;
  56614. private _debugMode;
  56615. /**
  56616. * @hidden
  56617. * This is reserved for the inspector.
  56618. * Defines the material debug mode.
  56619. * It helps seeing only some components of the material while troubleshooting.
  56620. */
  56621. debugMode: number;
  56622. /**
  56623. * @hidden
  56624. * This is reserved for the inspector.
  56625. * Specify from where on screen the debug mode should start.
  56626. * The value goes from -1 (full screen) to 1 (not visible)
  56627. * It helps with side by side comparison against the final render
  56628. * This defaults to -1
  56629. */
  56630. private debugLimit;
  56631. /**
  56632. * @hidden
  56633. * This is reserved for the inspector.
  56634. * As the default viewing range might not be enough (if the ambient is really small for instance)
  56635. * You can use the factor to better multiply the final value.
  56636. */
  56637. private debugFactor;
  56638. /**
  56639. * Defines the clear coat layer parameters for the material.
  56640. */
  56641. readonly clearCoat: PBRClearCoatConfiguration;
  56642. /**
  56643. * Defines the anisotropic parameters for the material.
  56644. */
  56645. readonly anisotropy: PBRAnisotropicConfiguration;
  56646. /**
  56647. * Defines the BRDF parameters for the material.
  56648. */
  56649. readonly brdf: PBRBRDFConfiguration;
  56650. /**
  56651. * Defines the Sheen parameters for the material.
  56652. */
  56653. readonly sheen: PBRSheenConfiguration;
  56654. /**
  56655. * Defines the SubSurface parameters for the material.
  56656. */
  56657. readonly subSurface: PBRSubSurfaceConfiguration;
  56658. /**
  56659. * Defines the detail map parameters for the material.
  56660. */
  56661. readonly detailMap: DetailMapConfiguration;
  56662. protected _rebuildInParallel: boolean;
  56663. /**
  56664. * Instantiates a new PBRMaterial instance.
  56665. *
  56666. * @param name The material name
  56667. * @param scene The scene the material will be use in.
  56668. */
  56669. constructor(name: string, scene: Scene);
  56670. /**
  56671. * Gets a boolean indicating that current material needs to register RTT
  56672. */
  56673. get hasRenderTargetTextures(): boolean;
  56674. /**
  56675. * Gets the name of the material class.
  56676. */
  56677. getClassName(): string;
  56678. /**
  56679. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56680. */
  56681. get useLogarithmicDepth(): boolean;
  56682. /**
  56683. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56684. */
  56685. set useLogarithmicDepth(value: boolean);
  56686. /**
  56687. * Returns true if alpha blending should be disabled.
  56688. */
  56689. protected get _disableAlphaBlending(): boolean;
  56690. /**
  56691. * Specifies whether or not this material should be rendered in alpha blend mode.
  56692. */
  56693. needAlphaBlending(): boolean;
  56694. /**
  56695. * Specifies whether or not this material should be rendered in alpha test mode.
  56696. */
  56697. needAlphaTesting(): boolean;
  56698. /**
  56699. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  56700. */
  56701. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  56702. /**
  56703. * Gets the texture used for the alpha test.
  56704. */
  56705. getAlphaTestTexture(): Nullable<BaseTexture>;
  56706. /**
  56707. * Specifies that the submesh is ready to be used.
  56708. * @param mesh - BJS mesh.
  56709. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  56710. * @param useInstances - Specifies that instances should be used.
  56711. * @returns - boolean indicating that the submesh is ready or not.
  56712. */
  56713. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56714. /**
  56715. * Specifies if the material uses metallic roughness workflow.
  56716. * @returns boolean specifiying if the material uses metallic roughness workflow.
  56717. */
  56718. isMetallicWorkflow(): boolean;
  56719. private _prepareEffect;
  56720. private _prepareDefines;
  56721. /**
  56722. * Force shader compilation
  56723. */
  56724. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  56725. /**
  56726. * Initializes the uniform buffer layout for the shader.
  56727. */
  56728. buildUniformLayout(): void;
  56729. /**
  56730. * Unbinds the material from the mesh
  56731. */
  56732. unbind(): void;
  56733. /**
  56734. * Binds the submesh data.
  56735. * @param world - The world matrix.
  56736. * @param mesh - The BJS mesh.
  56737. * @param subMesh - A submesh of the BJS mesh.
  56738. */
  56739. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56740. /**
  56741. * Returns the animatable textures.
  56742. * @returns - Array of animatable textures.
  56743. */
  56744. getAnimatables(): IAnimatable[];
  56745. /**
  56746. * Returns the texture used for reflections.
  56747. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  56748. */
  56749. private _getReflectionTexture;
  56750. /**
  56751. * Returns an array of the actively used textures.
  56752. * @returns - Array of BaseTextures
  56753. */
  56754. getActiveTextures(): BaseTexture[];
  56755. /**
  56756. * Checks to see if a texture is used in the material.
  56757. * @param texture - Base texture to use.
  56758. * @returns - Boolean specifying if a texture is used in the material.
  56759. */
  56760. hasTexture(texture: BaseTexture): boolean;
  56761. /**
  56762. * Sets the required values to the prepass renderer.
  56763. * @param prePassRenderer defines the prepass renderer to setup
  56764. */
  56765. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  56766. /**
  56767. * Disposes the resources of the material.
  56768. * @param forceDisposeEffect - Forces the disposal of effects.
  56769. * @param forceDisposeTextures - Forces the disposal of all textures.
  56770. */
  56771. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  56772. }
  56773. }
  56774. declare module BABYLON {
  56775. /**
  56776. * The Physically based material of BJS.
  56777. *
  56778. * This offers the main features of a standard PBR material.
  56779. * For more information, please refer to the documentation :
  56780. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56781. */
  56782. export class PBRMaterial extends PBRBaseMaterial {
  56783. /**
  56784. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56785. */
  56786. static readonly PBRMATERIAL_OPAQUE: number;
  56787. /**
  56788. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56789. */
  56790. static readonly PBRMATERIAL_ALPHATEST: number;
  56791. /**
  56792. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56793. */
  56794. static readonly PBRMATERIAL_ALPHABLEND: number;
  56795. /**
  56796. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56797. * They are also discarded below the alpha cutoff threshold to improve performances.
  56798. */
  56799. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56800. /**
  56801. * Defines the default value of how much AO map is occluding the analytical lights
  56802. * (point spot...).
  56803. */
  56804. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56805. /**
  56806. * Intensity of the direct lights e.g. the four lights available in your scene.
  56807. * This impacts both the direct diffuse and specular highlights.
  56808. */
  56809. directIntensity: number;
  56810. /**
  56811. * Intensity of the emissive part of the material.
  56812. * This helps controlling the emissive effect without modifying the emissive color.
  56813. */
  56814. emissiveIntensity: number;
  56815. /**
  56816. * Intensity of the environment e.g. how much the environment will light the object
  56817. * either through harmonics for rough material or through the refelction for shiny ones.
  56818. */
  56819. environmentIntensity: number;
  56820. /**
  56821. * This is a special control allowing the reduction of the specular highlights coming from the
  56822. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56823. */
  56824. specularIntensity: number;
  56825. /**
  56826. * Debug Control allowing disabling the bump map on this material.
  56827. */
  56828. disableBumpMap: boolean;
  56829. /**
  56830. * AKA Diffuse Texture in standard nomenclature.
  56831. */
  56832. albedoTexture: BaseTexture;
  56833. /**
  56834. * AKA Occlusion Texture in other nomenclature.
  56835. */
  56836. ambientTexture: BaseTexture;
  56837. /**
  56838. * AKA Occlusion Texture Intensity in other nomenclature.
  56839. */
  56840. ambientTextureStrength: number;
  56841. /**
  56842. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56843. * 1 means it completely occludes it
  56844. * 0 mean it has no impact
  56845. */
  56846. ambientTextureImpactOnAnalyticalLights: number;
  56847. /**
  56848. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  56849. */
  56850. opacityTexture: BaseTexture;
  56851. /**
  56852. * Stores the reflection values in a texture.
  56853. */
  56854. reflectionTexture: Nullable<BaseTexture>;
  56855. /**
  56856. * Stores the emissive values in a texture.
  56857. */
  56858. emissiveTexture: BaseTexture;
  56859. /**
  56860. * AKA Specular texture in other nomenclature.
  56861. */
  56862. reflectivityTexture: BaseTexture;
  56863. /**
  56864. * Used to switch from specular/glossiness to metallic/roughness workflow.
  56865. */
  56866. metallicTexture: BaseTexture;
  56867. /**
  56868. * Specifies the metallic scalar of the metallic/roughness workflow.
  56869. * Can also be used to scale the metalness values of the metallic texture.
  56870. */
  56871. metallic: Nullable<number>;
  56872. /**
  56873. * Specifies the roughness scalar of the metallic/roughness workflow.
  56874. * Can also be used to scale the roughness values of the metallic texture.
  56875. */
  56876. roughness: Nullable<number>;
  56877. /**
  56878. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  56879. * By default the indexOfrefraction is used to compute F0;
  56880. *
  56881. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  56882. *
  56883. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  56884. * F90 = metallicReflectanceColor;
  56885. */
  56886. metallicF0Factor: number;
  56887. /**
  56888. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  56889. * By default the F90 is always 1;
  56890. *
  56891. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  56892. *
  56893. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  56894. * F90 = metallicReflectanceColor;
  56895. */
  56896. metallicReflectanceColor: Color3;
  56897. /**
  56898. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  56899. * This is multiply against the scalar values defined in the material.
  56900. */
  56901. metallicReflectanceTexture: Nullable<BaseTexture>;
  56902. /**
  56903. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  56904. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  56905. */
  56906. microSurfaceTexture: BaseTexture;
  56907. /**
  56908. * Stores surface normal data used to displace a mesh in a texture.
  56909. */
  56910. bumpTexture: BaseTexture;
  56911. /**
  56912. * Stores the pre-calculated light information of a mesh in a texture.
  56913. */
  56914. lightmapTexture: BaseTexture;
  56915. /**
  56916. * Stores the refracted light information in a texture.
  56917. */
  56918. get refractionTexture(): Nullable<BaseTexture>;
  56919. set refractionTexture(value: Nullable<BaseTexture>);
  56920. /**
  56921. * The color of a material in ambient lighting.
  56922. */
  56923. ambientColor: Color3;
  56924. /**
  56925. * AKA Diffuse Color in other nomenclature.
  56926. */
  56927. albedoColor: Color3;
  56928. /**
  56929. * AKA Specular Color in other nomenclature.
  56930. */
  56931. reflectivityColor: Color3;
  56932. /**
  56933. * The color reflected from the material.
  56934. */
  56935. reflectionColor: Color3;
  56936. /**
  56937. * The color emitted from the material.
  56938. */
  56939. emissiveColor: Color3;
  56940. /**
  56941. * AKA Glossiness in other nomenclature.
  56942. */
  56943. microSurface: number;
  56944. /**
  56945. * Index of refraction of the material base layer.
  56946. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56947. *
  56948. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  56949. *
  56950. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  56951. */
  56952. get indexOfRefraction(): number;
  56953. set indexOfRefraction(value: number);
  56954. /**
  56955. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  56956. */
  56957. get invertRefractionY(): boolean;
  56958. set invertRefractionY(value: boolean);
  56959. /**
  56960. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  56961. * Materials half opaque for instance using refraction could benefit from this control.
  56962. */
  56963. get linkRefractionWithTransparency(): boolean;
  56964. set linkRefractionWithTransparency(value: boolean);
  56965. /**
  56966. * If true, the light map contains occlusion information instead of lighting info.
  56967. */
  56968. useLightmapAsShadowmap: boolean;
  56969. /**
  56970. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56971. */
  56972. useAlphaFromAlbedoTexture: boolean;
  56973. /**
  56974. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56975. */
  56976. forceAlphaTest: boolean;
  56977. /**
  56978. * Defines the alpha limits in alpha test mode.
  56979. */
  56980. alphaCutOff: number;
  56981. /**
  56982. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  56983. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56984. */
  56985. useSpecularOverAlpha: boolean;
  56986. /**
  56987. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56988. */
  56989. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56990. /**
  56991. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56992. */
  56993. useRoughnessFromMetallicTextureAlpha: boolean;
  56994. /**
  56995. * Specifies if the metallic texture contains the roughness information in its green channel.
  56996. */
  56997. useRoughnessFromMetallicTextureGreen: boolean;
  56998. /**
  56999. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57000. */
  57001. useMetallnessFromMetallicTextureBlue: boolean;
  57002. /**
  57003. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57004. */
  57005. useAmbientOcclusionFromMetallicTextureRed: boolean;
  57006. /**
  57007. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57008. */
  57009. useAmbientInGrayScale: boolean;
  57010. /**
  57011. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57012. * The material will try to infer what glossiness each pixel should be.
  57013. */
  57014. useAutoMicroSurfaceFromReflectivityMap: boolean;
  57015. /**
  57016. * BJS is using an harcoded light falloff based on a manually sets up range.
  57017. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57018. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57019. */
  57020. get usePhysicalLightFalloff(): boolean;
  57021. /**
  57022. * BJS is using an harcoded light falloff based on a manually sets up range.
  57023. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57024. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57025. */
  57026. set usePhysicalLightFalloff(value: boolean);
  57027. /**
  57028. * In order to support the falloff compatibility with gltf, a special mode has been added
  57029. * to reproduce the gltf light falloff.
  57030. */
  57031. get useGLTFLightFalloff(): boolean;
  57032. /**
  57033. * In order to support the falloff compatibility with gltf, a special mode has been added
  57034. * to reproduce the gltf light falloff.
  57035. */
  57036. set useGLTFLightFalloff(value: boolean);
  57037. /**
  57038. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57039. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57040. */
  57041. useRadianceOverAlpha: boolean;
  57042. /**
  57043. * Allows using an object space normal map (instead of tangent space).
  57044. */
  57045. useObjectSpaceNormalMap: boolean;
  57046. /**
  57047. * Allows using the bump map in parallax mode.
  57048. */
  57049. useParallax: boolean;
  57050. /**
  57051. * Allows using the bump map in parallax occlusion mode.
  57052. */
  57053. useParallaxOcclusion: boolean;
  57054. /**
  57055. * Controls the scale bias of the parallax mode.
  57056. */
  57057. parallaxScaleBias: number;
  57058. /**
  57059. * If sets to true, disables all the lights affecting the material.
  57060. */
  57061. disableLighting: boolean;
  57062. /**
  57063. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57064. */
  57065. forceIrradianceInFragment: boolean;
  57066. /**
  57067. * Number of Simultaneous lights allowed on the material.
  57068. */
  57069. maxSimultaneousLights: number;
  57070. /**
  57071. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  57072. */
  57073. invertNormalMapX: boolean;
  57074. /**
  57075. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  57076. */
  57077. invertNormalMapY: boolean;
  57078. /**
  57079. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57080. */
  57081. twoSidedLighting: boolean;
  57082. /**
  57083. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57084. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57085. */
  57086. useAlphaFresnel: boolean;
  57087. /**
  57088. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57089. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57090. */
  57091. useLinearAlphaFresnel: boolean;
  57092. /**
  57093. * Let user defines the brdf lookup texture used for IBL.
  57094. * A default 8bit version is embedded but you could point at :
  57095. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  57096. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  57097. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  57098. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  57099. */
  57100. environmentBRDFTexture: Nullable<BaseTexture>;
  57101. /**
  57102. * Force normal to face away from face.
  57103. */
  57104. forceNormalForward: boolean;
  57105. /**
  57106. * Enables specular anti aliasing in the PBR shader.
  57107. * It will both interacts on the Geometry for analytical and IBL lighting.
  57108. * It also prefilter the roughness map based on the bump values.
  57109. */
  57110. enableSpecularAntiAliasing: boolean;
  57111. /**
  57112. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57113. * makes the reflect vector face the model (under horizon).
  57114. */
  57115. useHorizonOcclusion: boolean;
  57116. /**
  57117. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57118. * too much the area relying on ambient texture to define their ambient occlusion.
  57119. */
  57120. useRadianceOcclusion: boolean;
  57121. /**
  57122. * If set to true, no lighting calculations will be applied.
  57123. */
  57124. unlit: boolean;
  57125. /**
  57126. * Gets the image processing configuration used either in this material.
  57127. */
  57128. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57129. /**
  57130. * Sets the Default image processing configuration used either in the this material.
  57131. *
  57132. * If sets to null, the scene one is in use.
  57133. */
  57134. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57135. /**
  57136. * Gets wether the color curves effect is enabled.
  57137. */
  57138. get cameraColorCurvesEnabled(): boolean;
  57139. /**
  57140. * Sets wether the color curves effect is enabled.
  57141. */
  57142. set cameraColorCurvesEnabled(value: boolean);
  57143. /**
  57144. * Gets wether the color grading effect is enabled.
  57145. */
  57146. get cameraColorGradingEnabled(): boolean;
  57147. /**
  57148. * Gets wether the color grading effect is enabled.
  57149. */
  57150. set cameraColorGradingEnabled(value: boolean);
  57151. /**
  57152. * Gets wether tonemapping is enabled or not.
  57153. */
  57154. get cameraToneMappingEnabled(): boolean;
  57155. /**
  57156. * Sets wether tonemapping is enabled or not
  57157. */
  57158. set cameraToneMappingEnabled(value: boolean);
  57159. /**
  57160. * The camera exposure used on this material.
  57161. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57162. * This corresponds to a photographic exposure.
  57163. */
  57164. get cameraExposure(): number;
  57165. /**
  57166. * The camera exposure used on this material.
  57167. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57168. * This corresponds to a photographic exposure.
  57169. */
  57170. set cameraExposure(value: number);
  57171. /**
  57172. * Gets The camera contrast used on this material.
  57173. */
  57174. get cameraContrast(): number;
  57175. /**
  57176. * Sets The camera contrast used on this material.
  57177. */
  57178. set cameraContrast(value: number);
  57179. /**
  57180. * Gets the Color Grading 2D Lookup Texture.
  57181. */
  57182. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57183. /**
  57184. * Sets the Color Grading 2D Lookup Texture.
  57185. */
  57186. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57187. /**
  57188. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57189. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57190. * 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;
  57191. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57192. */
  57193. get cameraColorCurves(): Nullable<ColorCurves>;
  57194. /**
  57195. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57196. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57197. * 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;
  57198. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57199. */
  57200. set cameraColorCurves(value: Nullable<ColorCurves>);
  57201. /**
  57202. * Instantiates a new PBRMaterial instance.
  57203. *
  57204. * @param name The material name
  57205. * @param scene The scene the material will be use in.
  57206. */
  57207. constructor(name: string, scene: Scene);
  57208. /**
  57209. * Returns the name of this material class.
  57210. */
  57211. getClassName(): string;
  57212. /**
  57213. * Makes a duplicate of the current material.
  57214. * @param name - name to use for the new material.
  57215. */
  57216. clone(name: string): PBRMaterial;
  57217. /**
  57218. * Serializes this PBR Material.
  57219. * @returns - An object with the serialized material.
  57220. */
  57221. serialize(): any;
  57222. /**
  57223. * Parses a PBR Material from a serialized object.
  57224. * @param source - Serialized object.
  57225. * @param scene - BJS scene instance.
  57226. * @param rootUrl - url for the scene object
  57227. * @returns - PBRMaterial
  57228. */
  57229. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  57230. }
  57231. }
  57232. declare module BABYLON {
  57233. /**
  57234. * Direct draw surface info
  57235. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  57236. */
  57237. export interface DDSInfo {
  57238. /**
  57239. * Width of the texture
  57240. */
  57241. width: number;
  57242. /**
  57243. * Width of the texture
  57244. */
  57245. height: number;
  57246. /**
  57247. * Number of Mipmaps for the texture
  57248. * @see https://en.wikipedia.org/wiki/Mipmap
  57249. */
  57250. mipmapCount: number;
  57251. /**
  57252. * If the textures format is a known fourCC format
  57253. * @see https://www.fourcc.org/
  57254. */
  57255. isFourCC: boolean;
  57256. /**
  57257. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  57258. */
  57259. isRGB: boolean;
  57260. /**
  57261. * If the texture is a lumincance format
  57262. */
  57263. isLuminance: boolean;
  57264. /**
  57265. * If this is a cube texture
  57266. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  57267. */
  57268. isCube: boolean;
  57269. /**
  57270. * If the texture is a compressed format eg. FOURCC_DXT1
  57271. */
  57272. isCompressed: boolean;
  57273. /**
  57274. * The dxgiFormat of the texture
  57275. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  57276. */
  57277. dxgiFormat: number;
  57278. /**
  57279. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  57280. */
  57281. textureType: number;
  57282. /**
  57283. * Sphericle polynomial created for the dds texture
  57284. */
  57285. sphericalPolynomial?: SphericalPolynomial;
  57286. }
  57287. /**
  57288. * Class used to provide DDS decompression tools
  57289. */
  57290. export class DDSTools {
  57291. /**
  57292. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  57293. */
  57294. static StoreLODInAlphaChannel: boolean;
  57295. /**
  57296. * Gets DDS information from an array buffer
  57297. * @param data defines the array buffer view to read data from
  57298. * @returns the DDS information
  57299. */
  57300. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  57301. private static _FloatView;
  57302. private static _Int32View;
  57303. private static _ToHalfFloat;
  57304. private static _FromHalfFloat;
  57305. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  57306. private static _GetHalfFloatRGBAArrayBuffer;
  57307. private static _GetFloatRGBAArrayBuffer;
  57308. private static _GetFloatAsUIntRGBAArrayBuffer;
  57309. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  57310. private static _GetRGBAArrayBuffer;
  57311. private static _ExtractLongWordOrder;
  57312. private static _GetRGBArrayBuffer;
  57313. private static _GetLuminanceArrayBuffer;
  57314. /**
  57315. * Uploads DDS Levels to a Babylon Texture
  57316. * @hidden
  57317. */
  57318. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  57319. }
  57320. interface ThinEngine {
  57321. /**
  57322. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  57323. * @param rootUrl defines the url where the file to load is located
  57324. * @param scene defines the current scene
  57325. * @param lodScale defines scale to apply to the mip map selection
  57326. * @param lodOffset defines offset to apply to the mip map selection
  57327. * @param onLoad defines an optional callback raised when the texture is loaded
  57328. * @param onError defines an optional callback raised if there is an issue to load the texture
  57329. * @param format defines the format of the data
  57330. * @param forcedExtension defines the extension to use to pick the right loader
  57331. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  57332. * @returns the cube texture as an InternalTexture
  57333. */
  57334. 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;
  57335. }
  57336. }
  57337. declare module BABYLON {
  57338. /**
  57339. * Implementation of the DDS Texture Loader.
  57340. * @hidden
  57341. */
  57342. export class _DDSTextureLoader implements IInternalTextureLoader {
  57343. /**
  57344. * Defines wether the loader supports cascade loading the different faces.
  57345. */
  57346. readonly supportCascades: boolean;
  57347. /**
  57348. * This returns if the loader support the current file information.
  57349. * @param extension defines the file extension of the file being loaded
  57350. * @returns true if the loader can load the specified file
  57351. */
  57352. canLoad(extension: string): boolean;
  57353. /**
  57354. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57355. * @param data contains the texture data
  57356. * @param texture defines the BabylonJS internal texture
  57357. * @param createPolynomials will be true if polynomials have been requested
  57358. * @param onLoad defines the callback to trigger once the texture is ready
  57359. * @param onError defines the callback to trigger in case of error
  57360. */
  57361. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57362. /**
  57363. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57364. * @param data contains the texture data
  57365. * @param texture defines the BabylonJS internal texture
  57366. * @param callback defines the method to call once ready to upload
  57367. */
  57368. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57369. }
  57370. }
  57371. declare module BABYLON {
  57372. /**
  57373. * Implementation of the ENV Texture Loader.
  57374. * @hidden
  57375. */
  57376. export class _ENVTextureLoader implements IInternalTextureLoader {
  57377. /**
  57378. * Defines wether the loader supports cascade loading the different faces.
  57379. */
  57380. readonly supportCascades: boolean;
  57381. /**
  57382. * This returns if the loader support the current file information.
  57383. * @param extension defines the file extension of the file being loaded
  57384. * @returns true if the loader can load the specified file
  57385. */
  57386. canLoad(extension: string): boolean;
  57387. /**
  57388. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57389. * @param data contains the texture data
  57390. * @param texture defines the BabylonJS internal texture
  57391. * @param createPolynomials will be true if polynomials have been requested
  57392. * @param onLoad defines the callback to trigger once the texture is ready
  57393. * @param onError defines the callback to trigger in case of error
  57394. */
  57395. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57396. /**
  57397. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57398. * @param data contains the texture data
  57399. * @param texture defines the BabylonJS internal texture
  57400. * @param callback defines the method to call once ready to upload
  57401. */
  57402. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57403. }
  57404. }
  57405. declare module BABYLON {
  57406. /**
  57407. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  57408. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  57409. */
  57410. export class KhronosTextureContainer {
  57411. /** contents of the KTX container file */
  57412. data: ArrayBufferView;
  57413. private static HEADER_LEN;
  57414. private static COMPRESSED_2D;
  57415. private static COMPRESSED_3D;
  57416. private static TEX_2D;
  57417. private static TEX_3D;
  57418. /**
  57419. * Gets the openGL type
  57420. */
  57421. glType: number;
  57422. /**
  57423. * Gets the openGL type size
  57424. */
  57425. glTypeSize: number;
  57426. /**
  57427. * Gets the openGL format
  57428. */
  57429. glFormat: number;
  57430. /**
  57431. * Gets the openGL internal format
  57432. */
  57433. glInternalFormat: number;
  57434. /**
  57435. * Gets the base internal format
  57436. */
  57437. glBaseInternalFormat: number;
  57438. /**
  57439. * Gets image width in pixel
  57440. */
  57441. pixelWidth: number;
  57442. /**
  57443. * Gets image height in pixel
  57444. */
  57445. pixelHeight: number;
  57446. /**
  57447. * Gets image depth in pixels
  57448. */
  57449. pixelDepth: number;
  57450. /**
  57451. * Gets the number of array elements
  57452. */
  57453. numberOfArrayElements: number;
  57454. /**
  57455. * Gets the number of faces
  57456. */
  57457. numberOfFaces: number;
  57458. /**
  57459. * Gets the number of mipmap levels
  57460. */
  57461. numberOfMipmapLevels: number;
  57462. /**
  57463. * Gets the bytes of key value data
  57464. */
  57465. bytesOfKeyValueData: number;
  57466. /**
  57467. * Gets the load type
  57468. */
  57469. loadType: number;
  57470. /**
  57471. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  57472. */
  57473. isInvalid: boolean;
  57474. /**
  57475. * Creates a new KhronosTextureContainer
  57476. * @param data contents of the KTX container file
  57477. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  57478. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  57479. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  57480. */
  57481. constructor(
  57482. /** contents of the KTX container file */
  57483. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  57484. /**
  57485. * Uploads KTX content to a Babylon Texture.
  57486. * It is assumed that the texture has already been created & is currently bound
  57487. * @hidden
  57488. */
  57489. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  57490. private _upload2DCompressedLevels;
  57491. /**
  57492. * Checks if the given data starts with a KTX file identifier.
  57493. * @param data the data to check
  57494. * @returns true if the data is a KTX file or false otherwise
  57495. */
  57496. static IsValid(data: ArrayBufferView): boolean;
  57497. }
  57498. }
  57499. declare module BABYLON {
  57500. /**
  57501. * Class for loading KTX2 files
  57502. * !!! Experimental Extension Subject to Changes !!!
  57503. * @hidden
  57504. */
  57505. export class KhronosTextureContainer2 {
  57506. private static _ModulePromise;
  57507. private static _TranscodeFormat;
  57508. constructor(engine: ThinEngine);
  57509. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  57510. private _determineTranscodeFormat;
  57511. /**
  57512. * Checks if the given data starts with a KTX2 file identifier.
  57513. * @param data the data to check
  57514. * @returns true if the data is a KTX2 file or false otherwise
  57515. */
  57516. static IsValid(data: ArrayBufferView): boolean;
  57517. }
  57518. }
  57519. declare module BABYLON {
  57520. /**
  57521. * Implementation of the KTX Texture Loader.
  57522. * @hidden
  57523. */
  57524. export class _KTXTextureLoader implements IInternalTextureLoader {
  57525. /**
  57526. * Defines wether the loader supports cascade loading the different faces.
  57527. */
  57528. readonly supportCascades: boolean;
  57529. /**
  57530. * This returns if the loader support the current file information.
  57531. * @param extension defines the file extension of the file being loaded
  57532. * @param mimeType defines the optional mime type of the file being loaded
  57533. * @returns true if the loader can load the specified file
  57534. */
  57535. canLoad(extension: string, mimeType?: string): boolean;
  57536. /**
  57537. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57538. * @param data contains the texture data
  57539. * @param texture defines the BabylonJS internal texture
  57540. * @param createPolynomials will be true if polynomials have been requested
  57541. * @param onLoad defines the callback to trigger once the texture is ready
  57542. * @param onError defines the callback to trigger in case of error
  57543. */
  57544. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57545. /**
  57546. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57547. * @param data contains the texture data
  57548. * @param texture defines the BabylonJS internal texture
  57549. * @param callback defines the method to call once ready to upload
  57550. */
  57551. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  57552. }
  57553. }
  57554. declare module BABYLON {
  57555. /** @hidden */
  57556. export var _forceSceneHelpersToBundle: boolean;
  57557. interface Scene {
  57558. /**
  57559. * Creates a default light for the scene.
  57560. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  57561. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  57562. */
  57563. createDefaultLight(replace?: boolean): void;
  57564. /**
  57565. * Creates a default camera for the scene.
  57566. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  57567. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57568. * @param replace has default false, when true replaces the active camera in the scene
  57569. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  57570. */
  57571. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57572. /**
  57573. * Creates a default camera and a default light.
  57574. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  57575. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57576. * @param replace has the default false, when true replaces the active camera/light in the scene
  57577. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  57578. */
  57579. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57580. /**
  57581. * Creates a new sky box
  57582. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  57583. * @param environmentTexture defines the texture to use as environment texture
  57584. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  57585. * @param scale defines the overall scale of the skybox
  57586. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  57587. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  57588. * @returns a new mesh holding the sky box
  57589. */
  57590. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  57591. /**
  57592. * Creates a new environment
  57593. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  57594. * @param options defines the options you can use to configure the environment
  57595. * @returns the new EnvironmentHelper
  57596. */
  57597. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  57598. /**
  57599. * Creates a new VREXperienceHelper
  57600. * @see https://doc.babylonjs.com/how_to/webvr_helper
  57601. * @param webVROptions defines the options used to create the new VREXperienceHelper
  57602. * @returns a new VREXperienceHelper
  57603. */
  57604. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  57605. /**
  57606. * Creates a new WebXRDefaultExperience
  57607. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  57608. * @param options experience options
  57609. * @returns a promise for a new WebXRDefaultExperience
  57610. */
  57611. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  57612. }
  57613. }
  57614. declare module BABYLON {
  57615. /**
  57616. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  57617. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  57618. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  57619. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57620. */
  57621. export class VideoDome extends TransformNode {
  57622. /**
  57623. * Define the video source as a Monoscopic panoramic 360 video.
  57624. */
  57625. static readonly MODE_MONOSCOPIC: number;
  57626. /**
  57627. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  57628. */
  57629. static readonly MODE_TOPBOTTOM: number;
  57630. /**
  57631. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  57632. */
  57633. static readonly MODE_SIDEBYSIDE: number;
  57634. private _halfDome;
  57635. private _useDirectMapping;
  57636. /**
  57637. * The video texture being displayed on the sphere
  57638. */
  57639. protected _videoTexture: VideoTexture;
  57640. /**
  57641. * Gets the video texture being displayed on the sphere
  57642. */
  57643. get videoTexture(): VideoTexture;
  57644. /**
  57645. * The skybox material
  57646. */
  57647. protected _material: BackgroundMaterial;
  57648. /**
  57649. * The surface used for the video dome
  57650. */
  57651. protected _mesh: Mesh;
  57652. /**
  57653. * Gets the mesh used for the video dome.
  57654. */
  57655. get mesh(): Mesh;
  57656. /**
  57657. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  57658. */
  57659. private _halfDomeMask;
  57660. /**
  57661. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57662. * Also see the options.resolution property.
  57663. */
  57664. get fovMultiplier(): number;
  57665. set fovMultiplier(value: number);
  57666. private _videoMode;
  57667. /**
  57668. * Gets or set the current video mode for the video. It can be:
  57669. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  57670. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  57671. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  57672. */
  57673. get videoMode(): number;
  57674. set videoMode(value: number);
  57675. /**
  57676. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  57677. *
  57678. */
  57679. get halfDome(): boolean;
  57680. /**
  57681. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  57682. */
  57683. set halfDome(enabled: boolean);
  57684. /**
  57685. * Oberserver used in Stereoscopic VR Mode.
  57686. */
  57687. private _onBeforeCameraRenderObserver;
  57688. /**
  57689. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  57690. * @param name Element's name, child elements will append suffixes for their own names.
  57691. * @param urlsOrVideo defines the url(s) or the video element to use
  57692. * @param options An object containing optional or exposed sub element properties
  57693. */
  57694. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  57695. resolution?: number;
  57696. clickToPlay?: boolean;
  57697. autoPlay?: boolean;
  57698. loop?: boolean;
  57699. size?: number;
  57700. poster?: string;
  57701. faceForward?: boolean;
  57702. useDirectMapping?: boolean;
  57703. halfDomeMode?: boolean;
  57704. }, scene: Scene);
  57705. private _changeVideoMode;
  57706. /**
  57707. * Releases resources associated with this node.
  57708. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57709. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57710. */
  57711. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57712. }
  57713. }
  57714. declare module BABYLON {
  57715. /**
  57716. * This class can be used to get instrumentation data from a Babylon engine
  57717. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  57718. */
  57719. export class EngineInstrumentation implements IDisposable {
  57720. /**
  57721. * Define the instrumented engine.
  57722. */
  57723. engine: Engine;
  57724. private _captureGPUFrameTime;
  57725. private _gpuFrameTimeToken;
  57726. private _gpuFrameTime;
  57727. private _captureShaderCompilationTime;
  57728. private _shaderCompilationTime;
  57729. private _onBeginFrameObserver;
  57730. private _onEndFrameObserver;
  57731. private _onBeforeShaderCompilationObserver;
  57732. private _onAfterShaderCompilationObserver;
  57733. /**
  57734. * Gets the perf counter used for GPU frame time
  57735. */
  57736. get gpuFrameTimeCounter(): PerfCounter;
  57737. /**
  57738. * Gets the GPU frame time capture status
  57739. */
  57740. get captureGPUFrameTime(): boolean;
  57741. /**
  57742. * Enable or disable the GPU frame time capture
  57743. */
  57744. set captureGPUFrameTime(value: boolean);
  57745. /**
  57746. * Gets the perf counter used for shader compilation time
  57747. */
  57748. get shaderCompilationTimeCounter(): PerfCounter;
  57749. /**
  57750. * Gets the shader compilation time capture status
  57751. */
  57752. get captureShaderCompilationTime(): boolean;
  57753. /**
  57754. * Enable or disable the shader compilation time capture
  57755. */
  57756. set captureShaderCompilationTime(value: boolean);
  57757. /**
  57758. * Instantiates a new engine instrumentation.
  57759. * This class can be used to get instrumentation data from a Babylon engine
  57760. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  57761. * @param engine Defines the engine to instrument
  57762. */
  57763. constructor(
  57764. /**
  57765. * Define the instrumented engine.
  57766. */
  57767. engine: Engine);
  57768. /**
  57769. * Dispose and release associated resources.
  57770. */
  57771. dispose(): void;
  57772. }
  57773. }
  57774. declare module BABYLON {
  57775. /**
  57776. * This class can be used to get instrumentation data from a Babylon engine
  57777. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  57778. */
  57779. export class SceneInstrumentation implements IDisposable {
  57780. /**
  57781. * Defines the scene to instrument
  57782. */
  57783. scene: Scene;
  57784. private _captureActiveMeshesEvaluationTime;
  57785. private _activeMeshesEvaluationTime;
  57786. private _captureRenderTargetsRenderTime;
  57787. private _renderTargetsRenderTime;
  57788. private _captureFrameTime;
  57789. private _frameTime;
  57790. private _captureRenderTime;
  57791. private _renderTime;
  57792. private _captureInterFrameTime;
  57793. private _interFrameTime;
  57794. private _captureParticlesRenderTime;
  57795. private _particlesRenderTime;
  57796. private _captureSpritesRenderTime;
  57797. private _spritesRenderTime;
  57798. private _capturePhysicsTime;
  57799. private _physicsTime;
  57800. private _captureAnimationsTime;
  57801. private _animationsTime;
  57802. private _captureCameraRenderTime;
  57803. private _cameraRenderTime;
  57804. private _onBeforeActiveMeshesEvaluationObserver;
  57805. private _onAfterActiveMeshesEvaluationObserver;
  57806. private _onBeforeRenderTargetsRenderObserver;
  57807. private _onAfterRenderTargetsRenderObserver;
  57808. private _onAfterRenderObserver;
  57809. private _onBeforeDrawPhaseObserver;
  57810. private _onAfterDrawPhaseObserver;
  57811. private _onBeforeAnimationsObserver;
  57812. private _onBeforeParticlesRenderingObserver;
  57813. private _onAfterParticlesRenderingObserver;
  57814. private _onBeforeSpritesRenderingObserver;
  57815. private _onAfterSpritesRenderingObserver;
  57816. private _onBeforePhysicsObserver;
  57817. private _onAfterPhysicsObserver;
  57818. private _onAfterAnimationsObserver;
  57819. private _onBeforeCameraRenderObserver;
  57820. private _onAfterCameraRenderObserver;
  57821. /**
  57822. * Gets the perf counter used for active meshes evaluation time
  57823. */
  57824. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  57825. /**
  57826. * Gets the active meshes evaluation time capture status
  57827. */
  57828. get captureActiveMeshesEvaluationTime(): boolean;
  57829. /**
  57830. * Enable or disable the active meshes evaluation time capture
  57831. */
  57832. set captureActiveMeshesEvaluationTime(value: boolean);
  57833. /**
  57834. * Gets the perf counter used for render targets render time
  57835. */
  57836. get renderTargetsRenderTimeCounter(): PerfCounter;
  57837. /**
  57838. * Gets the render targets render time capture status
  57839. */
  57840. get captureRenderTargetsRenderTime(): boolean;
  57841. /**
  57842. * Enable or disable the render targets render time capture
  57843. */
  57844. set captureRenderTargetsRenderTime(value: boolean);
  57845. /**
  57846. * Gets the perf counter used for particles render time
  57847. */
  57848. get particlesRenderTimeCounter(): PerfCounter;
  57849. /**
  57850. * Gets the particles render time capture status
  57851. */
  57852. get captureParticlesRenderTime(): boolean;
  57853. /**
  57854. * Enable or disable the particles render time capture
  57855. */
  57856. set captureParticlesRenderTime(value: boolean);
  57857. /**
  57858. * Gets the perf counter used for sprites render time
  57859. */
  57860. get spritesRenderTimeCounter(): PerfCounter;
  57861. /**
  57862. * Gets the sprites render time capture status
  57863. */
  57864. get captureSpritesRenderTime(): boolean;
  57865. /**
  57866. * Enable or disable the sprites render time capture
  57867. */
  57868. set captureSpritesRenderTime(value: boolean);
  57869. /**
  57870. * Gets the perf counter used for physics time
  57871. */
  57872. get physicsTimeCounter(): PerfCounter;
  57873. /**
  57874. * Gets the physics time capture status
  57875. */
  57876. get capturePhysicsTime(): boolean;
  57877. /**
  57878. * Enable or disable the physics time capture
  57879. */
  57880. set capturePhysicsTime(value: boolean);
  57881. /**
  57882. * Gets the perf counter used for animations time
  57883. */
  57884. get animationsTimeCounter(): PerfCounter;
  57885. /**
  57886. * Gets the animations time capture status
  57887. */
  57888. get captureAnimationsTime(): boolean;
  57889. /**
  57890. * Enable or disable the animations time capture
  57891. */
  57892. set captureAnimationsTime(value: boolean);
  57893. /**
  57894. * Gets the perf counter used for frame time capture
  57895. */
  57896. get frameTimeCounter(): PerfCounter;
  57897. /**
  57898. * Gets the frame time capture status
  57899. */
  57900. get captureFrameTime(): boolean;
  57901. /**
  57902. * Enable or disable the frame time capture
  57903. */
  57904. set captureFrameTime(value: boolean);
  57905. /**
  57906. * Gets the perf counter used for inter-frames time capture
  57907. */
  57908. get interFrameTimeCounter(): PerfCounter;
  57909. /**
  57910. * Gets the inter-frames time capture status
  57911. */
  57912. get captureInterFrameTime(): boolean;
  57913. /**
  57914. * Enable or disable the inter-frames time capture
  57915. */
  57916. set captureInterFrameTime(value: boolean);
  57917. /**
  57918. * Gets the perf counter used for render time capture
  57919. */
  57920. get renderTimeCounter(): PerfCounter;
  57921. /**
  57922. * Gets the render time capture status
  57923. */
  57924. get captureRenderTime(): boolean;
  57925. /**
  57926. * Enable or disable the render time capture
  57927. */
  57928. set captureRenderTime(value: boolean);
  57929. /**
  57930. * Gets the perf counter used for camera render time capture
  57931. */
  57932. get cameraRenderTimeCounter(): PerfCounter;
  57933. /**
  57934. * Gets the camera render time capture status
  57935. */
  57936. get captureCameraRenderTime(): boolean;
  57937. /**
  57938. * Enable or disable the camera render time capture
  57939. */
  57940. set captureCameraRenderTime(value: boolean);
  57941. /**
  57942. * Gets the perf counter used for draw calls
  57943. */
  57944. get drawCallsCounter(): PerfCounter;
  57945. /**
  57946. * Instantiates a new scene instrumentation.
  57947. * This class can be used to get instrumentation data from a Babylon engine
  57948. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  57949. * @param scene Defines the scene to instrument
  57950. */
  57951. constructor(
  57952. /**
  57953. * Defines the scene to instrument
  57954. */
  57955. scene: Scene);
  57956. /**
  57957. * Dispose and release associated resources.
  57958. */
  57959. dispose(): void;
  57960. }
  57961. }
  57962. declare module BABYLON {
  57963. /** @hidden */
  57964. export var glowMapGenerationPixelShader: {
  57965. name: string;
  57966. shader: string;
  57967. };
  57968. }
  57969. declare module BABYLON {
  57970. /** @hidden */
  57971. export var glowMapGenerationVertexShader: {
  57972. name: string;
  57973. shader: string;
  57974. };
  57975. }
  57976. declare module BABYLON {
  57977. /**
  57978. * Effect layer options. This helps customizing the behaviour
  57979. * of the effect layer.
  57980. */
  57981. export interface IEffectLayerOptions {
  57982. /**
  57983. * Multiplication factor apply to the canvas size to compute the render target size
  57984. * used to generated the objects (the smaller the faster).
  57985. */
  57986. mainTextureRatio: number;
  57987. /**
  57988. * Enforces a fixed size texture to ensure effect stability across devices.
  57989. */
  57990. mainTextureFixedSize?: number;
  57991. /**
  57992. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  57993. */
  57994. alphaBlendingMode: number;
  57995. /**
  57996. * The camera attached to the layer.
  57997. */
  57998. camera: Nullable<Camera>;
  57999. /**
  58000. * The rendering group to draw the layer in.
  58001. */
  58002. renderingGroupId: number;
  58003. }
  58004. /**
  58005. * The effect layer Helps adding post process effect blended with the main pass.
  58006. *
  58007. * This can be for instance use to generate glow or higlight effects on the scene.
  58008. *
  58009. * The effect layer class can not be used directly and is intented to inherited from to be
  58010. * customized per effects.
  58011. */
  58012. export abstract class EffectLayer {
  58013. private _vertexBuffers;
  58014. private _indexBuffer;
  58015. private _cachedDefines;
  58016. private _effectLayerMapGenerationEffect;
  58017. private _effectLayerOptions;
  58018. private _mergeEffect;
  58019. protected _scene: Scene;
  58020. protected _engine: Engine;
  58021. protected _maxSize: number;
  58022. protected _mainTextureDesiredSize: ISize;
  58023. protected _mainTexture: RenderTargetTexture;
  58024. protected _shouldRender: boolean;
  58025. protected _postProcesses: PostProcess[];
  58026. protected _textures: BaseTexture[];
  58027. protected _emissiveTextureAndColor: {
  58028. texture: Nullable<BaseTexture>;
  58029. color: Color4;
  58030. };
  58031. /**
  58032. * The name of the layer
  58033. */
  58034. name: string;
  58035. /**
  58036. * The clear color of the texture used to generate the glow map.
  58037. */
  58038. neutralColor: Color4;
  58039. /**
  58040. * Specifies whether the highlight layer is enabled or not.
  58041. */
  58042. isEnabled: boolean;
  58043. /**
  58044. * Gets the camera attached to the layer.
  58045. */
  58046. get camera(): Nullable<Camera>;
  58047. /**
  58048. * Gets the rendering group id the layer should render in.
  58049. */
  58050. get renderingGroupId(): number;
  58051. set renderingGroupId(renderingGroupId: number);
  58052. /**
  58053. * An event triggered when the effect layer has been disposed.
  58054. */
  58055. onDisposeObservable: Observable<EffectLayer>;
  58056. /**
  58057. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  58058. */
  58059. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  58060. /**
  58061. * An event triggered when the generated texture is being merged in the scene.
  58062. */
  58063. onBeforeComposeObservable: Observable<EffectLayer>;
  58064. /**
  58065. * An event triggered when the mesh is rendered into the effect render target.
  58066. */
  58067. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  58068. /**
  58069. * An event triggered after the mesh has been rendered into the effect render target.
  58070. */
  58071. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  58072. /**
  58073. * An event triggered when the generated texture has been merged in the scene.
  58074. */
  58075. onAfterComposeObservable: Observable<EffectLayer>;
  58076. /**
  58077. * An event triggered when the efffect layer changes its size.
  58078. */
  58079. onSizeChangedObservable: Observable<EffectLayer>;
  58080. /** @hidden */
  58081. static _SceneComponentInitialization: (scene: Scene) => void;
  58082. /**
  58083. * Instantiates a new effect Layer and references it in the scene.
  58084. * @param name The name of the layer
  58085. * @param scene The scene to use the layer in
  58086. */
  58087. constructor(
  58088. /** The Friendly of the effect in the scene */
  58089. name: string, scene: Scene);
  58090. /**
  58091. * Get the effect name of the layer.
  58092. * @return The effect name
  58093. */
  58094. abstract getEffectName(): string;
  58095. /**
  58096. * Checks for the readiness of the element composing the layer.
  58097. * @param subMesh the mesh to check for
  58098. * @param useInstances specify whether or not to use instances to render the mesh
  58099. * @return true if ready otherwise, false
  58100. */
  58101. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58102. /**
  58103. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58104. * @returns true if the effect requires stencil during the main canvas render pass.
  58105. */
  58106. abstract needStencil(): boolean;
  58107. /**
  58108. * Create the merge effect. This is the shader use to blit the information back
  58109. * to the main canvas at the end of the scene rendering.
  58110. * @returns The effect containing the shader used to merge the effect on the main canvas
  58111. */
  58112. protected abstract _createMergeEffect(): Effect;
  58113. /**
  58114. * Creates the render target textures and post processes used in the effect layer.
  58115. */
  58116. protected abstract _createTextureAndPostProcesses(): void;
  58117. /**
  58118. * Implementation specific of rendering the generating effect on the main canvas.
  58119. * @param effect The effect used to render through
  58120. */
  58121. protected abstract _internalRender(effect: Effect): void;
  58122. /**
  58123. * Sets the required values for both the emissive texture and and the main color.
  58124. */
  58125. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58126. /**
  58127. * Free any resources and references associated to a mesh.
  58128. * Internal use
  58129. * @param mesh The mesh to free.
  58130. */
  58131. abstract _disposeMesh(mesh: Mesh): void;
  58132. /**
  58133. * Serializes this layer (Glow or Highlight for example)
  58134. * @returns a serialized layer object
  58135. */
  58136. abstract serialize?(): any;
  58137. /**
  58138. * Initializes the effect layer with the required options.
  58139. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  58140. */
  58141. protected _init(options: Partial<IEffectLayerOptions>): void;
  58142. /**
  58143. * Generates the index buffer of the full screen quad blending to the main canvas.
  58144. */
  58145. private _generateIndexBuffer;
  58146. /**
  58147. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  58148. */
  58149. private _generateVertexBuffer;
  58150. /**
  58151. * Sets the main texture desired size which is the closest power of two
  58152. * of the engine canvas size.
  58153. */
  58154. private _setMainTextureSize;
  58155. /**
  58156. * Creates the main texture for the effect layer.
  58157. */
  58158. protected _createMainTexture(): void;
  58159. /**
  58160. * Adds specific effects defines.
  58161. * @param defines The defines to add specifics to.
  58162. */
  58163. protected _addCustomEffectDefines(defines: string[]): void;
  58164. /**
  58165. * Checks for the readiness of the element composing the layer.
  58166. * @param subMesh the mesh to check for
  58167. * @param useInstances specify whether or not to use instances to render the mesh
  58168. * @param emissiveTexture the associated emissive texture used to generate the glow
  58169. * @return true if ready otherwise, false
  58170. */
  58171. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  58172. /**
  58173. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  58174. */
  58175. render(): void;
  58176. /**
  58177. * Determine if a given mesh will be used in the current effect.
  58178. * @param mesh mesh to test
  58179. * @returns true if the mesh will be used
  58180. */
  58181. hasMesh(mesh: AbstractMesh): boolean;
  58182. /**
  58183. * Returns true if the layer contains information to display, otherwise false.
  58184. * @returns true if the glow layer should be rendered
  58185. */
  58186. shouldRender(): boolean;
  58187. /**
  58188. * Returns true if the mesh should render, otherwise false.
  58189. * @param mesh The mesh to render
  58190. * @returns true if it should render otherwise false
  58191. */
  58192. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  58193. /**
  58194. * Returns true if the mesh can be rendered, otherwise false.
  58195. * @param mesh The mesh to render
  58196. * @param material The material used on the mesh
  58197. * @returns true if it can be rendered otherwise false
  58198. */
  58199. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58200. /**
  58201. * Returns true if the mesh should render, otherwise false.
  58202. * @param mesh The mesh to render
  58203. * @returns true if it should render otherwise false
  58204. */
  58205. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  58206. /**
  58207. * Renders the submesh passed in parameter to the generation map.
  58208. */
  58209. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  58210. /**
  58211. * Defines whether the current material of the mesh should be use to render the effect.
  58212. * @param mesh defines the current mesh to render
  58213. */
  58214. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58215. /**
  58216. * Rebuild the required buffers.
  58217. * @hidden Internal use only.
  58218. */
  58219. _rebuild(): void;
  58220. /**
  58221. * Dispose only the render target textures and post process.
  58222. */
  58223. private _disposeTextureAndPostProcesses;
  58224. /**
  58225. * Dispose the highlight layer and free resources.
  58226. */
  58227. dispose(): void;
  58228. /**
  58229. * Gets the class name of the effect layer
  58230. * @returns the string with the class name of the effect layer
  58231. */
  58232. getClassName(): string;
  58233. /**
  58234. * Creates an effect layer from parsed effect layer data
  58235. * @param parsedEffectLayer defines effect layer data
  58236. * @param scene defines the current scene
  58237. * @param rootUrl defines the root URL containing the effect layer information
  58238. * @returns a parsed effect Layer
  58239. */
  58240. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  58241. }
  58242. }
  58243. declare module BABYLON {
  58244. interface AbstractScene {
  58245. /**
  58246. * The list of effect layers (highlights/glow) added to the scene
  58247. * @see https://doc.babylonjs.com/how_to/highlight_layer
  58248. * @see https://doc.babylonjs.com/how_to/glow_layer
  58249. */
  58250. effectLayers: Array<EffectLayer>;
  58251. /**
  58252. * Removes the given effect layer from this scene.
  58253. * @param toRemove defines the effect layer to remove
  58254. * @returns the index of the removed effect layer
  58255. */
  58256. removeEffectLayer(toRemove: EffectLayer): number;
  58257. /**
  58258. * Adds the given effect layer to this scene
  58259. * @param newEffectLayer defines the effect layer to add
  58260. */
  58261. addEffectLayer(newEffectLayer: EffectLayer): void;
  58262. }
  58263. /**
  58264. * Defines the layer scene component responsible to manage any effect layers
  58265. * in a given scene.
  58266. */
  58267. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  58268. /**
  58269. * The component name helpfull to identify the component in the list of scene components.
  58270. */
  58271. readonly name: string;
  58272. /**
  58273. * The scene the component belongs to.
  58274. */
  58275. scene: Scene;
  58276. private _engine;
  58277. private _renderEffects;
  58278. private _needStencil;
  58279. private _previousStencilState;
  58280. /**
  58281. * Creates a new instance of the component for the given scene
  58282. * @param scene Defines the scene to register the component in
  58283. */
  58284. constructor(scene: Scene);
  58285. /**
  58286. * Registers the component in a given scene
  58287. */
  58288. register(): void;
  58289. /**
  58290. * Rebuilds the elements related to this component in case of
  58291. * context lost for instance.
  58292. */
  58293. rebuild(): void;
  58294. /**
  58295. * Serializes the component data to the specified json object
  58296. * @param serializationObject The object to serialize to
  58297. */
  58298. serialize(serializationObject: any): void;
  58299. /**
  58300. * Adds all the elements from the container to the scene
  58301. * @param container the container holding the elements
  58302. */
  58303. addFromContainer(container: AbstractScene): void;
  58304. /**
  58305. * Removes all the elements in the container from the scene
  58306. * @param container contains the elements to remove
  58307. * @param dispose if the removed element should be disposed (default: false)
  58308. */
  58309. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58310. /**
  58311. * Disposes the component and the associated ressources.
  58312. */
  58313. dispose(): void;
  58314. private _isReadyForMesh;
  58315. private _renderMainTexture;
  58316. private _setStencil;
  58317. private _setStencilBack;
  58318. private _draw;
  58319. private _drawCamera;
  58320. private _drawRenderingGroup;
  58321. }
  58322. }
  58323. declare module BABYLON {
  58324. /** @hidden */
  58325. export var glowMapMergePixelShader: {
  58326. name: string;
  58327. shader: string;
  58328. };
  58329. }
  58330. declare module BABYLON {
  58331. /** @hidden */
  58332. export var glowMapMergeVertexShader: {
  58333. name: string;
  58334. shader: string;
  58335. };
  58336. }
  58337. declare module BABYLON {
  58338. interface AbstractScene {
  58339. /**
  58340. * Return a the first highlight layer of the scene with a given name.
  58341. * @param name The name of the highlight layer to look for.
  58342. * @return The highlight layer if found otherwise null.
  58343. */
  58344. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  58345. }
  58346. /**
  58347. * Glow layer options. This helps customizing the behaviour
  58348. * of the glow layer.
  58349. */
  58350. export interface IGlowLayerOptions {
  58351. /**
  58352. * Multiplication factor apply to the canvas size to compute the render target size
  58353. * used to generated the glowing objects (the smaller the faster).
  58354. */
  58355. mainTextureRatio: number;
  58356. /**
  58357. * Enforces a fixed size texture to ensure resize independant blur.
  58358. */
  58359. mainTextureFixedSize?: number;
  58360. /**
  58361. * How big is the kernel of the blur texture.
  58362. */
  58363. blurKernelSize: number;
  58364. /**
  58365. * The camera attached to the layer.
  58366. */
  58367. camera: Nullable<Camera>;
  58368. /**
  58369. * Enable MSAA by chosing the number of samples.
  58370. */
  58371. mainTextureSamples?: number;
  58372. /**
  58373. * The rendering group to draw the layer in.
  58374. */
  58375. renderingGroupId: number;
  58376. }
  58377. /**
  58378. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  58379. *
  58380. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  58381. *
  58382. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  58383. */
  58384. export class GlowLayer extends EffectLayer {
  58385. /**
  58386. * Effect Name of the layer.
  58387. */
  58388. static readonly EffectName: string;
  58389. /**
  58390. * The default blur kernel size used for the glow.
  58391. */
  58392. static DefaultBlurKernelSize: number;
  58393. /**
  58394. * The default texture size ratio used for the glow.
  58395. */
  58396. static DefaultTextureRatio: number;
  58397. /**
  58398. * Sets the kernel size of the blur.
  58399. */
  58400. set blurKernelSize(value: number);
  58401. /**
  58402. * Gets the kernel size of the blur.
  58403. */
  58404. get blurKernelSize(): number;
  58405. /**
  58406. * Sets the glow intensity.
  58407. */
  58408. set intensity(value: number);
  58409. /**
  58410. * Gets the glow intensity.
  58411. */
  58412. get intensity(): number;
  58413. private _options;
  58414. private _intensity;
  58415. private _horizontalBlurPostprocess1;
  58416. private _verticalBlurPostprocess1;
  58417. private _horizontalBlurPostprocess2;
  58418. private _verticalBlurPostprocess2;
  58419. private _blurTexture1;
  58420. private _blurTexture2;
  58421. private _postProcesses1;
  58422. private _postProcesses2;
  58423. private _includedOnlyMeshes;
  58424. private _excludedMeshes;
  58425. private _meshesUsingTheirOwnMaterials;
  58426. /**
  58427. * Callback used to let the user override the color selection on a per mesh basis
  58428. */
  58429. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  58430. /**
  58431. * Callback used to let the user override the texture selection on a per mesh basis
  58432. */
  58433. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  58434. /**
  58435. * Instantiates a new glow Layer and references it to the scene.
  58436. * @param name The name of the layer
  58437. * @param scene The scene to use the layer in
  58438. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  58439. */
  58440. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  58441. /**
  58442. * Get the effect name of the layer.
  58443. * @return The effect name
  58444. */
  58445. getEffectName(): string;
  58446. /**
  58447. * Create the merge effect. This is the shader use to blit the information back
  58448. * to the main canvas at the end of the scene rendering.
  58449. */
  58450. protected _createMergeEffect(): Effect;
  58451. /**
  58452. * Creates the render target textures and post processes used in the glow layer.
  58453. */
  58454. protected _createTextureAndPostProcesses(): void;
  58455. /**
  58456. * Checks for the readiness of the element composing the layer.
  58457. * @param subMesh the mesh to check for
  58458. * @param useInstances specify wether or not to use instances to render the mesh
  58459. * @param emissiveTexture the associated emissive texture used to generate the glow
  58460. * @return true if ready otherwise, false
  58461. */
  58462. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58463. /**
  58464. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58465. */
  58466. needStencil(): boolean;
  58467. /**
  58468. * Returns true if the mesh can be rendered, otherwise false.
  58469. * @param mesh The mesh to render
  58470. * @param material The material used on the mesh
  58471. * @returns true if it can be rendered otherwise false
  58472. */
  58473. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58474. /**
  58475. * Implementation specific of rendering the generating effect on the main canvas.
  58476. * @param effect The effect used to render through
  58477. */
  58478. protected _internalRender(effect: Effect): void;
  58479. /**
  58480. * Sets the required values for both the emissive texture and and the main color.
  58481. */
  58482. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58483. /**
  58484. * Returns true if the mesh should render, otherwise false.
  58485. * @param mesh The mesh to render
  58486. * @returns true if it should render otherwise false
  58487. */
  58488. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58489. /**
  58490. * Adds specific effects defines.
  58491. * @param defines The defines to add specifics to.
  58492. */
  58493. protected _addCustomEffectDefines(defines: string[]): void;
  58494. /**
  58495. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  58496. * @param mesh The mesh to exclude from the glow layer
  58497. */
  58498. addExcludedMesh(mesh: Mesh): void;
  58499. /**
  58500. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  58501. * @param mesh The mesh to remove
  58502. */
  58503. removeExcludedMesh(mesh: Mesh): void;
  58504. /**
  58505. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  58506. * @param mesh The mesh to include in the glow layer
  58507. */
  58508. addIncludedOnlyMesh(mesh: Mesh): void;
  58509. /**
  58510. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  58511. * @param mesh The mesh to remove
  58512. */
  58513. removeIncludedOnlyMesh(mesh: Mesh): void;
  58514. /**
  58515. * Determine if a given mesh will be used in the glow layer
  58516. * @param mesh The mesh to test
  58517. * @returns true if the mesh will be highlighted by the current glow layer
  58518. */
  58519. hasMesh(mesh: AbstractMesh): boolean;
  58520. /**
  58521. * Defines whether the current material of the mesh should be use to render the effect.
  58522. * @param mesh defines the current mesh to render
  58523. */
  58524. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58525. /**
  58526. * Add a mesh to be rendered through its own material and not with emissive only.
  58527. * @param mesh The mesh for which we need to use its material
  58528. */
  58529. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  58530. /**
  58531. * Remove a mesh from being rendered through its own material and not with emissive only.
  58532. * @param mesh The mesh for which we need to not use its material
  58533. */
  58534. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  58535. /**
  58536. * Free any resources and references associated to a mesh.
  58537. * Internal use
  58538. * @param mesh The mesh to free.
  58539. * @hidden
  58540. */
  58541. _disposeMesh(mesh: Mesh): void;
  58542. /**
  58543. * Gets the class name of the effect layer
  58544. * @returns the string with the class name of the effect layer
  58545. */
  58546. getClassName(): string;
  58547. /**
  58548. * Serializes this glow layer
  58549. * @returns a serialized glow layer object
  58550. */
  58551. serialize(): any;
  58552. /**
  58553. * Creates a Glow Layer from parsed glow layer data
  58554. * @param parsedGlowLayer defines glow layer data
  58555. * @param scene defines the current scene
  58556. * @param rootUrl defines the root URL containing the glow layer information
  58557. * @returns a parsed Glow Layer
  58558. */
  58559. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  58560. }
  58561. }
  58562. declare module BABYLON {
  58563. /** @hidden */
  58564. export var glowBlurPostProcessPixelShader: {
  58565. name: string;
  58566. shader: string;
  58567. };
  58568. }
  58569. declare module BABYLON {
  58570. interface AbstractScene {
  58571. /**
  58572. * Return a the first highlight layer of the scene with a given name.
  58573. * @param name The name of the highlight layer to look for.
  58574. * @return The highlight layer if found otherwise null.
  58575. */
  58576. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  58577. }
  58578. /**
  58579. * Highlight layer options. This helps customizing the behaviour
  58580. * of the highlight layer.
  58581. */
  58582. export interface IHighlightLayerOptions {
  58583. /**
  58584. * Multiplication factor apply to the canvas size to compute the render target size
  58585. * used to generated the glowing objects (the smaller the faster).
  58586. */
  58587. mainTextureRatio: number;
  58588. /**
  58589. * Enforces a fixed size texture to ensure resize independant blur.
  58590. */
  58591. mainTextureFixedSize?: number;
  58592. /**
  58593. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  58594. * of the picture to blur (the smaller the faster).
  58595. */
  58596. blurTextureSizeRatio: number;
  58597. /**
  58598. * How big in texel of the blur texture is the vertical blur.
  58599. */
  58600. blurVerticalSize: number;
  58601. /**
  58602. * How big in texel of the blur texture is the horizontal blur.
  58603. */
  58604. blurHorizontalSize: number;
  58605. /**
  58606. * Alpha blending mode used to apply the blur. Default is combine.
  58607. */
  58608. alphaBlendingMode: number;
  58609. /**
  58610. * The camera attached to the layer.
  58611. */
  58612. camera: Nullable<Camera>;
  58613. /**
  58614. * Should we display highlight as a solid stroke?
  58615. */
  58616. isStroke?: boolean;
  58617. /**
  58618. * The rendering group to draw the layer in.
  58619. */
  58620. renderingGroupId: number;
  58621. }
  58622. /**
  58623. * The highlight layer Helps adding a glow effect around a mesh.
  58624. *
  58625. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  58626. * glowy meshes to your scene.
  58627. *
  58628. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  58629. */
  58630. export class HighlightLayer extends EffectLayer {
  58631. name: string;
  58632. /**
  58633. * Effect Name of the highlight layer.
  58634. */
  58635. static readonly EffectName: string;
  58636. /**
  58637. * The neutral color used during the preparation of the glow effect.
  58638. * This is black by default as the blend operation is a blend operation.
  58639. */
  58640. static NeutralColor: Color4;
  58641. /**
  58642. * Stencil value used for glowing meshes.
  58643. */
  58644. static GlowingMeshStencilReference: number;
  58645. /**
  58646. * Stencil value used for the other meshes in the scene.
  58647. */
  58648. static NormalMeshStencilReference: number;
  58649. /**
  58650. * Specifies whether or not the inner glow is ACTIVE in the layer.
  58651. */
  58652. innerGlow: boolean;
  58653. /**
  58654. * Specifies whether or not the outer glow is ACTIVE in the layer.
  58655. */
  58656. outerGlow: boolean;
  58657. /**
  58658. * Specifies the horizontal size of the blur.
  58659. */
  58660. set blurHorizontalSize(value: number);
  58661. /**
  58662. * Specifies the vertical size of the blur.
  58663. */
  58664. set blurVerticalSize(value: number);
  58665. /**
  58666. * Gets the horizontal size of the blur.
  58667. */
  58668. get blurHorizontalSize(): number;
  58669. /**
  58670. * Gets the vertical size of the blur.
  58671. */
  58672. get blurVerticalSize(): number;
  58673. /**
  58674. * An event triggered when the highlight layer is being blurred.
  58675. */
  58676. onBeforeBlurObservable: Observable<HighlightLayer>;
  58677. /**
  58678. * An event triggered when the highlight layer has been blurred.
  58679. */
  58680. onAfterBlurObservable: Observable<HighlightLayer>;
  58681. private _instanceGlowingMeshStencilReference;
  58682. private _options;
  58683. private _downSamplePostprocess;
  58684. private _horizontalBlurPostprocess;
  58685. private _verticalBlurPostprocess;
  58686. private _blurTexture;
  58687. private _meshes;
  58688. private _excludedMeshes;
  58689. /**
  58690. * Instantiates a new highlight Layer and references it to the scene..
  58691. * @param name The name of the layer
  58692. * @param scene The scene to use the layer in
  58693. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  58694. */
  58695. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  58696. /**
  58697. * Get the effect name of the layer.
  58698. * @return The effect name
  58699. */
  58700. getEffectName(): string;
  58701. /**
  58702. * Create the merge effect. This is the shader use to blit the information back
  58703. * to the main canvas at the end of the scene rendering.
  58704. */
  58705. protected _createMergeEffect(): Effect;
  58706. /**
  58707. * Creates the render target textures and post processes used in the highlight layer.
  58708. */
  58709. protected _createTextureAndPostProcesses(): void;
  58710. /**
  58711. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  58712. */
  58713. needStencil(): boolean;
  58714. /**
  58715. * Checks for the readiness of the element composing the layer.
  58716. * @param subMesh the mesh to check for
  58717. * @param useInstances specify wether or not to use instances to render the mesh
  58718. * @param emissiveTexture the associated emissive texture used to generate the glow
  58719. * @return true if ready otherwise, false
  58720. */
  58721. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58722. /**
  58723. * Implementation specific of rendering the generating effect on the main canvas.
  58724. * @param effect The effect used to render through
  58725. */
  58726. protected _internalRender(effect: Effect): void;
  58727. /**
  58728. * Returns true if the layer contains information to display, otherwise false.
  58729. */
  58730. shouldRender(): boolean;
  58731. /**
  58732. * Returns true if the mesh should render, otherwise false.
  58733. * @param mesh The mesh to render
  58734. * @returns true if it should render otherwise false
  58735. */
  58736. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58737. /**
  58738. * Returns true if the mesh can be rendered, otherwise false.
  58739. * @param mesh The mesh to render
  58740. * @param material The material used on the mesh
  58741. * @returns true if it can be rendered otherwise false
  58742. */
  58743. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58744. /**
  58745. * Adds specific effects defines.
  58746. * @param defines The defines to add specifics to.
  58747. */
  58748. protected _addCustomEffectDefines(defines: string[]): void;
  58749. /**
  58750. * Sets the required values for both the emissive texture and and the main color.
  58751. */
  58752. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58753. /**
  58754. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  58755. * @param mesh The mesh to exclude from the highlight layer
  58756. */
  58757. addExcludedMesh(mesh: Mesh): void;
  58758. /**
  58759. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  58760. * @param mesh The mesh to highlight
  58761. */
  58762. removeExcludedMesh(mesh: Mesh): void;
  58763. /**
  58764. * Determine if a given mesh will be highlighted by the current HighlightLayer
  58765. * @param mesh mesh to test
  58766. * @returns true if the mesh will be highlighted by the current HighlightLayer
  58767. */
  58768. hasMesh(mesh: AbstractMesh): boolean;
  58769. /**
  58770. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  58771. * @param mesh The mesh to highlight
  58772. * @param color The color of the highlight
  58773. * @param glowEmissiveOnly Extract the glow from the emissive texture
  58774. */
  58775. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  58776. /**
  58777. * Remove a mesh from the highlight layer in order to make it stop glowing.
  58778. * @param mesh The mesh to highlight
  58779. */
  58780. removeMesh(mesh: Mesh): void;
  58781. /**
  58782. * Remove all the meshes currently referenced in the highlight layer
  58783. */
  58784. removeAllMeshes(): void;
  58785. /**
  58786. * Force the stencil to the normal expected value for none glowing parts
  58787. */
  58788. private _defaultStencilReference;
  58789. /**
  58790. * Free any resources and references associated to a mesh.
  58791. * Internal use
  58792. * @param mesh The mesh to free.
  58793. * @hidden
  58794. */
  58795. _disposeMesh(mesh: Mesh): void;
  58796. /**
  58797. * Dispose the highlight layer and free resources.
  58798. */
  58799. dispose(): void;
  58800. /**
  58801. * Gets the class name of the effect layer
  58802. * @returns the string with the class name of the effect layer
  58803. */
  58804. getClassName(): string;
  58805. /**
  58806. * Serializes this Highlight layer
  58807. * @returns a serialized Highlight layer object
  58808. */
  58809. serialize(): any;
  58810. /**
  58811. * Creates a Highlight layer from parsed Highlight layer data
  58812. * @param parsedHightlightLayer defines the Highlight layer data
  58813. * @param scene defines the current scene
  58814. * @param rootUrl defines the root URL containing the Highlight layer information
  58815. * @returns a parsed Highlight layer
  58816. */
  58817. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  58818. }
  58819. }
  58820. declare module BABYLON {
  58821. interface AbstractScene {
  58822. /**
  58823. * The list of layers (background and foreground) of the scene
  58824. */
  58825. layers: Array<Layer>;
  58826. }
  58827. /**
  58828. * Defines the layer scene component responsible to manage any layers
  58829. * in a given scene.
  58830. */
  58831. export class LayerSceneComponent implements ISceneComponent {
  58832. /**
  58833. * The component name helpfull to identify the component in the list of scene components.
  58834. */
  58835. readonly name: string;
  58836. /**
  58837. * The scene the component belongs to.
  58838. */
  58839. scene: Scene;
  58840. private _engine;
  58841. /**
  58842. * Creates a new instance of the component for the given scene
  58843. * @param scene Defines the scene to register the component in
  58844. */
  58845. constructor(scene: Scene);
  58846. /**
  58847. * Registers the component in a given scene
  58848. */
  58849. register(): void;
  58850. /**
  58851. * Rebuilds the elements related to this component in case of
  58852. * context lost for instance.
  58853. */
  58854. rebuild(): void;
  58855. /**
  58856. * Disposes the component and the associated ressources.
  58857. */
  58858. dispose(): void;
  58859. private _draw;
  58860. private _drawCameraPredicate;
  58861. private _drawCameraBackground;
  58862. private _drawCameraForeground;
  58863. private _drawRenderTargetPredicate;
  58864. private _drawRenderTargetBackground;
  58865. private _drawRenderTargetForeground;
  58866. /**
  58867. * Adds all the elements from the container to the scene
  58868. * @param container the container holding the elements
  58869. */
  58870. addFromContainer(container: AbstractScene): void;
  58871. /**
  58872. * Removes all the elements in the container from the scene
  58873. * @param container contains the elements to remove
  58874. * @param dispose if the removed element should be disposed (default: false)
  58875. */
  58876. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58877. }
  58878. }
  58879. declare module BABYLON {
  58880. /** @hidden */
  58881. export var layerPixelShader: {
  58882. name: string;
  58883. shader: string;
  58884. };
  58885. }
  58886. declare module BABYLON {
  58887. /** @hidden */
  58888. export var layerVertexShader: {
  58889. name: string;
  58890. shader: string;
  58891. };
  58892. }
  58893. declare module BABYLON {
  58894. /**
  58895. * This represents a full screen 2d layer.
  58896. * This can be useful to display a picture in the background of your scene for instance.
  58897. * @see https://www.babylonjs-playground.com/#08A2BS#1
  58898. */
  58899. export class Layer {
  58900. /**
  58901. * Define the name of the layer.
  58902. */
  58903. name: string;
  58904. /**
  58905. * Define the texture the layer should display.
  58906. */
  58907. texture: Nullable<Texture>;
  58908. /**
  58909. * Is the layer in background or foreground.
  58910. */
  58911. isBackground: boolean;
  58912. /**
  58913. * Define the color of the layer (instead of texture).
  58914. */
  58915. color: Color4;
  58916. /**
  58917. * Define the scale of the layer in order to zoom in out of the texture.
  58918. */
  58919. scale: Vector2;
  58920. /**
  58921. * Define an offset for the layer in order to shift the texture.
  58922. */
  58923. offset: Vector2;
  58924. /**
  58925. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  58926. */
  58927. alphaBlendingMode: number;
  58928. /**
  58929. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  58930. * Alpha test will not mix with the background color in case of transparency.
  58931. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  58932. */
  58933. alphaTest: boolean;
  58934. /**
  58935. * Define a mask to restrict the layer to only some of the scene cameras.
  58936. */
  58937. layerMask: number;
  58938. /**
  58939. * Define the list of render target the layer is visible into.
  58940. */
  58941. renderTargetTextures: RenderTargetTexture[];
  58942. /**
  58943. * Define if the layer is only used in renderTarget or if it also
  58944. * renders in the main frame buffer of the canvas.
  58945. */
  58946. renderOnlyInRenderTargetTextures: boolean;
  58947. private _scene;
  58948. private _vertexBuffers;
  58949. private _indexBuffer;
  58950. private _effect;
  58951. private _previousDefines;
  58952. /**
  58953. * An event triggered when the layer is disposed.
  58954. */
  58955. onDisposeObservable: Observable<Layer>;
  58956. private _onDisposeObserver;
  58957. /**
  58958. * Back compatibility with callback before the onDisposeObservable existed.
  58959. * The set callback will be triggered when the layer has been disposed.
  58960. */
  58961. set onDispose(callback: () => void);
  58962. /**
  58963. * An event triggered before rendering the scene
  58964. */
  58965. onBeforeRenderObservable: Observable<Layer>;
  58966. private _onBeforeRenderObserver;
  58967. /**
  58968. * Back compatibility with callback before the onBeforeRenderObservable existed.
  58969. * The set callback will be triggered just before rendering the layer.
  58970. */
  58971. set onBeforeRender(callback: () => void);
  58972. /**
  58973. * An event triggered after rendering the scene
  58974. */
  58975. onAfterRenderObservable: Observable<Layer>;
  58976. private _onAfterRenderObserver;
  58977. /**
  58978. * Back compatibility with callback before the onAfterRenderObservable existed.
  58979. * The set callback will be triggered just after rendering the layer.
  58980. */
  58981. set onAfterRender(callback: () => void);
  58982. /**
  58983. * Instantiates a new layer.
  58984. * This represents a full screen 2d layer.
  58985. * This can be useful to display a picture in the background of your scene for instance.
  58986. * @see https://www.babylonjs-playground.com/#08A2BS#1
  58987. * @param name Define the name of the layer in the scene
  58988. * @param imgUrl Define the url of the texture to display in the layer
  58989. * @param scene Define the scene the layer belongs to
  58990. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  58991. * @param color Defines a color for the layer
  58992. */
  58993. constructor(
  58994. /**
  58995. * Define the name of the layer.
  58996. */
  58997. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  58998. private _createIndexBuffer;
  58999. /** @hidden */
  59000. _rebuild(): void;
  59001. /**
  59002. * Renders the layer in the scene.
  59003. */
  59004. render(): void;
  59005. /**
  59006. * Disposes and releases the associated ressources.
  59007. */
  59008. dispose(): void;
  59009. }
  59010. }
  59011. declare module BABYLON {
  59012. /** @hidden */
  59013. export var lensFlarePixelShader: {
  59014. name: string;
  59015. shader: string;
  59016. };
  59017. }
  59018. declare module BABYLON {
  59019. /** @hidden */
  59020. export var lensFlareVertexShader: {
  59021. name: string;
  59022. shader: string;
  59023. };
  59024. }
  59025. declare module BABYLON {
  59026. /**
  59027. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59028. * It is usually composed of several `lensFlare`.
  59029. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59030. */
  59031. export class LensFlareSystem {
  59032. /**
  59033. * Define the name of the lens flare system
  59034. */
  59035. name: string;
  59036. /**
  59037. * List of lens flares used in this system.
  59038. */
  59039. lensFlares: LensFlare[];
  59040. /**
  59041. * Define a limit from the border the lens flare can be visible.
  59042. */
  59043. borderLimit: number;
  59044. /**
  59045. * Define a viewport border we do not want to see the lens flare in.
  59046. */
  59047. viewportBorder: number;
  59048. /**
  59049. * Define a predicate which could limit the list of meshes able to occlude the effect.
  59050. */
  59051. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  59052. /**
  59053. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  59054. */
  59055. layerMask: number;
  59056. /**
  59057. * Define the id of the lens flare system in the scene.
  59058. * (equal to name by default)
  59059. */
  59060. id: string;
  59061. private _scene;
  59062. private _emitter;
  59063. private _vertexBuffers;
  59064. private _indexBuffer;
  59065. private _effect;
  59066. private _positionX;
  59067. private _positionY;
  59068. private _isEnabled;
  59069. /** @hidden */
  59070. static _SceneComponentInitialization: (scene: Scene) => void;
  59071. /**
  59072. * Instantiates a lens flare system.
  59073. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59074. * It is usually composed of several `lensFlare`.
  59075. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59076. * @param name Define the name of the lens flare system in the scene
  59077. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  59078. * @param scene Define the scene the lens flare system belongs to
  59079. */
  59080. constructor(
  59081. /**
  59082. * Define the name of the lens flare system
  59083. */
  59084. name: string, emitter: any, scene: Scene);
  59085. /**
  59086. * Define if the lens flare system is enabled.
  59087. */
  59088. get isEnabled(): boolean;
  59089. set isEnabled(value: boolean);
  59090. /**
  59091. * Get the scene the effects belongs to.
  59092. * @returns the scene holding the lens flare system
  59093. */
  59094. getScene(): Scene;
  59095. /**
  59096. * Get the emitter of the lens flare system.
  59097. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59098. * @returns the emitter of the lens flare system
  59099. */
  59100. getEmitter(): any;
  59101. /**
  59102. * Set the emitter of the lens flare system.
  59103. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59104. * @param newEmitter Define the new emitter of the system
  59105. */
  59106. setEmitter(newEmitter: any): void;
  59107. /**
  59108. * Get the lens flare system emitter position.
  59109. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  59110. * @returns the position
  59111. */
  59112. getEmitterPosition(): Vector3;
  59113. /**
  59114. * @hidden
  59115. */
  59116. computeEffectivePosition(globalViewport: Viewport): boolean;
  59117. /** @hidden */
  59118. _isVisible(): boolean;
  59119. /**
  59120. * @hidden
  59121. */
  59122. render(): boolean;
  59123. /**
  59124. * Dispose and release the lens flare with its associated resources.
  59125. */
  59126. dispose(): void;
  59127. /**
  59128. * Parse a lens flare system from a JSON repressentation
  59129. * @param parsedLensFlareSystem Define the JSON to parse
  59130. * @param scene Define the scene the parsed system should be instantiated in
  59131. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  59132. * @returns the parsed system
  59133. */
  59134. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  59135. /**
  59136. * Serialize the current Lens Flare System into a JSON representation.
  59137. * @returns the serialized JSON
  59138. */
  59139. serialize(): any;
  59140. }
  59141. }
  59142. declare module BABYLON {
  59143. /**
  59144. * This represents one of the lens effect in a `lensFlareSystem`.
  59145. * It controls one of the indiviual texture used in the effect.
  59146. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59147. */
  59148. export class LensFlare {
  59149. /**
  59150. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59151. */
  59152. size: number;
  59153. /**
  59154. * 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.
  59155. */
  59156. position: number;
  59157. /**
  59158. * Define the lens color.
  59159. */
  59160. color: Color3;
  59161. /**
  59162. * Define the lens texture.
  59163. */
  59164. texture: Nullable<Texture>;
  59165. /**
  59166. * Define the alpha mode to render this particular lens.
  59167. */
  59168. alphaMode: number;
  59169. private _system;
  59170. /**
  59171. * Creates a new Lens Flare.
  59172. * This represents one of the lens effect in a `lensFlareSystem`.
  59173. * It controls one of the indiviual texture used in the effect.
  59174. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59175. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  59176. * @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.
  59177. * @param color Define the lens color
  59178. * @param imgUrl Define the lens texture url
  59179. * @param system Define the `lensFlareSystem` this flare is part of
  59180. * @returns The newly created Lens Flare
  59181. */
  59182. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  59183. /**
  59184. * Instantiates a new Lens Flare.
  59185. * This represents one of the lens effect in a `lensFlareSystem`.
  59186. * It controls one of the indiviual texture used in the effect.
  59187. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59188. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  59189. * @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.
  59190. * @param color Define the lens color
  59191. * @param imgUrl Define the lens texture url
  59192. * @param system Define the `lensFlareSystem` this flare is part of
  59193. */
  59194. constructor(
  59195. /**
  59196. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59197. */
  59198. size: number,
  59199. /**
  59200. * 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.
  59201. */
  59202. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  59203. /**
  59204. * Dispose and release the lens flare with its associated resources.
  59205. */
  59206. dispose(): void;
  59207. }
  59208. }
  59209. declare module BABYLON {
  59210. interface AbstractScene {
  59211. /**
  59212. * The list of lens flare system added to the scene
  59213. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59214. */
  59215. lensFlareSystems: Array<LensFlareSystem>;
  59216. /**
  59217. * Removes the given lens flare system from this scene.
  59218. * @param toRemove The lens flare system to remove
  59219. * @returns The index of the removed lens flare system
  59220. */
  59221. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  59222. /**
  59223. * Adds the given lens flare system to this scene
  59224. * @param newLensFlareSystem The lens flare system to add
  59225. */
  59226. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  59227. /**
  59228. * Gets a lens flare system using its name
  59229. * @param name defines the name to look for
  59230. * @returns the lens flare system or null if not found
  59231. */
  59232. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  59233. /**
  59234. * Gets a lens flare system using its id
  59235. * @param id defines the id to look for
  59236. * @returns the lens flare system or null if not found
  59237. */
  59238. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  59239. }
  59240. /**
  59241. * Defines the lens flare scene component responsible to manage any lens flares
  59242. * in a given scene.
  59243. */
  59244. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  59245. /**
  59246. * The component name helpfull to identify the component in the list of scene components.
  59247. */
  59248. readonly name: string;
  59249. /**
  59250. * The scene the component belongs to.
  59251. */
  59252. scene: Scene;
  59253. /**
  59254. * Creates a new instance of the component for the given scene
  59255. * @param scene Defines the scene to register the component in
  59256. */
  59257. constructor(scene: Scene);
  59258. /**
  59259. * Registers the component in a given scene
  59260. */
  59261. register(): void;
  59262. /**
  59263. * Rebuilds the elements related to this component in case of
  59264. * context lost for instance.
  59265. */
  59266. rebuild(): void;
  59267. /**
  59268. * Adds all the elements from the container to the scene
  59269. * @param container the container holding the elements
  59270. */
  59271. addFromContainer(container: AbstractScene): void;
  59272. /**
  59273. * Removes all the elements in the container from the scene
  59274. * @param container contains the elements to remove
  59275. * @param dispose if the removed element should be disposed (default: false)
  59276. */
  59277. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59278. /**
  59279. * Serializes the component data to the specified json object
  59280. * @param serializationObject The object to serialize to
  59281. */
  59282. serialize(serializationObject: any): void;
  59283. /**
  59284. * Disposes the component and the associated ressources.
  59285. */
  59286. dispose(): void;
  59287. private _draw;
  59288. }
  59289. }
  59290. declare module BABYLON {
  59291. /** @hidden */
  59292. export var depthPixelShader: {
  59293. name: string;
  59294. shader: string;
  59295. };
  59296. }
  59297. declare module BABYLON {
  59298. /** @hidden */
  59299. export var depthVertexShader: {
  59300. name: string;
  59301. shader: string;
  59302. };
  59303. }
  59304. declare module BABYLON {
  59305. /**
  59306. * This represents a depth renderer in Babylon.
  59307. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59308. */
  59309. export class DepthRenderer {
  59310. private _scene;
  59311. private _depthMap;
  59312. private _effect;
  59313. private readonly _storeNonLinearDepth;
  59314. private readonly _clearColor;
  59315. /** Get if the depth renderer is using packed depth or not */
  59316. readonly isPacked: boolean;
  59317. private _cachedDefines;
  59318. private _camera;
  59319. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  59320. enabled: boolean;
  59321. /**
  59322. * Specifiess that the depth renderer will only be used within
  59323. * the camera it is created for.
  59324. * This can help forcing its rendering during the camera processing.
  59325. */
  59326. useOnlyInActiveCamera: boolean;
  59327. /** @hidden */
  59328. static _SceneComponentInitialization: (scene: Scene) => void;
  59329. /**
  59330. * Instantiates a depth renderer
  59331. * @param scene The scene the renderer belongs to
  59332. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59333. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59334. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59335. */
  59336. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  59337. /**
  59338. * Creates the depth rendering effect and checks if the effect is ready.
  59339. * @param subMesh The submesh to be used to render the depth map of
  59340. * @param useInstances If multiple world instances should be used
  59341. * @returns if the depth renderer is ready to render the depth map
  59342. */
  59343. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59344. /**
  59345. * Gets the texture which the depth map will be written to.
  59346. * @returns The depth map texture
  59347. */
  59348. getDepthMap(): RenderTargetTexture;
  59349. /**
  59350. * Disposes of the depth renderer.
  59351. */
  59352. dispose(): void;
  59353. }
  59354. }
  59355. declare module BABYLON {
  59356. /** @hidden */
  59357. export var minmaxReduxPixelShader: {
  59358. name: string;
  59359. shader: string;
  59360. };
  59361. }
  59362. declare module BABYLON {
  59363. /**
  59364. * This class computes a min/max reduction from a texture: it means it computes the minimum
  59365. * and maximum values from all values of the texture.
  59366. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  59367. * The source values are read from the red channel of the texture.
  59368. */
  59369. export class MinMaxReducer {
  59370. /**
  59371. * Observable triggered when the computation has been performed
  59372. */
  59373. onAfterReductionPerformed: Observable<{
  59374. min: number;
  59375. max: number;
  59376. }>;
  59377. protected _camera: Camera;
  59378. protected _sourceTexture: Nullable<RenderTargetTexture>;
  59379. protected _reductionSteps: Nullable<Array<PostProcess>>;
  59380. protected _postProcessManager: PostProcessManager;
  59381. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  59382. protected _forceFullscreenViewport: boolean;
  59383. /**
  59384. * Creates a min/max reducer
  59385. * @param camera The camera to use for the post processes
  59386. */
  59387. constructor(camera: Camera);
  59388. /**
  59389. * Gets the texture used to read the values from.
  59390. */
  59391. get sourceTexture(): Nullable<RenderTargetTexture>;
  59392. /**
  59393. * Sets the source texture to read the values from.
  59394. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  59395. * because in such textures '1' value must not be taken into account to compute the maximum
  59396. * as this value is used to clear the texture.
  59397. * Note that the computation is not activated by calling this function, you must call activate() for that!
  59398. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  59399. * @param depthRedux Indicates if the texture is a depth texture or not
  59400. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  59401. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59402. */
  59403. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59404. /**
  59405. * Defines the refresh rate of the computation.
  59406. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59407. */
  59408. get refreshRate(): number;
  59409. set refreshRate(value: number);
  59410. protected _activated: boolean;
  59411. /**
  59412. * Gets the activation status of the reducer
  59413. */
  59414. get activated(): boolean;
  59415. /**
  59416. * Activates the reduction computation.
  59417. * When activated, the observers registered in onAfterReductionPerformed are
  59418. * called after the compuation is performed
  59419. */
  59420. activate(): void;
  59421. /**
  59422. * Deactivates the reduction computation.
  59423. */
  59424. deactivate(): void;
  59425. /**
  59426. * Disposes the min/max reducer
  59427. * @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.
  59428. */
  59429. dispose(disposeAll?: boolean): void;
  59430. }
  59431. }
  59432. declare module BABYLON {
  59433. /**
  59434. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  59435. */
  59436. export class DepthReducer extends MinMaxReducer {
  59437. private _depthRenderer;
  59438. private _depthRendererId;
  59439. /**
  59440. * Gets the depth renderer used for the computation.
  59441. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  59442. */
  59443. get depthRenderer(): Nullable<DepthRenderer>;
  59444. /**
  59445. * Creates a depth reducer
  59446. * @param camera The camera used to render the depth texture
  59447. */
  59448. constructor(camera: Camera);
  59449. /**
  59450. * Sets the depth renderer to use to generate the depth map
  59451. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  59452. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  59453. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59454. */
  59455. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  59456. /** @hidden */
  59457. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59458. /**
  59459. * Activates the reduction computation.
  59460. * When activated, the observers registered in onAfterReductionPerformed are
  59461. * called after the compuation is performed
  59462. */
  59463. activate(): void;
  59464. /**
  59465. * Deactivates the reduction computation.
  59466. */
  59467. deactivate(): void;
  59468. /**
  59469. * Disposes the depth reducer
  59470. * @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.
  59471. */
  59472. dispose(disposeAll?: boolean): void;
  59473. }
  59474. }
  59475. declare module BABYLON {
  59476. /**
  59477. * A CSM implementation allowing casting shadows on large scenes.
  59478. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59479. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  59480. */
  59481. export class CascadedShadowGenerator extends ShadowGenerator {
  59482. private static readonly frustumCornersNDCSpace;
  59483. /**
  59484. * Name of the CSM class
  59485. */
  59486. static CLASSNAME: string;
  59487. /**
  59488. * Defines the default number of cascades used by the CSM.
  59489. */
  59490. static readonly DEFAULT_CASCADES_COUNT: number;
  59491. /**
  59492. * Defines the minimum number of cascades used by the CSM.
  59493. */
  59494. static readonly MIN_CASCADES_COUNT: number;
  59495. /**
  59496. * Defines the maximum number of cascades used by the CSM.
  59497. */
  59498. static readonly MAX_CASCADES_COUNT: number;
  59499. protected _validateFilter(filter: number): number;
  59500. /**
  59501. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  59502. */
  59503. penumbraDarkness: number;
  59504. private _numCascades;
  59505. /**
  59506. * Gets or set the number of cascades used by the CSM.
  59507. */
  59508. get numCascades(): number;
  59509. set numCascades(value: number);
  59510. /**
  59511. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  59512. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  59513. */
  59514. stabilizeCascades: boolean;
  59515. private _freezeShadowCastersBoundingInfo;
  59516. private _freezeShadowCastersBoundingInfoObservable;
  59517. /**
  59518. * Enables or disables the shadow casters bounding info computation.
  59519. * If your shadow casters don't move, you can disable this feature.
  59520. * If it is enabled, the bounding box computation is done every frame.
  59521. */
  59522. get freezeShadowCastersBoundingInfo(): boolean;
  59523. set freezeShadowCastersBoundingInfo(freeze: boolean);
  59524. private _scbiMin;
  59525. private _scbiMax;
  59526. protected _computeShadowCastersBoundingInfo(): void;
  59527. protected _shadowCastersBoundingInfo: BoundingInfo;
  59528. /**
  59529. * Gets or sets the shadow casters bounding info.
  59530. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  59531. * so that the system won't overwrite the bounds you provide
  59532. */
  59533. get shadowCastersBoundingInfo(): BoundingInfo;
  59534. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  59535. protected _breaksAreDirty: boolean;
  59536. protected _minDistance: number;
  59537. protected _maxDistance: number;
  59538. /**
  59539. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  59540. *
  59541. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  59542. * If you don't know these values, simply leave them to their defaults and don't call this function.
  59543. * @param min minimal distance for the breaks (default to 0.)
  59544. * @param max maximal distance for the breaks (default to 1.)
  59545. */
  59546. setMinMaxDistance(min: number, max: number): void;
  59547. /** Gets the minimal distance used in the cascade break computation */
  59548. get minDistance(): number;
  59549. /** Gets the maximal distance used in the cascade break computation */
  59550. get maxDistance(): number;
  59551. /**
  59552. * Gets the class name of that object
  59553. * @returns "CascadedShadowGenerator"
  59554. */
  59555. getClassName(): string;
  59556. private _cascadeMinExtents;
  59557. private _cascadeMaxExtents;
  59558. /**
  59559. * Gets a cascade minimum extents
  59560. * @param cascadeIndex index of the cascade
  59561. * @returns the minimum cascade extents
  59562. */
  59563. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  59564. /**
  59565. * Gets a cascade maximum extents
  59566. * @param cascadeIndex index of the cascade
  59567. * @returns the maximum cascade extents
  59568. */
  59569. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  59570. private _cascades;
  59571. private _currentLayer;
  59572. private _viewSpaceFrustumsZ;
  59573. private _viewMatrices;
  59574. private _projectionMatrices;
  59575. private _transformMatrices;
  59576. private _transformMatricesAsArray;
  59577. private _frustumLengths;
  59578. private _lightSizeUVCorrection;
  59579. private _depthCorrection;
  59580. private _frustumCornersWorldSpace;
  59581. private _frustumCenter;
  59582. private _shadowCameraPos;
  59583. private _shadowMaxZ;
  59584. /**
  59585. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  59586. * It defaults to camera.maxZ
  59587. */
  59588. get shadowMaxZ(): number;
  59589. /**
  59590. * Sets the shadow max z distance.
  59591. */
  59592. set shadowMaxZ(value: number);
  59593. protected _debug: boolean;
  59594. /**
  59595. * Gets or sets the debug flag.
  59596. * When enabled, the cascades are materialized by different colors on the screen.
  59597. */
  59598. get debug(): boolean;
  59599. set debug(dbg: boolean);
  59600. private _depthClamp;
  59601. /**
  59602. * Gets or sets the depth clamping value.
  59603. *
  59604. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  59605. * to account for the shadow casters far away.
  59606. *
  59607. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  59608. */
  59609. get depthClamp(): boolean;
  59610. set depthClamp(value: boolean);
  59611. private _cascadeBlendPercentage;
  59612. /**
  59613. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  59614. * It defaults to 0.1 (10% blending).
  59615. */
  59616. get cascadeBlendPercentage(): number;
  59617. set cascadeBlendPercentage(value: number);
  59618. private _lambda;
  59619. /**
  59620. * Gets or set the lambda parameter.
  59621. * This parameter is used to split the camera frustum and create the cascades.
  59622. * 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.
  59623. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  59624. */
  59625. get lambda(): number;
  59626. set lambda(value: number);
  59627. /**
  59628. * Gets the view matrix corresponding to a given cascade
  59629. * @param cascadeNum cascade to retrieve the view matrix from
  59630. * @returns the cascade view matrix
  59631. */
  59632. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  59633. /**
  59634. * Gets the projection matrix corresponding to a given cascade
  59635. * @param cascadeNum cascade to retrieve the projection matrix from
  59636. * @returns the cascade projection matrix
  59637. */
  59638. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  59639. /**
  59640. * Gets the transformation matrix corresponding to a given cascade
  59641. * @param cascadeNum cascade to retrieve the transformation matrix from
  59642. * @returns the cascade transformation matrix
  59643. */
  59644. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  59645. private _depthRenderer;
  59646. /**
  59647. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  59648. *
  59649. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  59650. *
  59651. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  59652. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  59653. * @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
  59654. */
  59655. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  59656. private _depthReducer;
  59657. private _autoCalcDepthBounds;
  59658. /**
  59659. * Gets or sets the autoCalcDepthBounds property.
  59660. *
  59661. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  59662. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  59663. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  59664. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  59665. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  59666. */
  59667. get autoCalcDepthBounds(): boolean;
  59668. set autoCalcDepthBounds(value: boolean);
  59669. /**
  59670. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  59671. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59672. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  59673. * for setting the refresh rate on the renderer yourself!
  59674. */
  59675. get autoCalcDepthBoundsRefreshRate(): number;
  59676. set autoCalcDepthBoundsRefreshRate(value: number);
  59677. /**
  59678. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  59679. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  59680. * you change the camera near/far planes!
  59681. */
  59682. splitFrustum(): void;
  59683. private _splitFrustum;
  59684. private _computeMatrices;
  59685. private _computeFrustumInWorldSpace;
  59686. private _computeCascadeFrustum;
  59687. /**
  59688. * Support test.
  59689. */
  59690. static get IsSupported(): boolean;
  59691. /** @hidden */
  59692. static _SceneComponentInitialization: (scene: Scene) => void;
  59693. /**
  59694. * Creates a Cascaded Shadow Generator object.
  59695. * A ShadowGenerator is the required tool to use the shadows.
  59696. * Each directional light casting shadows needs to use its own ShadowGenerator.
  59697. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59698. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  59699. * @param light The directional light object generating the shadows.
  59700. * @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.
  59701. */
  59702. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  59703. protected _initializeGenerator(): void;
  59704. protected _createTargetRenderTexture(): void;
  59705. protected _initializeShadowMap(): void;
  59706. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  59707. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  59708. /**
  59709. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  59710. * @param defines Defines of the material we want to update
  59711. * @param lightIndex Index of the light in the enabled light list of the material
  59712. */
  59713. prepareDefines(defines: any, lightIndex: number): void;
  59714. /**
  59715. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  59716. * defined in the generator but impacting the effect).
  59717. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  59718. * @param effect The effect we are binfing the information for
  59719. */
  59720. bindShadowLight(lightIndex: string, effect: Effect): void;
  59721. /**
  59722. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  59723. * (eq to view projection * shadow projection matrices)
  59724. * @returns The transform matrix used to create the shadow map
  59725. */
  59726. getTransformMatrix(): Matrix;
  59727. /**
  59728. * Disposes the ShadowGenerator.
  59729. * Returns nothing.
  59730. */
  59731. dispose(): void;
  59732. /**
  59733. * Serializes the shadow generator setup to a json object.
  59734. * @returns The serialized JSON object
  59735. */
  59736. serialize(): any;
  59737. /**
  59738. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  59739. * @param parsedShadowGenerator The JSON object to parse
  59740. * @param scene The scene to create the shadow map for
  59741. * @returns The parsed shadow generator
  59742. */
  59743. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  59744. }
  59745. }
  59746. declare module BABYLON {
  59747. /**
  59748. * Defines the shadow generator component responsible to manage any shadow generators
  59749. * in a given scene.
  59750. */
  59751. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  59752. /**
  59753. * The component name helpfull to identify the component in the list of scene components.
  59754. */
  59755. readonly name: string;
  59756. /**
  59757. * The scene the component belongs to.
  59758. */
  59759. scene: Scene;
  59760. /**
  59761. * Creates a new instance of the component for the given scene
  59762. * @param scene Defines the scene to register the component in
  59763. */
  59764. constructor(scene: Scene);
  59765. /**
  59766. * Registers the component in a given scene
  59767. */
  59768. register(): void;
  59769. /**
  59770. * Rebuilds the elements related to this component in case of
  59771. * context lost for instance.
  59772. */
  59773. rebuild(): void;
  59774. /**
  59775. * Serializes the component data to the specified json object
  59776. * @param serializationObject The object to serialize to
  59777. */
  59778. serialize(serializationObject: any): void;
  59779. /**
  59780. * Adds all the elements from the container to the scene
  59781. * @param container the container holding the elements
  59782. */
  59783. addFromContainer(container: AbstractScene): void;
  59784. /**
  59785. * Removes all the elements in the container from the scene
  59786. * @param container contains the elements to remove
  59787. * @param dispose if the removed element should be disposed (default: false)
  59788. */
  59789. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59790. /**
  59791. * Rebuilds the elements related to this component in case of
  59792. * context lost for instance.
  59793. */
  59794. dispose(): void;
  59795. private _gatherRenderTargets;
  59796. }
  59797. }
  59798. declare module BABYLON {
  59799. /**
  59800. * A point light is a light defined by an unique point in world space.
  59801. * The light is emitted in every direction from this point.
  59802. * A good example of a point light is a standard light bulb.
  59803. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59804. */
  59805. export class PointLight extends ShadowLight {
  59806. private _shadowAngle;
  59807. /**
  59808. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59809. * This specifies what angle the shadow will use to be created.
  59810. *
  59811. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  59812. */
  59813. get shadowAngle(): number;
  59814. /**
  59815. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59816. * This specifies what angle the shadow will use to be created.
  59817. *
  59818. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  59819. */
  59820. set shadowAngle(value: number);
  59821. /**
  59822. * Gets the direction if it has been set.
  59823. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59824. */
  59825. get direction(): Vector3;
  59826. /**
  59827. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59828. */
  59829. set direction(value: Vector3);
  59830. /**
  59831. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  59832. * A PointLight emits the light in every direction.
  59833. * It can cast shadows.
  59834. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  59835. * ```javascript
  59836. * var pointLight = new PointLight("pl", camera.position, scene);
  59837. * ```
  59838. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59839. * @param name The light friendly name
  59840. * @param position The position of the point light in the scene
  59841. * @param scene The scene the lights belongs to
  59842. */
  59843. constructor(name: string, position: Vector3, scene: Scene);
  59844. /**
  59845. * Returns the string "PointLight"
  59846. * @returns the class name
  59847. */
  59848. getClassName(): string;
  59849. /**
  59850. * Returns the integer 0.
  59851. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59852. */
  59853. getTypeID(): number;
  59854. /**
  59855. * Specifies wether or not the shadowmap should be a cube texture.
  59856. * @returns true if the shadowmap needs to be a cube texture.
  59857. */
  59858. needCube(): boolean;
  59859. /**
  59860. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  59861. * @param faceIndex The index of the face we are computed the direction to generate shadow
  59862. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  59863. */
  59864. getShadowDirection(faceIndex?: number): Vector3;
  59865. /**
  59866. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  59867. * - fov = PI / 2
  59868. * - aspect ratio : 1.0
  59869. * - z-near and far equal to the active camera minZ and maxZ.
  59870. * Returns the PointLight.
  59871. */
  59872. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59873. protected _buildUniformLayout(): void;
  59874. /**
  59875. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  59876. * @param effect The effect to update
  59877. * @param lightIndex The index of the light in the effect to update
  59878. * @returns The point light
  59879. */
  59880. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  59881. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  59882. /**
  59883. * Prepares the list of defines specific to the light type.
  59884. * @param defines the list of defines
  59885. * @param lightIndex defines the index of the light for the effect
  59886. */
  59887. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59888. }
  59889. }
  59890. declare module BABYLON {
  59891. /**
  59892. * Header information of HDR texture files.
  59893. */
  59894. export interface HDRInfo {
  59895. /**
  59896. * The height of the texture in pixels.
  59897. */
  59898. height: number;
  59899. /**
  59900. * The width of the texture in pixels.
  59901. */
  59902. width: number;
  59903. /**
  59904. * The index of the beginning of the data in the binary file.
  59905. */
  59906. dataPosition: number;
  59907. }
  59908. /**
  59909. * This groups tools to convert HDR texture to native colors array.
  59910. */
  59911. export class HDRTools {
  59912. private static Ldexp;
  59913. private static Rgbe2float;
  59914. private static readStringLine;
  59915. /**
  59916. * Reads header information from an RGBE texture stored in a native array.
  59917. * More information on this format are available here:
  59918. * https://en.wikipedia.org/wiki/RGBE_image_format
  59919. *
  59920. * @param uint8array The binary file stored in native array.
  59921. * @return The header information.
  59922. */
  59923. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  59924. /**
  59925. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  59926. * This RGBE texture needs to store the information as a panorama.
  59927. *
  59928. * More information on this format are available here:
  59929. * https://en.wikipedia.org/wiki/RGBE_image_format
  59930. *
  59931. * @param buffer The binary file stored in an array buffer.
  59932. * @param size The expected size of the extracted cubemap.
  59933. * @return The Cube Map information.
  59934. */
  59935. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  59936. /**
  59937. * Returns the pixels data extracted from an RGBE texture.
  59938. * This pixels will be stored left to right up to down in the R G B order in one array.
  59939. *
  59940. * More information on this format are available here:
  59941. * https://en.wikipedia.org/wiki/RGBE_image_format
  59942. *
  59943. * @param uint8array The binary file stored in an array buffer.
  59944. * @param hdrInfo The header information of the file.
  59945. * @return The pixels data in RGB right to left up to down order.
  59946. */
  59947. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  59948. private static RGBE_ReadPixels_RLE;
  59949. private static RGBE_ReadPixels_NOT_RLE;
  59950. }
  59951. }
  59952. declare module BABYLON {
  59953. /**
  59954. * Effect Render Options
  59955. */
  59956. export interface IEffectRendererOptions {
  59957. /**
  59958. * Defines the vertices positions.
  59959. */
  59960. positions?: number[];
  59961. /**
  59962. * Defines the indices.
  59963. */
  59964. indices?: number[];
  59965. }
  59966. /**
  59967. * Helper class to render one or more effects.
  59968. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  59969. */
  59970. export class EffectRenderer {
  59971. private engine;
  59972. private static _DefaultOptions;
  59973. private _vertexBuffers;
  59974. private _indexBuffer;
  59975. private _fullscreenViewport;
  59976. /**
  59977. * Creates an effect renderer
  59978. * @param engine the engine to use for rendering
  59979. * @param options defines the options of the effect renderer
  59980. */
  59981. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  59982. /**
  59983. * Sets the current viewport in normalized coordinates 0-1
  59984. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  59985. */
  59986. setViewport(viewport?: Viewport): void;
  59987. /**
  59988. * Binds the embedded attributes buffer to the effect.
  59989. * @param effect Defines the effect to bind the attributes for
  59990. */
  59991. bindBuffers(effect: Effect): void;
  59992. /**
  59993. * Sets the current effect wrapper to use during draw.
  59994. * The effect needs to be ready before calling this api.
  59995. * This also sets the default full screen position attribute.
  59996. * @param effectWrapper Defines the effect to draw with
  59997. */
  59998. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  59999. /**
  60000. * Restores engine states
  60001. */
  60002. restoreStates(): void;
  60003. /**
  60004. * Draws a full screen quad.
  60005. */
  60006. draw(): void;
  60007. private isRenderTargetTexture;
  60008. /**
  60009. * renders one or more effects to a specified texture
  60010. * @param effectWrapper the effect to renderer
  60011. * @param outputTexture texture to draw to, if null it will render to the screen.
  60012. */
  60013. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  60014. /**
  60015. * Disposes of the effect renderer
  60016. */
  60017. dispose(): void;
  60018. }
  60019. /**
  60020. * Options to create an EffectWrapper
  60021. */
  60022. interface EffectWrapperCreationOptions {
  60023. /**
  60024. * Engine to use to create the effect
  60025. */
  60026. engine: ThinEngine;
  60027. /**
  60028. * Fragment shader for the effect
  60029. */
  60030. fragmentShader: string;
  60031. /**
  60032. * Use the shader store instead of direct source code
  60033. */
  60034. useShaderStore?: boolean;
  60035. /**
  60036. * Vertex shader for the effect
  60037. */
  60038. vertexShader?: string;
  60039. /**
  60040. * Attributes to use in the shader
  60041. */
  60042. attributeNames?: Array<string>;
  60043. /**
  60044. * Uniforms to use in the shader
  60045. */
  60046. uniformNames?: Array<string>;
  60047. /**
  60048. * Texture sampler names to use in the shader
  60049. */
  60050. samplerNames?: Array<string>;
  60051. /**
  60052. * Defines to use in the shader
  60053. */
  60054. defines?: Array<string>;
  60055. /**
  60056. * Callback when effect is compiled
  60057. */
  60058. onCompiled?: Nullable<(effect: Effect) => void>;
  60059. /**
  60060. * The friendly name of the effect displayed in Spector.
  60061. */
  60062. name?: string;
  60063. }
  60064. /**
  60065. * Wraps an effect to be used for rendering
  60066. */
  60067. export class EffectWrapper {
  60068. /**
  60069. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60070. */
  60071. onApplyObservable: Observable<{}>;
  60072. /**
  60073. * The underlying effect
  60074. */
  60075. effect: Effect;
  60076. /**
  60077. * Creates an effect to be renderer
  60078. * @param creationOptions options to create the effect
  60079. */
  60080. constructor(creationOptions: EffectWrapperCreationOptions);
  60081. /**
  60082. * Disposes of the effect wrapper
  60083. */
  60084. dispose(): void;
  60085. }
  60086. }
  60087. declare module BABYLON {
  60088. /** @hidden */
  60089. export var hdrFilteringVertexShader: {
  60090. name: string;
  60091. shader: string;
  60092. };
  60093. }
  60094. declare module BABYLON {
  60095. /** @hidden */
  60096. export var hdrFilteringPixelShader: {
  60097. name: string;
  60098. shader: string;
  60099. };
  60100. }
  60101. declare module BABYLON {
  60102. /**
  60103. * Options for texture filtering
  60104. */
  60105. interface IHDRFilteringOptions {
  60106. /**
  60107. * Scales pixel intensity for the input HDR map.
  60108. */
  60109. hdrScale?: number;
  60110. /**
  60111. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  60112. */
  60113. quality?: number;
  60114. }
  60115. /**
  60116. * Filters HDR maps to get correct renderings of PBR reflections
  60117. */
  60118. export class HDRFiltering {
  60119. private _engine;
  60120. private _effectRenderer;
  60121. private _effectWrapper;
  60122. private _lodGenerationOffset;
  60123. private _lodGenerationScale;
  60124. /**
  60125. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  60126. * you care about baking speed.
  60127. */
  60128. quality: number;
  60129. /**
  60130. * Scales pixel intensity for the input HDR map.
  60131. */
  60132. hdrScale: number;
  60133. /**
  60134. * Instantiates HDR filter for reflection maps
  60135. *
  60136. * @param engine Thin engine
  60137. * @param options Options
  60138. */
  60139. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  60140. private _createRenderTarget;
  60141. private _prefilterInternal;
  60142. private _createEffect;
  60143. /**
  60144. * Get a value indicating if the filter is ready to be used
  60145. * @param texture Texture to filter
  60146. * @returns true if the filter is ready
  60147. */
  60148. isReady(texture: BaseTexture): boolean;
  60149. /**
  60150. * Prefilters a cube texture to have mipmap levels representing roughness values.
  60151. * Prefiltering will be invoked at the end of next rendering pass.
  60152. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  60153. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  60154. * @param texture Texture to filter
  60155. * @param onFinished Callback when filtering is done
  60156. * @return Promise called when prefiltering is done
  60157. */
  60158. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  60159. }
  60160. }
  60161. declare module BABYLON {
  60162. /**
  60163. * This represents a texture coming from an HDR input.
  60164. *
  60165. * The only supported format is currently panorama picture stored in RGBE format.
  60166. * Example of such files can be found on HDRLib: http://hdrlib.com/
  60167. */
  60168. export class HDRCubeTexture extends BaseTexture {
  60169. private static _facesMapping;
  60170. private _generateHarmonics;
  60171. private _noMipmap;
  60172. private _prefilterOnLoad;
  60173. private _textureMatrix;
  60174. private _size;
  60175. private _onLoad;
  60176. private _onError;
  60177. /**
  60178. * The texture URL.
  60179. */
  60180. url: string;
  60181. /**
  60182. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  60183. */
  60184. coordinatesMode: number;
  60185. protected _isBlocking: boolean;
  60186. /**
  60187. * Sets wether or not the texture is blocking during loading.
  60188. */
  60189. set isBlocking(value: boolean);
  60190. /**
  60191. * Gets wether or not the texture is blocking during loading.
  60192. */
  60193. get isBlocking(): boolean;
  60194. protected _rotationY: number;
  60195. /**
  60196. * Sets texture matrix rotation angle around Y axis in radians.
  60197. */
  60198. set rotationY(value: number);
  60199. /**
  60200. * Gets texture matrix rotation angle around Y axis radians.
  60201. */
  60202. get rotationY(): number;
  60203. /**
  60204. * Gets or sets the center of the bounding box associated with the cube texture
  60205. * It must define where the camera used to render the texture was set
  60206. */
  60207. boundingBoxPosition: Vector3;
  60208. private _boundingBoxSize;
  60209. /**
  60210. * Gets or sets the size of the bounding box associated with the cube texture
  60211. * When defined, the cubemap will switch to local mode
  60212. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  60213. * @example https://www.babylonjs-playground.com/#RNASML
  60214. */
  60215. set boundingBoxSize(value: Vector3);
  60216. get boundingBoxSize(): Vector3;
  60217. /**
  60218. * Instantiates an HDRTexture from the following parameters.
  60219. *
  60220. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  60221. * @param sceneOrEngine The scene or engine the texture will be used in
  60222. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60223. * @param noMipmap Forces to not generate the mipmap if true
  60224. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  60225. * @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)
  60226. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  60227. */
  60228. 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>);
  60229. /**
  60230. * Get the current class name of the texture useful for serialization or dynamic coding.
  60231. * @returns "HDRCubeTexture"
  60232. */
  60233. getClassName(): string;
  60234. /**
  60235. * Occurs when the file is raw .hdr file.
  60236. */
  60237. private loadTexture;
  60238. clone(): HDRCubeTexture;
  60239. delayLoad(): void;
  60240. /**
  60241. * Get the texture reflection matrix used to rotate/transform the reflection.
  60242. * @returns the reflection matrix
  60243. */
  60244. getReflectionTextureMatrix(): Matrix;
  60245. /**
  60246. * Set the texture reflection matrix used to rotate/transform the reflection.
  60247. * @param value Define the reflection matrix to set
  60248. */
  60249. setReflectionTextureMatrix(value: Matrix): void;
  60250. /**
  60251. * Parses a JSON representation of an HDR Texture in order to create the texture
  60252. * @param parsedTexture Define the JSON representation
  60253. * @param scene Define the scene the texture should be created in
  60254. * @param rootUrl Define the root url in case we need to load relative dependencies
  60255. * @returns the newly created texture after parsing
  60256. */
  60257. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  60258. serialize(): any;
  60259. }
  60260. }
  60261. declare module BABYLON {
  60262. /**
  60263. * Class used to control physics engine
  60264. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60265. */
  60266. export class PhysicsEngine implements IPhysicsEngine {
  60267. private _physicsPlugin;
  60268. /**
  60269. * Global value used to control the smallest number supported by the simulation
  60270. */
  60271. static Epsilon: number;
  60272. private _impostors;
  60273. private _joints;
  60274. private _subTimeStep;
  60275. /**
  60276. * Gets the gravity vector used by the simulation
  60277. */
  60278. gravity: Vector3;
  60279. /**
  60280. * Factory used to create the default physics plugin.
  60281. * @returns The default physics plugin
  60282. */
  60283. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  60284. /**
  60285. * Creates a new Physics Engine
  60286. * @param gravity defines the gravity vector used by the simulation
  60287. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  60288. */
  60289. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  60290. /**
  60291. * Sets the gravity vector used by the simulation
  60292. * @param gravity defines the gravity vector to use
  60293. */
  60294. setGravity(gravity: Vector3): void;
  60295. /**
  60296. * Set the time step of the physics engine.
  60297. * Default is 1/60.
  60298. * To slow it down, enter 1/600 for example.
  60299. * To speed it up, 1/30
  60300. * @param newTimeStep defines the new timestep to apply to this world.
  60301. */
  60302. setTimeStep(newTimeStep?: number): void;
  60303. /**
  60304. * Get the time step of the physics engine.
  60305. * @returns the current time step
  60306. */
  60307. getTimeStep(): number;
  60308. /**
  60309. * Set the sub time step of the physics engine.
  60310. * Default is 0 meaning there is no sub steps
  60311. * To increase physics resolution precision, set a small value (like 1 ms)
  60312. * @param subTimeStep defines the new sub timestep used for physics resolution.
  60313. */
  60314. setSubTimeStep(subTimeStep?: number): void;
  60315. /**
  60316. * Get the sub time step of the physics engine.
  60317. * @returns the current sub time step
  60318. */
  60319. getSubTimeStep(): number;
  60320. /**
  60321. * Release all resources
  60322. */
  60323. dispose(): void;
  60324. /**
  60325. * Gets the name of the current physics plugin
  60326. * @returns the name of the plugin
  60327. */
  60328. getPhysicsPluginName(): string;
  60329. /**
  60330. * Adding a new impostor for the impostor tracking.
  60331. * This will be done by the impostor itself.
  60332. * @param impostor the impostor to add
  60333. */
  60334. addImpostor(impostor: PhysicsImpostor): void;
  60335. /**
  60336. * Remove an impostor from the engine.
  60337. * This impostor and its mesh will not longer be updated by the physics engine.
  60338. * @param impostor the impostor to remove
  60339. */
  60340. removeImpostor(impostor: PhysicsImpostor): void;
  60341. /**
  60342. * Add a joint to the physics engine
  60343. * @param mainImpostor defines the main impostor to which the joint is added.
  60344. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  60345. * @param joint defines the joint that will connect both impostors.
  60346. */
  60347. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60348. /**
  60349. * Removes a joint from the simulation
  60350. * @param mainImpostor defines the impostor used with the joint
  60351. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  60352. * @param joint defines the joint to remove
  60353. */
  60354. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60355. /**
  60356. * Called by the scene. No need to call it.
  60357. * @param delta defines the timespam between frames
  60358. */
  60359. _step(delta: number): void;
  60360. /**
  60361. * Gets the current plugin used to run the simulation
  60362. * @returns current plugin
  60363. */
  60364. getPhysicsPlugin(): IPhysicsEnginePlugin;
  60365. /**
  60366. * Gets the list of physic impostors
  60367. * @returns an array of PhysicsImpostor
  60368. */
  60369. getImpostors(): Array<PhysicsImpostor>;
  60370. /**
  60371. * Gets the impostor for a physics enabled object
  60372. * @param object defines the object impersonated by the impostor
  60373. * @returns the PhysicsImpostor or null if not found
  60374. */
  60375. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  60376. /**
  60377. * Gets the impostor for a physics body object
  60378. * @param body defines physics body used by the impostor
  60379. * @returns the PhysicsImpostor or null if not found
  60380. */
  60381. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  60382. /**
  60383. * Does a raycast in the physics world
  60384. * @param from when should the ray start?
  60385. * @param to when should the ray end?
  60386. * @returns PhysicsRaycastResult
  60387. */
  60388. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60389. }
  60390. }
  60391. declare module BABYLON {
  60392. /** @hidden */
  60393. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  60394. private _useDeltaForWorldStep;
  60395. world: any;
  60396. name: string;
  60397. private _physicsMaterials;
  60398. private _fixedTimeStep;
  60399. private _cannonRaycastResult;
  60400. private _raycastResult;
  60401. private _physicsBodysToRemoveAfterStep;
  60402. private _firstFrame;
  60403. BJSCANNON: any;
  60404. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  60405. setGravity(gravity: Vector3): void;
  60406. setTimeStep(timeStep: number): void;
  60407. getTimeStep(): number;
  60408. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60409. private _removeMarkedPhysicsBodiesFromWorld;
  60410. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60411. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60412. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60413. private _processChildMeshes;
  60414. removePhysicsBody(impostor: PhysicsImpostor): void;
  60415. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60416. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60417. private _addMaterial;
  60418. private _checkWithEpsilon;
  60419. private _createShape;
  60420. private _createHeightmap;
  60421. private _minus90X;
  60422. private _plus90X;
  60423. private _tmpPosition;
  60424. private _tmpDeltaPosition;
  60425. private _tmpUnityRotation;
  60426. private _updatePhysicsBodyTransformation;
  60427. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60428. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60429. isSupported(): boolean;
  60430. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60431. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60432. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60433. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60434. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60435. getBodyMass(impostor: PhysicsImpostor): number;
  60436. getBodyFriction(impostor: PhysicsImpostor): number;
  60437. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60438. getBodyRestitution(impostor: PhysicsImpostor): number;
  60439. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60440. sleepBody(impostor: PhysicsImpostor): void;
  60441. wakeUpBody(impostor: PhysicsImpostor): void;
  60442. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  60443. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60444. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60445. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60446. getRadius(impostor: PhysicsImpostor): number;
  60447. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60448. dispose(): void;
  60449. private _extendNamespace;
  60450. /**
  60451. * Does a raycast in the physics world
  60452. * @param from when should the ray start?
  60453. * @param to when should the ray end?
  60454. * @returns PhysicsRaycastResult
  60455. */
  60456. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60457. }
  60458. }
  60459. declare module BABYLON {
  60460. /** @hidden */
  60461. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  60462. private _useDeltaForWorldStep;
  60463. world: any;
  60464. name: string;
  60465. BJSOIMO: any;
  60466. private _raycastResult;
  60467. private _fixedTimeStep;
  60468. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  60469. setGravity(gravity: Vector3): void;
  60470. setTimeStep(timeStep: number): void;
  60471. getTimeStep(): number;
  60472. private _tmpImpostorsArray;
  60473. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60474. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60475. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60476. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60477. private _tmpPositionVector;
  60478. removePhysicsBody(impostor: PhysicsImpostor): void;
  60479. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60480. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60481. isSupported(): boolean;
  60482. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60483. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60484. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60485. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60486. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60487. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60488. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60489. getBodyMass(impostor: PhysicsImpostor): number;
  60490. getBodyFriction(impostor: PhysicsImpostor): number;
  60491. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60492. getBodyRestitution(impostor: PhysicsImpostor): number;
  60493. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60494. sleepBody(impostor: PhysicsImpostor): void;
  60495. wakeUpBody(impostor: PhysicsImpostor): void;
  60496. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60497. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  60498. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  60499. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60500. getRadius(impostor: PhysicsImpostor): number;
  60501. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60502. dispose(): void;
  60503. /**
  60504. * Does a raycast in the physics world
  60505. * @param from when should the ray start?
  60506. * @param to when should the ray end?
  60507. * @returns PhysicsRaycastResult
  60508. */
  60509. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60510. }
  60511. }
  60512. declare module BABYLON {
  60513. /**
  60514. * AmmoJS Physics plugin
  60515. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60516. * @see https://github.com/kripken/ammo.js/
  60517. */
  60518. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  60519. private _useDeltaForWorldStep;
  60520. /**
  60521. * Reference to the Ammo library
  60522. */
  60523. bjsAMMO: any;
  60524. /**
  60525. * Created ammoJS world which physics bodies are added to
  60526. */
  60527. world: any;
  60528. /**
  60529. * Name of the plugin
  60530. */
  60531. name: string;
  60532. private _timeStep;
  60533. private _fixedTimeStep;
  60534. private _maxSteps;
  60535. private _tmpQuaternion;
  60536. private _tmpAmmoTransform;
  60537. private _tmpAmmoQuaternion;
  60538. private _tmpAmmoConcreteContactResultCallback;
  60539. private _collisionConfiguration;
  60540. private _dispatcher;
  60541. private _overlappingPairCache;
  60542. private _solver;
  60543. private _softBodySolver;
  60544. private _tmpAmmoVectorA;
  60545. private _tmpAmmoVectorB;
  60546. private _tmpAmmoVectorC;
  60547. private _tmpAmmoVectorD;
  60548. private _tmpContactCallbackResult;
  60549. private _tmpAmmoVectorRCA;
  60550. private _tmpAmmoVectorRCB;
  60551. private _raycastResult;
  60552. private static readonly DISABLE_COLLISION_FLAG;
  60553. private static readonly KINEMATIC_FLAG;
  60554. private static readonly DISABLE_DEACTIVATION_FLAG;
  60555. /**
  60556. * Initializes the ammoJS plugin
  60557. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  60558. * @param ammoInjection can be used to inject your own ammo reference
  60559. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  60560. */
  60561. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  60562. /**
  60563. * Sets the gravity of the physics world (m/(s^2))
  60564. * @param gravity Gravity to set
  60565. */
  60566. setGravity(gravity: Vector3): void;
  60567. /**
  60568. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  60569. * @param timeStep timestep to use in seconds
  60570. */
  60571. setTimeStep(timeStep: number): void;
  60572. /**
  60573. * 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)
  60574. * @param fixedTimeStep fixedTimeStep to use in seconds
  60575. */
  60576. setFixedTimeStep(fixedTimeStep: number): void;
  60577. /**
  60578. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  60579. * @param maxSteps the maximum number of steps by the physics engine per frame
  60580. */
  60581. setMaxSteps(maxSteps: number): void;
  60582. /**
  60583. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  60584. * @returns the current timestep in seconds
  60585. */
  60586. getTimeStep(): number;
  60587. /**
  60588. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  60589. */
  60590. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  60591. private _isImpostorInContact;
  60592. private _isImpostorPairInContact;
  60593. private _stepSimulation;
  60594. /**
  60595. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  60596. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  60597. * After the step the babylon meshes are set to the position of the physics imposters
  60598. * @param delta amount of time to step forward
  60599. * @param impostors array of imposters to update before/after the step
  60600. */
  60601. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60602. /**
  60603. * Update babylon mesh to match physics world object
  60604. * @param impostor imposter to match
  60605. */
  60606. private _afterSoftStep;
  60607. /**
  60608. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60609. * @param impostor imposter to match
  60610. */
  60611. private _ropeStep;
  60612. /**
  60613. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60614. * @param impostor imposter to match
  60615. */
  60616. private _softbodyOrClothStep;
  60617. private _tmpMatrix;
  60618. /**
  60619. * Applies an impulse on the imposter
  60620. * @param impostor imposter to apply impulse to
  60621. * @param force amount of force to be applied to the imposter
  60622. * @param contactPoint the location to apply the impulse on the imposter
  60623. */
  60624. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60625. /**
  60626. * Applies a force on the imposter
  60627. * @param impostor imposter to apply force
  60628. * @param force amount of force to be applied to the imposter
  60629. * @param contactPoint the location to apply the force on the imposter
  60630. */
  60631. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60632. /**
  60633. * Creates a physics body using the plugin
  60634. * @param impostor the imposter to create the physics body on
  60635. */
  60636. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60637. /**
  60638. * Removes the physics body from the imposter and disposes of the body's memory
  60639. * @param impostor imposter to remove the physics body from
  60640. */
  60641. removePhysicsBody(impostor: PhysicsImpostor): void;
  60642. /**
  60643. * Generates a joint
  60644. * @param impostorJoint the imposter joint to create the joint with
  60645. */
  60646. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60647. /**
  60648. * Removes a joint
  60649. * @param impostorJoint the imposter joint to remove the joint from
  60650. */
  60651. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60652. private _addMeshVerts;
  60653. /**
  60654. * Initialise the soft body vertices to match its object's (mesh) vertices
  60655. * Softbody vertices (nodes) are in world space and to match this
  60656. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  60657. * @param impostor to create the softbody for
  60658. */
  60659. private _softVertexData;
  60660. /**
  60661. * Create an impostor's soft body
  60662. * @param impostor to create the softbody for
  60663. */
  60664. private _createSoftbody;
  60665. /**
  60666. * Create cloth for an impostor
  60667. * @param impostor to create the softbody for
  60668. */
  60669. private _createCloth;
  60670. /**
  60671. * Create rope for an impostor
  60672. * @param impostor to create the softbody for
  60673. */
  60674. private _createRope;
  60675. /**
  60676. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  60677. * @param impostor to create the custom physics shape for
  60678. */
  60679. private _createCustom;
  60680. private _addHullVerts;
  60681. private _createShape;
  60682. /**
  60683. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  60684. * @param impostor imposter containing the physics body and babylon object
  60685. */
  60686. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60687. /**
  60688. * Sets the babylon object's position/rotation from the physics body's position/rotation
  60689. * @param impostor imposter containing the physics body and babylon object
  60690. * @param newPosition new position
  60691. * @param newRotation new rotation
  60692. */
  60693. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60694. /**
  60695. * If this plugin is supported
  60696. * @returns true if its supported
  60697. */
  60698. isSupported(): boolean;
  60699. /**
  60700. * Sets the linear velocity of the physics body
  60701. * @param impostor imposter to set the velocity on
  60702. * @param velocity velocity to set
  60703. */
  60704. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60705. /**
  60706. * Sets the angular velocity of the physics body
  60707. * @param impostor imposter to set the velocity on
  60708. * @param velocity velocity to set
  60709. */
  60710. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60711. /**
  60712. * gets the linear velocity
  60713. * @param impostor imposter to get linear velocity from
  60714. * @returns linear velocity
  60715. */
  60716. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60717. /**
  60718. * gets the angular velocity
  60719. * @param impostor imposter to get angular velocity from
  60720. * @returns angular velocity
  60721. */
  60722. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60723. /**
  60724. * Sets the mass of physics body
  60725. * @param impostor imposter to set the mass on
  60726. * @param mass mass to set
  60727. */
  60728. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60729. /**
  60730. * Gets the mass of the physics body
  60731. * @param impostor imposter to get the mass from
  60732. * @returns mass
  60733. */
  60734. getBodyMass(impostor: PhysicsImpostor): number;
  60735. /**
  60736. * Gets friction of the impostor
  60737. * @param impostor impostor to get friction from
  60738. * @returns friction value
  60739. */
  60740. getBodyFriction(impostor: PhysicsImpostor): number;
  60741. /**
  60742. * Sets friction of the impostor
  60743. * @param impostor impostor to set friction on
  60744. * @param friction friction value
  60745. */
  60746. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60747. /**
  60748. * Gets restitution of the impostor
  60749. * @param impostor impostor to get restitution from
  60750. * @returns restitution value
  60751. */
  60752. getBodyRestitution(impostor: PhysicsImpostor): number;
  60753. /**
  60754. * Sets resitution of the impostor
  60755. * @param impostor impostor to set resitution on
  60756. * @param restitution resitution value
  60757. */
  60758. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60759. /**
  60760. * Gets pressure inside the impostor
  60761. * @param impostor impostor to get pressure from
  60762. * @returns pressure value
  60763. */
  60764. getBodyPressure(impostor: PhysicsImpostor): number;
  60765. /**
  60766. * Sets pressure inside a soft body impostor
  60767. * Cloth and rope must remain 0 pressure
  60768. * @param impostor impostor to set pressure on
  60769. * @param pressure pressure value
  60770. */
  60771. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  60772. /**
  60773. * Gets stiffness of the impostor
  60774. * @param impostor impostor to get stiffness from
  60775. * @returns pressure value
  60776. */
  60777. getBodyStiffness(impostor: PhysicsImpostor): number;
  60778. /**
  60779. * Sets stiffness of the impostor
  60780. * @param impostor impostor to set stiffness on
  60781. * @param stiffness stiffness value from 0 to 1
  60782. */
  60783. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  60784. /**
  60785. * Gets velocityIterations of the impostor
  60786. * @param impostor impostor to get velocity iterations from
  60787. * @returns velocityIterations value
  60788. */
  60789. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  60790. /**
  60791. * Sets velocityIterations of the impostor
  60792. * @param impostor impostor to set velocity iterations on
  60793. * @param velocityIterations velocityIterations value
  60794. */
  60795. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  60796. /**
  60797. * Gets positionIterations of the impostor
  60798. * @param impostor impostor to get position iterations from
  60799. * @returns positionIterations value
  60800. */
  60801. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  60802. /**
  60803. * Sets positionIterations of the impostor
  60804. * @param impostor impostor to set position on
  60805. * @param positionIterations positionIterations value
  60806. */
  60807. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  60808. /**
  60809. * Append an anchor to a cloth object
  60810. * @param impostor is the cloth impostor to add anchor to
  60811. * @param otherImpostor is the rigid impostor to anchor to
  60812. * @param width ratio across width from 0 to 1
  60813. * @param height ratio up height from 0 to 1
  60814. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  60815. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  60816. */
  60817. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  60818. /**
  60819. * Append an hook to a rope object
  60820. * @param impostor is the rope impostor to add hook to
  60821. * @param otherImpostor is the rigid impostor to hook to
  60822. * @param length ratio along the rope from 0 to 1
  60823. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  60824. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  60825. */
  60826. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  60827. /**
  60828. * Sleeps the physics body and stops it from being active
  60829. * @param impostor impostor to sleep
  60830. */
  60831. sleepBody(impostor: PhysicsImpostor): void;
  60832. /**
  60833. * Activates the physics body
  60834. * @param impostor impostor to activate
  60835. */
  60836. wakeUpBody(impostor: PhysicsImpostor): void;
  60837. /**
  60838. * Updates the distance parameters of the joint
  60839. * @param joint joint to update
  60840. * @param maxDistance maximum distance of the joint
  60841. * @param minDistance minimum distance of the joint
  60842. */
  60843. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60844. /**
  60845. * Sets a motor on the joint
  60846. * @param joint joint to set motor on
  60847. * @param speed speed of the motor
  60848. * @param maxForce maximum force of the motor
  60849. * @param motorIndex index of the motor
  60850. */
  60851. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60852. /**
  60853. * Sets the motors limit
  60854. * @param joint joint to set limit on
  60855. * @param upperLimit upper limit
  60856. * @param lowerLimit lower limit
  60857. */
  60858. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60859. /**
  60860. * Syncs the position and rotation of a mesh with the impostor
  60861. * @param mesh mesh to sync
  60862. * @param impostor impostor to update the mesh with
  60863. */
  60864. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60865. /**
  60866. * Gets the radius of the impostor
  60867. * @param impostor impostor to get radius from
  60868. * @returns the radius
  60869. */
  60870. getRadius(impostor: PhysicsImpostor): number;
  60871. /**
  60872. * Gets the box size of the impostor
  60873. * @param impostor impostor to get box size from
  60874. * @param result the resulting box size
  60875. */
  60876. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60877. /**
  60878. * Disposes of the impostor
  60879. */
  60880. dispose(): void;
  60881. /**
  60882. * Does a raycast in the physics world
  60883. * @param from when should the ray start?
  60884. * @param to when should the ray end?
  60885. * @returns PhysicsRaycastResult
  60886. */
  60887. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60888. }
  60889. }
  60890. declare module BABYLON {
  60891. interface AbstractScene {
  60892. /**
  60893. * The list of reflection probes added to the scene
  60894. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60895. */
  60896. reflectionProbes: Array<ReflectionProbe>;
  60897. /**
  60898. * Removes the given reflection probe from this scene.
  60899. * @param toRemove The reflection probe to remove
  60900. * @returns The index of the removed reflection probe
  60901. */
  60902. removeReflectionProbe(toRemove: ReflectionProbe): number;
  60903. /**
  60904. * Adds the given reflection probe to this scene.
  60905. * @param newReflectionProbe The reflection probe to add
  60906. */
  60907. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  60908. }
  60909. /**
  60910. * Class used to generate realtime reflection / refraction cube textures
  60911. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60912. */
  60913. export class ReflectionProbe {
  60914. /** defines the name of the probe */
  60915. name: string;
  60916. private _scene;
  60917. private _renderTargetTexture;
  60918. private _projectionMatrix;
  60919. private _viewMatrix;
  60920. private _target;
  60921. private _add;
  60922. private _attachedMesh;
  60923. private _invertYAxis;
  60924. /** Gets or sets probe position (center of the cube map) */
  60925. position: Vector3;
  60926. /**
  60927. * Creates a new reflection probe
  60928. * @param name defines the name of the probe
  60929. * @param size defines the texture resolution (for each face)
  60930. * @param scene defines the hosting scene
  60931. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  60932. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  60933. */
  60934. constructor(
  60935. /** defines the name of the probe */
  60936. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  60937. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  60938. get samples(): number;
  60939. set samples(value: number);
  60940. /** Gets or sets the refresh rate to use (on every frame by default) */
  60941. get refreshRate(): number;
  60942. set refreshRate(value: number);
  60943. /**
  60944. * Gets the hosting scene
  60945. * @returns a Scene
  60946. */
  60947. getScene(): Scene;
  60948. /** Gets the internal CubeTexture used to render to */
  60949. get cubeTexture(): RenderTargetTexture;
  60950. /** Gets the list of meshes to render */
  60951. get renderList(): Nullable<AbstractMesh[]>;
  60952. /**
  60953. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  60954. * @param mesh defines the mesh to attach to
  60955. */
  60956. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  60957. /**
  60958. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  60959. * @param renderingGroupId The rendering group id corresponding to its index
  60960. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  60961. */
  60962. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  60963. /**
  60964. * Clean all associated resources
  60965. */
  60966. dispose(): void;
  60967. /**
  60968. * Converts the reflection probe information to a readable string for debug purpose.
  60969. * @param fullDetails Supports for multiple levels of logging within scene loading
  60970. * @returns the human readable reflection probe info
  60971. */
  60972. toString(fullDetails?: boolean): string;
  60973. /**
  60974. * Get the class name of the relfection probe.
  60975. * @returns "ReflectionProbe"
  60976. */
  60977. getClassName(): string;
  60978. /**
  60979. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  60980. * @returns The JSON representation of the texture
  60981. */
  60982. serialize(): any;
  60983. /**
  60984. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  60985. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  60986. * @param scene Define the scene the parsed reflection probe should be instantiated in
  60987. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  60988. * @returns The parsed reflection probe if successful
  60989. */
  60990. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  60991. }
  60992. }
  60993. declare module BABYLON {
  60994. /** @hidden */
  60995. export var _BabylonLoaderRegistered: boolean;
  60996. /**
  60997. * Helps setting up some configuration for the babylon file loader.
  60998. */
  60999. export class BabylonFileLoaderConfiguration {
  61000. /**
  61001. * The loader does not allow injecting custom physix engine into the plugins.
  61002. * Unfortunately in ES6, we need to manually inject them into the plugin.
  61003. * So you could set this variable to your engine import to make it work.
  61004. */
  61005. static LoaderInjectedPhysicsEngine: any;
  61006. }
  61007. }
  61008. declare module BABYLON {
  61009. /**
  61010. * The Physically based simple base material of BJS.
  61011. *
  61012. * This enables better naming and convention enforcements on top of the pbrMaterial.
  61013. * It is used as the base class for both the specGloss and metalRough conventions.
  61014. */
  61015. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  61016. /**
  61017. * Number of Simultaneous lights allowed on the material.
  61018. */
  61019. maxSimultaneousLights: number;
  61020. /**
  61021. * If sets to true, disables all the lights affecting the material.
  61022. */
  61023. disableLighting: boolean;
  61024. /**
  61025. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  61026. */
  61027. environmentTexture: BaseTexture;
  61028. /**
  61029. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  61030. */
  61031. invertNormalMapX: boolean;
  61032. /**
  61033. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  61034. */
  61035. invertNormalMapY: boolean;
  61036. /**
  61037. * Normal map used in the model.
  61038. */
  61039. normalTexture: BaseTexture;
  61040. /**
  61041. * Emissivie color used to self-illuminate the model.
  61042. */
  61043. emissiveColor: Color3;
  61044. /**
  61045. * Emissivie texture used to self-illuminate the model.
  61046. */
  61047. emissiveTexture: BaseTexture;
  61048. /**
  61049. * Occlusion Channel Strenght.
  61050. */
  61051. occlusionStrength: number;
  61052. /**
  61053. * Occlusion Texture of the material (adding extra occlusion effects).
  61054. */
  61055. occlusionTexture: BaseTexture;
  61056. /**
  61057. * Defines the alpha limits in alpha test mode.
  61058. */
  61059. alphaCutOff: number;
  61060. /**
  61061. * Gets the current double sided mode.
  61062. */
  61063. get doubleSided(): boolean;
  61064. /**
  61065. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  61066. */
  61067. set doubleSided(value: boolean);
  61068. /**
  61069. * Stores the pre-calculated light information of a mesh in a texture.
  61070. */
  61071. lightmapTexture: BaseTexture;
  61072. /**
  61073. * If true, the light map contains occlusion information instead of lighting info.
  61074. */
  61075. useLightmapAsShadowmap: boolean;
  61076. /**
  61077. * Instantiates a new PBRMaterial instance.
  61078. *
  61079. * @param name The material name
  61080. * @param scene The scene the material will be use in.
  61081. */
  61082. constructor(name: string, scene: Scene);
  61083. getClassName(): string;
  61084. }
  61085. }
  61086. declare module BABYLON {
  61087. /**
  61088. * The PBR material of BJS following the metal roughness convention.
  61089. *
  61090. * This fits to the PBR convention in the GLTF definition:
  61091. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  61092. */
  61093. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  61094. /**
  61095. * The base color has two different interpretations depending on the value of metalness.
  61096. * When the material is a metal, the base color is the specific measured reflectance value
  61097. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  61098. * of the material.
  61099. */
  61100. baseColor: Color3;
  61101. /**
  61102. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  61103. * well as opacity information in the alpha channel.
  61104. */
  61105. baseTexture: BaseTexture;
  61106. /**
  61107. * Specifies the metallic scalar value of the material.
  61108. * Can also be used to scale the metalness values of the metallic texture.
  61109. */
  61110. metallic: number;
  61111. /**
  61112. * Specifies the roughness scalar value of the material.
  61113. * Can also be used to scale the roughness values of the metallic texture.
  61114. */
  61115. roughness: number;
  61116. /**
  61117. * Texture containing both the metallic value in the B channel and the
  61118. * roughness value in the G channel to keep better precision.
  61119. */
  61120. metallicRoughnessTexture: BaseTexture;
  61121. /**
  61122. * Instantiates a new PBRMetalRoughnessMaterial instance.
  61123. *
  61124. * @param name The material name
  61125. * @param scene The scene the material will be use in.
  61126. */
  61127. constructor(name: string, scene: Scene);
  61128. /**
  61129. * Return the currrent class name of the material.
  61130. */
  61131. getClassName(): string;
  61132. /**
  61133. * Makes a duplicate of the current material.
  61134. * @param name - name to use for the new material.
  61135. */
  61136. clone(name: string): PBRMetallicRoughnessMaterial;
  61137. /**
  61138. * Serialize the material to a parsable JSON object.
  61139. */
  61140. serialize(): any;
  61141. /**
  61142. * Parses a JSON object correponding to the serialize function.
  61143. */
  61144. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  61145. }
  61146. }
  61147. declare module BABYLON {
  61148. /**
  61149. * The PBR material of BJS following the specular glossiness convention.
  61150. *
  61151. * This fits to the PBR convention in the GLTF definition:
  61152. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  61153. */
  61154. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  61155. /**
  61156. * Specifies the diffuse color of the material.
  61157. */
  61158. diffuseColor: Color3;
  61159. /**
  61160. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  61161. * channel.
  61162. */
  61163. diffuseTexture: BaseTexture;
  61164. /**
  61165. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  61166. */
  61167. specularColor: Color3;
  61168. /**
  61169. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  61170. */
  61171. glossiness: number;
  61172. /**
  61173. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  61174. */
  61175. specularGlossinessTexture: BaseTexture;
  61176. /**
  61177. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  61178. *
  61179. * @param name The material name
  61180. * @param scene The scene the material will be use in.
  61181. */
  61182. constructor(name: string, scene: Scene);
  61183. /**
  61184. * Return the currrent class name of the material.
  61185. */
  61186. getClassName(): string;
  61187. /**
  61188. * Makes a duplicate of the current material.
  61189. * @param name - name to use for the new material.
  61190. */
  61191. clone(name: string): PBRSpecularGlossinessMaterial;
  61192. /**
  61193. * Serialize the material to a parsable JSON object.
  61194. */
  61195. serialize(): any;
  61196. /**
  61197. * Parses a JSON object correponding to the serialize function.
  61198. */
  61199. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  61200. }
  61201. }
  61202. declare module BABYLON {
  61203. /**
  61204. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  61205. * It can help converting any input color in a desired output one. This can then be used to create effects
  61206. * from sepia, black and white to sixties or futuristic rendering...
  61207. *
  61208. * The only supported format is currently 3dl.
  61209. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  61210. */
  61211. export class ColorGradingTexture extends BaseTexture {
  61212. /**
  61213. * The texture URL.
  61214. */
  61215. url: string;
  61216. /**
  61217. * Empty line regex stored for GC.
  61218. */
  61219. private static _noneEmptyLineRegex;
  61220. private _textureMatrix;
  61221. private _onLoad;
  61222. /**
  61223. * Instantiates a ColorGradingTexture from the following parameters.
  61224. *
  61225. * @param url The location of the color gradind data (currently only supporting 3dl)
  61226. * @param sceneOrEngine The scene or engine the texture will be used in
  61227. * @param onLoad defines a callback triggered when the texture has been loaded
  61228. */
  61229. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  61230. /**
  61231. * Fires the onload event from the constructor if requested.
  61232. */
  61233. private _triggerOnLoad;
  61234. /**
  61235. * Returns the texture matrix used in most of the material.
  61236. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  61237. */
  61238. getTextureMatrix(): Matrix;
  61239. /**
  61240. * Occurs when the file being loaded is a .3dl LUT file.
  61241. */
  61242. private load3dlTexture;
  61243. /**
  61244. * Starts the loading process of the texture.
  61245. */
  61246. private loadTexture;
  61247. /**
  61248. * Clones the color gradind texture.
  61249. */
  61250. clone(): ColorGradingTexture;
  61251. /**
  61252. * Called during delayed load for textures.
  61253. */
  61254. delayLoad(): void;
  61255. /**
  61256. * Parses a color grading texture serialized by Babylon.
  61257. * @param parsedTexture The texture information being parsedTexture
  61258. * @param scene The scene to load the texture in
  61259. * @param rootUrl The root url of the data assets to load
  61260. * @return A color gradind texture
  61261. */
  61262. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  61263. /**
  61264. * Serializes the LUT texture to json format.
  61265. */
  61266. serialize(): any;
  61267. }
  61268. }
  61269. declare module BABYLON {
  61270. /**
  61271. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  61272. */
  61273. export class EquiRectangularCubeTexture extends BaseTexture {
  61274. /** The six faces of the cube. */
  61275. private static _FacesMapping;
  61276. private _noMipmap;
  61277. private _onLoad;
  61278. private _onError;
  61279. /** The size of the cubemap. */
  61280. private _size;
  61281. /** The buffer of the image. */
  61282. private _buffer;
  61283. /** The width of the input image. */
  61284. private _width;
  61285. /** The height of the input image. */
  61286. private _height;
  61287. /** The URL to the image. */
  61288. url: string;
  61289. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  61290. coordinatesMode: number;
  61291. /**
  61292. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  61293. * @param url The location of the image
  61294. * @param scene The scene the texture will be used in
  61295. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61296. * @param noMipmap Forces to not generate the mipmap if true
  61297. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61298. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61299. * @param onLoad — defines a callback called when texture is loaded
  61300. * @param onError — defines a callback called if there is an error
  61301. */
  61302. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  61303. /**
  61304. * Load the image data, by putting the image on a canvas and extracting its buffer.
  61305. */
  61306. private loadImage;
  61307. /**
  61308. * Convert the image buffer into a cubemap and create a CubeTexture.
  61309. */
  61310. private loadTexture;
  61311. /**
  61312. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  61313. * @param buffer The ArrayBuffer that should be converted.
  61314. * @returns The buffer as Float32Array.
  61315. */
  61316. private getFloat32ArrayFromArrayBuffer;
  61317. /**
  61318. * Get the current class name of the texture useful for serialization or dynamic coding.
  61319. * @returns "EquiRectangularCubeTexture"
  61320. */
  61321. getClassName(): string;
  61322. /**
  61323. * Create a clone of the current EquiRectangularCubeTexture and return it.
  61324. * @returns A clone of the current EquiRectangularCubeTexture.
  61325. */
  61326. clone(): EquiRectangularCubeTexture;
  61327. }
  61328. }
  61329. declare module BABYLON {
  61330. /**
  61331. * Defines the options related to the creation of an HtmlElementTexture
  61332. */
  61333. export interface IHtmlElementTextureOptions {
  61334. /**
  61335. * Defines wether mip maps should be created or not.
  61336. */
  61337. generateMipMaps?: boolean;
  61338. /**
  61339. * Defines the sampling mode of the texture.
  61340. */
  61341. samplingMode?: number;
  61342. /**
  61343. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  61344. */
  61345. engine: Nullable<ThinEngine>;
  61346. /**
  61347. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  61348. */
  61349. scene: Nullable<Scene>;
  61350. }
  61351. /**
  61352. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  61353. * To be as efficient as possible depending on your constraints nothing aside the first upload
  61354. * is automatically managed.
  61355. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  61356. * in your application.
  61357. *
  61358. * As the update is not automatic, you need to call them manually.
  61359. */
  61360. export class HtmlElementTexture extends BaseTexture {
  61361. /**
  61362. * The texture URL.
  61363. */
  61364. element: HTMLVideoElement | HTMLCanvasElement;
  61365. private static readonly DefaultOptions;
  61366. private _textureMatrix;
  61367. private _isVideo;
  61368. private _generateMipMaps;
  61369. private _samplingMode;
  61370. /**
  61371. * Instantiates a HtmlElementTexture from the following parameters.
  61372. *
  61373. * @param name Defines the name of the texture
  61374. * @param element Defines the video or canvas the texture is filled with
  61375. * @param options Defines the other none mandatory texture creation options
  61376. */
  61377. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  61378. private _createInternalTexture;
  61379. /**
  61380. * Returns the texture matrix used in most of the material.
  61381. */
  61382. getTextureMatrix(): Matrix;
  61383. /**
  61384. * Updates the content of the texture.
  61385. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  61386. */
  61387. update(invertY?: Nullable<boolean>): void;
  61388. }
  61389. }
  61390. declare module BABYLON {
  61391. /**
  61392. * Based on jsTGALoader - Javascript loader for TGA file
  61393. * By Vincent Thibault
  61394. * @see http://blog.robrowser.com/javascript-tga-loader.html
  61395. */
  61396. export class TGATools {
  61397. private static _TYPE_INDEXED;
  61398. private static _TYPE_RGB;
  61399. private static _TYPE_GREY;
  61400. private static _TYPE_RLE_INDEXED;
  61401. private static _TYPE_RLE_RGB;
  61402. private static _TYPE_RLE_GREY;
  61403. private static _ORIGIN_MASK;
  61404. private static _ORIGIN_SHIFT;
  61405. private static _ORIGIN_BL;
  61406. private static _ORIGIN_BR;
  61407. private static _ORIGIN_UL;
  61408. private static _ORIGIN_UR;
  61409. /**
  61410. * Gets the header of a TGA file
  61411. * @param data defines the TGA data
  61412. * @returns the header
  61413. */
  61414. static GetTGAHeader(data: Uint8Array): any;
  61415. /**
  61416. * Uploads TGA content to a Babylon Texture
  61417. * @hidden
  61418. */
  61419. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  61420. /** @hidden */
  61421. 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;
  61422. /** @hidden */
  61423. 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;
  61424. /** @hidden */
  61425. 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;
  61426. /** @hidden */
  61427. 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;
  61428. /** @hidden */
  61429. 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;
  61430. /** @hidden */
  61431. 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;
  61432. }
  61433. }
  61434. declare module BABYLON {
  61435. /**
  61436. * Implementation of the TGA Texture Loader.
  61437. * @hidden
  61438. */
  61439. export class _TGATextureLoader implements IInternalTextureLoader {
  61440. /**
  61441. * Defines wether the loader supports cascade loading the different faces.
  61442. */
  61443. readonly supportCascades: boolean;
  61444. /**
  61445. * This returns if the loader support the current file information.
  61446. * @param extension defines the file extension of the file being loaded
  61447. * @returns true if the loader can load the specified file
  61448. */
  61449. canLoad(extension: string): boolean;
  61450. /**
  61451. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61452. * @param data contains the texture data
  61453. * @param texture defines the BabylonJS internal texture
  61454. * @param createPolynomials will be true if polynomials have been requested
  61455. * @param onLoad defines the callback to trigger once the texture is ready
  61456. * @param onError defines the callback to trigger in case of error
  61457. */
  61458. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61459. /**
  61460. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61461. * @param data contains the texture data
  61462. * @param texture defines the BabylonJS internal texture
  61463. * @param callback defines the method to call once ready to upload
  61464. */
  61465. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61466. }
  61467. }
  61468. declare module BABYLON {
  61469. /**
  61470. * Info about the .basis files
  61471. */
  61472. class BasisFileInfo {
  61473. /**
  61474. * If the file has alpha
  61475. */
  61476. hasAlpha: boolean;
  61477. /**
  61478. * Info about each image of the basis file
  61479. */
  61480. images: Array<{
  61481. levels: Array<{
  61482. width: number;
  61483. height: number;
  61484. transcodedPixels: ArrayBufferView;
  61485. }>;
  61486. }>;
  61487. }
  61488. /**
  61489. * Result of transcoding a basis file
  61490. */
  61491. class TranscodeResult {
  61492. /**
  61493. * Info about the .basis file
  61494. */
  61495. fileInfo: BasisFileInfo;
  61496. /**
  61497. * Format to use when loading the file
  61498. */
  61499. format: number;
  61500. }
  61501. /**
  61502. * Configuration options for the Basis transcoder
  61503. */
  61504. export class BasisTranscodeConfiguration {
  61505. /**
  61506. * Supported compression formats used to determine the supported output format of the transcoder
  61507. */
  61508. supportedCompressionFormats?: {
  61509. /**
  61510. * etc1 compression format
  61511. */
  61512. etc1?: boolean;
  61513. /**
  61514. * s3tc compression format
  61515. */
  61516. s3tc?: boolean;
  61517. /**
  61518. * pvrtc compression format
  61519. */
  61520. pvrtc?: boolean;
  61521. /**
  61522. * etc2 compression format
  61523. */
  61524. etc2?: boolean;
  61525. };
  61526. /**
  61527. * If mipmap levels should be loaded for transcoded images (Default: true)
  61528. */
  61529. loadMipmapLevels?: boolean;
  61530. /**
  61531. * Index of a single image to load (Default: all images)
  61532. */
  61533. loadSingleImage?: number;
  61534. }
  61535. /**
  61536. * Used to load .Basis files
  61537. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  61538. */
  61539. export class BasisTools {
  61540. private static _IgnoreSupportedFormats;
  61541. /**
  61542. * URL to use when loading the basis transcoder
  61543. */
  61544. static JSModuleURL: string;
  61545. /**
  61546. * URL to use when loading the wasm module for the transcoder
  61547. */
  61548. static WasmModuleURL: string;
  61549. /**
  61550. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  61551. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  61552. * @returns internal format corresponding to the Basis format
  61553. */
  61554. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  61555. private static _WorkerPromise;
  61556. private static _Worker;
  61557. private static _actionId;
  61558. private static _CreateWorkerAsync;
  61559. /**
  61560. * Transcodes a loaded image file to compressed pixel data
  61561. * @param data image data to transcode
  61562. * @param config configuration options for the transcoding
  61563. * @returns a promise resulting in the transcoded image
  61564. */
  61565. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  61566. /**
  61567. * Loads a texture from the transcode result
  61568. * @param texture texture load to
  61569. * @param transcodeResult the result of transcoding the basis file to load from
  61570. */
  61571. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  61572. }
  61573. }
  61574. declare module BABYLON {
  61575. /**
  61576. * Loader for .basis file format
  61577. */
  61578. export class _BasisTextureLoader implements IInternalTextureLoader {
  61579. /**
  61580. * Defines whether the loader supports cascade loading the different faces.
  61581. */
  61582. readonly supportCascades: boolean;
  61583. /**
  61584. * This returns if the loader support the current file information.
  61585. * @param extension defines the file extension of the file being loaded
  61586. * @returns true if the loader can load the specified file
  61587. */
  61588. canLoad(extension: string): boolean;
  61589. /**
  61590. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61591. * @param data contains the texture data
  61592. * @param texture defines the BabylonJS internal texture
  61593. * @param createPolynomials will be true if polynomials have been requested
  61594. * @param onLoad defines the callback to trigger once the texture is ready
  61595. * @param onError defines the callback to trigger in case of error
  61596. */
  61597. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61598. /**
  61599. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61600. * @param data contains the texture data
  61601. * @param texture defines the BabylonJS internal texture
  61602. * @param callback defines the method to call once ready to upload
  61603. */
  61604. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61605. }
  61606. }
  61607. declare module BABYLON {
  61608. /**
  61609. * Defines the basic options interface of a TexturePacker Frame
  61610. */
  61611. export interface ITexturePackerFrame {
  61612. /**
  61613. * The frame ID
  61614. */
  61615. id: number;
  61616. /**
  61617. * The frames Scale
  61618. */
  61619. scale: Vector2;
  61620. /**
  61621. * The Frames offset
  61622. */
  61623. offset: Vector2;
  61624. }
  61625. /**
  61626. * This is a support class for frame Data on texture packer sets.
  61627. */
  61628. export class TexturePackerFrame implements ITexturePackerFrame {
  61629. /**
  61630. * The frame ID
  61631. */
  61632. id: number;
  61633. /**
  61634. * The frames Scale
  61635. */
  61636. scale: Vector2;
  61637. /**
  61638. * The Frames offset
  61639. */
  61640. offset: Vector2;
  61641. /**
  61642. * Initializes a texture package frame.
  61643. * @param id The numerical frame identifier
  61644. * @param scale Scalar Vector2 for UV frame
  61645. * @param offset Vector2 for the frame position in UV units.
  61646. * @returns TexturePackerFrame
  61647. */
  61648. constructor(id: number, scale: Vector2, offset: Vector2);
  61649. }
  61650. }
  61651. declare module BABYLON {
  61652. /**
  61653. * Defines the basic options interface of a TexturePacker
  61654. */
  61655. export interface ITexturePackerOptions {
  61656. /**
  61657. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  61658. */
  61659. map?: string[];
  61660. /**
  61661. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61662. */
  61663. uvsIn?: string;
  61664. /**
  61665. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61666. */
  61667. uvsOut?: string;
  61668. /**
  61669. * number representing the layout style. Defaults to LAYOUT_STRIP
  61670. */
  61671. layout?: number;
  61672. /**
  61673. * number of columns if using custom column count layout(2). This defaults to 4.
  61674. */
  61675. colnum?: number;
  61676. /**
  61677. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  61678. */
  61679. updateInputMeshes?: boolean;
  61680. /**
  61681. * boolean flag to dispose all the source textures. Defaults to true.
  61682. */
  61683. disposeSources?: boolean;
  61684. /**
  61685. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  61686. */
  61687. fillBlanks?: boolean;
  61688. /**
  61689. * string value representing the context fill style color. Defaults to 'black'.
  61690. */
  61691. customFillColor?: string;
  61692. /**
  61693. * Width and Height Value of each Frame in the TexturePacker Sets
  61694. */
  61695. frameSize?: number;
  61696. /**
  61697. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  61698. */
  61699. paddingRatio?: number;
  61700. /**
  61701. * Number that declares the fill method for the padding gutter.
  61702. */
  61703. paddingMode?: number;
  61704. /**
  61705. * If in SUBUV_COLOR padding mode what color to use.
  61706. */
  61707. paddingColor?: Color3 | Color4;
  61708. }
  61709. /**
  61710. * Defines the basic interface of a TexturePacker JSON File
  61711. */
  61712. export interface ITexturePackerJSON {
  61713. /**
  61714. * The frame ID
  61715. */
  61716. name: string;
  61717. /**
  61718. * The base64 channel data
  61719. */
  61720. sets: any;
  61721. /**
  61722. * The options of the Packer
  61723. */
  61724. options: ITexturePackerOptions;
  61725. /**
  61726. * The frame data of the Packer
  61727. */
  61728. frames: Array<number>;
  61729. }
  61730. /**
  61731. * This is a support class that generates a series of packed texture sets.
  61732. * @see https://doc.babylonjs.com/babylon101/materials
  61733. */
  61734. export class TexturePacker {
  61735. /** Packer Layout Constant 0 */
  61736. static readonly LAYOUT_STRIP: number;
  61737. /** Packer Layout Constant 1 */
  61738. static readonly LAYOUT_POWER2: number;
  61739. /** Packer Layout Constant 2 */
  61740. static readonly LAYOUT_COLNUM: number;
  61741. /** Packer Layout Constant 0 */
  61742. static readonly SUBUV_WRAP: number;
  61743. /** Packer Layout Constant 1 */
  61744. static readonly SUBUV_EXTEND: number;
  61745. /** Packer Layout Constant 2 */
  61746. static readonly SUBUV_COLOR: number;
  61747. /** The Name of the Texture Package */
  61748. name: string;
  61749. /** The scene scope of the TexturePacker */
  61750. scene: Scene;
  61751. /** The Meshes to target */
  61752. meshes: AbstractMesh[];
  61753. /** Arguments passed with the Constructor */
  61754. options: ITexturePackerOptions;
  61755. /** The promise that is started upon initialization */
  61756. promise: Nullable<Promise<TexturePacker | string>>;
  61757. /** The Container object for the channel sets that are generated */
  61758. sets: object;
  61759. /** The Container array for the frames that are generated */
  61760. frames: TexturePackerFrame[];
  61761. /** The expected number of textures the system is parsing. */
  61762. private _expecting;
  61763. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  61764. private _paddingValue;
  61765. /**
  61766. * Initializes a texture package series from an array of meshes or a single mesh.
  61767. * @param name The name of the package
  61768. * @param meshes The target meshes to compose the package from
  61769. * @param options The arguments that texture packer should follow while building.
  61770. * @param scene The scene which the textures are scoped to.
  61771. * @returns TexturePacker
  61772. */
  61773. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  61774. /**
  61775. * Starts the package process
  61776. * @param resolve The promises resolution function
  61777. * @returns TexturePacker
  61778. */
  61779. private _createFrames;
  61780. /**
  61781. * Calculates the Size of the Channel Sets
  61782. * @returns Vector2
  61783. */
  61784. private _calculateSize;
  61785. /**
  61786. * Calculates the UV data for the frames.
  61787. * @param baseSize the base frameSize
  61788. * @param padding the base frame padding
  61789. * @param dtSize size of the Dynamic Texture for that channel
  61790. * @param dtUnits is 1/dtSize
  61791. * @param update flag to update the input meshes
  61792. */
  61793. private _calculateMeshUVFrames;
  61794. /**
  61795. * Calculates the frames Offset.
  61796. * @param index of the frame
  61797. * @returns Vector2
  61798. */
  61799. private _getFrameOffset;
  61800. /**
  61801. * Updates a Mesh to the frame data
  61802. * @param mesh that is the target
  61803. * @param frameID or the frame index
  61804. */
  61805. private _updateMeshUV;
  61806. /**
  61807. * Updates a Meshes materials to use the texture packer channels
  61808. * @param m is the mesh to target
  61809. * @param force all channels on the packer to be set.
  61810. */
  61811. private _updateTextureReferences;
  61812. /**
  61813. * Public method to set a Mesh to a frame
  61814. * @param m that is the target
  61815. * @param frameID or the frame index
  61816. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  61817. */
  61818. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  61819. /**
  61820. * Starts the async promise to compile the texture packer.
  61821. * @returns Promise<void>
  61822. */
  61823. processAsync(): Promise<void>;
  61824. /**
  61825. * Disposes all textures associated with this packer
  61826. */
  61827. dispose(): void;
  61828. /**
  61829. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  61830. * @param imageType is the image type to use.
  61831. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  61832. */
  61833. download(imageType?: string, quality?: number): void;
  61834. /**
  61835. * Public method to load a texturePacker JSON file.
  61836. * @param data of the JSON file in string format.
  61837. */
  61838. updateFromJSON(data: string): void;
  61839. }
  61840. }
  61841. declare module BABYLON {
  61842. /**
  61843. * 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.
  61844. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61845. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61846. */
  61847. export class CustomProceduralTexture extends ProceduralTexture {
  61848. private _animate;
  61849. private _time;
  61850. private _config;
  61851. private _texturePath;
  61852. /**
  61853. * Instantiates a new Custom Procedural Texture.
  61854. * 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.
  61855. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61856. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61857. * @param name Define the name of the texture
  61858. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  61859. * @param size Define the size of the texture to create
  61860. * @param scene Define the scene the texture belongs to
  61861. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  61862. * @param generateMipMaps Define if the texture should creates mip maps or not
  61863. */
  61864. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61865. private _loadJson;
  61866. /**
  61867. * Is the texture ready to be used ? (rendered at least once)
  61868. * @returns true if ready, otherwise, false.
  61869. */
  61870. isReady(): boolean;
  61871. /**
  61872. * Render the texture to its associated render target.
  61873. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  61874. */
  61875. render(useCameraPostProcess?: boolean): void;
  61876. /**
  61877. * Update the list of dependant textures samplers in the shader.
  61878. */
  61879. updateTextures(): void;
  61880. /**
  61881. * Update the uniform values of the procedural texture in the shader.
  61882. */
  61883. updateShaderUniforms(): void;
  61884. /**
  61885. * Define if the texture animates or not.
  61886. */
  61887. get animate(): boolean;
  61888. set animate(value: boolean);
  61889. }
  61890. }
  61891. declare module BABYLON {
  61892. /** @hidden */
  61893. export var noisePixelShader: {
  61894. name: string;
  61895. shader: string;
  61896. };
  61897. }
  61898. declare module BABYLON {
  61899. /**
  61900. * Class used to generate noise procedural textures
  61901. */
  61902. export class NoiseProceduralTexture extends ProceduralTexture {
  61903. private _time;
  61904. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  61905. brightness: number;
  61906. /** Defines the number of octaves to process */
  61907. octaves: number;
  61908. /** Defines the level of persistence (0.8 by default) */
  61909. persistence: number;
  61910. /** Gets or sets animation speed factor (default is 1) */
  61911. animationSpeedFactor: number;
  61912. /**
  61913. * Creates a new NoiseProceduralTexture
  61914. * @param name defines the name fo the texture
  61915. * @param size defines the size of the texture (default is 256)
  61916. * @param scene defines the hosting scene
  61917. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  61918. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  61919. */
  61920. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61921. private _updateShaderUniforms;
  61922. protected _getDefines(): string;
  61923. /** Generate the current state of the procedural texture */
  61924. render(useCameraPostProcess?: boolean): void;
  61925. /**
  61926. * Serializes this noise procedural texture
  61927. * @returns a serialized noise procedural texture object
  61928. */
  61929. serialize(): any;
  61930. /**
  61931. * Clone the texture.
  61932. * @returns the cloned texture
  61933. */
  61934. clone(): NoiseProceduralTexture;
  61935. /**
  61936. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  61937. * @param parsedTexture defines parsed texture data
  61938. * @param scene defines the current scene
  61939. * @param rootUrl defines the root URL containing noise procedural texture information
  61940. * @returns a parsed NoiseProceduralTexture
  61941. */
  61942. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  61943. }
  61944. }
  61945. declare module BABYLON {
  61946. /**
  61947. * Raw cube texture where the raw buffers are passed in
  61948. */
  61949. export class RawCubeTexture extends CubeTexture {
  61950. /**
  61951. * Creates a cube texture where the raw buffers are passed in.
  61952. * @param scene defines the scene the texture is attached to
  61953. * @param data defines the array of data to use to create each face
  61954. * @param size defines the size of the textures
  61955. * @param format defines the format of the data
  61956. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  61957. * @param generateMipMaps defines if the engine should generate the mip levels
  61958. * @param invertY defines if data must be stored with Y axis inverted
  61959. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  61960. * @param compression defines the compression used (null by default)
  61961. */
  61962. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  61963. /**
  61964. * Updates the raw cube texture.
  61965. * @param data defines the data to store
  61966. * @param format defines the data format
  61967. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61968. * @param invertY defines if data must be stored with Y axis inverted
  61969. * @param compression defines the compression used (null by default)
  61970. * @param level defines which level of the texture to update
  61971. */
  61972. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  61973. /**
  61974. * Updates a raw cube texture with RGBD encoded data.
  61975. * @param data defines the array of data [mipmap][face] to use to create each face
  61976. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  61977. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  61978. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  61979. * @returns a promsie that resolves when the operation is complete
  61980. */
  61981. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  61982. /**
  61983. * Clones the raw cube texture.
  61984. * @return a new cube texture
  61985. */
  61986. clone(): CubeTexture;
  61987. /** @hidden */
  61988. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  61989. }
  61990. }
  61991. declare module BABYLON {
  61992. /**
  61993. * Class used to store 2D array textures containing user data
  61994. */
  61995. export class RawTexture2DArray extends Texture {
  61996. /** Gets or sets the texture format to use */
  61997. format: number;
  61998. /**
  61999. * Create a new RawTexture2DArray
  62000. * @param data defines the data of the texture
  62001. * @param width defines the width of the texture
  62002. * @param height defines the height of the texture
  62003. * @param depth defines the number of layers of the texture
  62004. * @param format defines the texture format to use
  62005. * @param scene defines the hosting scene
  62006. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62007. * @param invertY defines if texture must be stored with Y axis inverted
  62008. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62009. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62010. */
  62011. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62012. /** Gets or sets the texture format to use */
  62013. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62014. /**
  62015. * Update the texture with new data
  62016. * @param data defines the data to store in the texture
  62017. */
  62018. update(data: ArrayBufferView): void;
  62019. }
  62020. }
  62021. declare module BABYLON {
  62022. /**
  62023. * Class used to store 3D textures containing user data
  62024. */
  62025. export class RawTexture3D extends Texture {
  62026. /** Gets or sets the texture format to use */
  62027. format: number;
  62028. /**
  62029. * Create a new RawTexture3D
  62030. * @param data defines the data of the texture
  62031. * @param width defines the width of the texture
  62032. * @param height defines the height of the texture
  62033. * @param depth defines the depth of the texture
  62034. * @param format defines the texture format to use
  62035. * @param scene defines the hosting scene
  62036. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62037. * @param invertY defines if texture must be stored with Y axis inverted
  62038. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62039. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62040. */
  62041. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62042. /** Gets or sets the texture format to use */
  62043. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62044. /**
  62045. * Update the texture with new data
  62046. * @param data defines the data to store in the texture
  62047. */
  62048. update(data: ArrayBufferView): void;
  62049. }
  62050. }
  62051. declare module BABYLON {
  62052. /**
  62053. * Creates a refraction texture used by refraction channel of the standard material.
  62054. * It is like a mirror but to see through a material.
  62055. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62056. */
  62057. export class RefractionTexture extends RenderTargetTexture {
  62058. /**
  62059. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  62060. * 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.
  62061. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62062. */
  62063. refractionPlane: Plane;
  62064. /**
  62065. * Define how deep under the surface we should see.
  62066. */
  62067. depth: number;
  62068. /**
  62069. * Creates a refraction texture used by refraction channel of the standard material.
  62070. * It is like a mirror but to see through a material.
  62071. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62072. * @param name Define the texture name
  62073. * @param size Define the size of the underlying texture
  62074. * @param scene Define the scene the refraction belongs to
  62075. * @param generateMipMaps Define if we need to generate mips level for the refraction
  62076. */
  62077. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  62078. /**
  62079. * Clone the refraction texture.
  62080. * @returns the cloned texture
  62081. */
  62082. clone(): RefractionTexture;
  62083. /**
  62084. * Serialize the texture to a JSON representation you could use in Parse later on
  62085. * @returns the serialized JSON representation
  62086. */
  62087. serialize(): any;
  62088. }
  62089. }
  62090. declare module BABYLON {
  62091. /**
  62092. * Block used to add support for vertex skinning (bones)
  62093. */
  62094. export class BonesBlock extends NodeMaterialBlock {
  62095. /**
  62096. * Creates a new BonesBlock
  62097. * @param name defines the block name
  62098. */
  62099. constructor(name: string);
  62100. /**
  62101. * Initialize the block and prepare the context for build
  62102. * @param state defines the state that will be used for the build
  62103. */
  62104. initialize(state: NodeMaterialBuildState): void;
  62105. /**
  62106. * Gets the current class name
  62107. * @returns the class name
  62108. */
  62109. getClassName(): string;
  62110. /**
  62111. * Gets the matrix indices input component
  62112. */
  62113. get matricesIndices(): NodeMaterialConnectionPoint;
  62114. /**
  62115. * Gets the matrix weights input component
  62116. */
  62117. get matricesWeights(): NodeMaterialConnectionPoint;
  62118. /**
  62119. * Gets the extra matrix indices input component
  62120. */
  62121. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  62122. /**
  62123. * Gets the extra matrix weights input component
  62124. */
  62125. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  62126. /**
  62127. * Gets the world input component
  62128. */
  62129. get world(): NodeMaterialConnectionPoint;
  62130. /**
  62131. * Gets the output component
  62132. */
  62133. get output(): NodeMaterialConnectionPoint;
  62134. autoConfigure(material: NodeMaterial): void;
  62135. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  62136. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62137. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62138. protected _buildBlock(state: NodeMaterialBuildState): this;
  62139. }
  62140. }
  62141. declare module BABYLON {
  62142. /**
  62143. * Block used to add support for instances
  62144. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  62145. */
  62146. export class InstancesBlock extends NodeMaterialBlock {
  62147. /**
  62148. * Creates a new InstancesBlock
  62149. * @param name defines the block name
  62150. */
  62151. constructor(name: string);
  62152. /**
  62153. * Gets the current class name
  62154. * @returns the class name
  62155. */
  62156. getClassName(): string;
  62157. /**
  62158. * Gets the first world row input component
  62159. */
  62160. get world0(): NodeMaterialConnectionPoint;
  62161. /**
  62162. * Gets the second world row input component
  62163. */
  62164. get world1(): NodeMaterialConnectionPoint;
  62165. /**
  62166. * Gets the third world row input component
  62167. */
  62168. get world2(): NodeMaterialConnectionPoint;
  62169. /**
  62170. * Gets the forth world row input component
  62171. */
  62172. get world3(): NodeMaterialConnectionPoint;
  62173. /**
  62174. * Gets the world input component
  62175. */
  62176. get world(): NodeMaterialConnectionPoint;
  62177. /**
  62178. * Gets the output component
  62179. */
  62180. get output(): NodeMaterialConnectionPoint;
  62181. /**
  62182. * Gets the isntanceID component
  62183. */
  62184. get instanceID(): NodeMaterialConnectionPoint;
  62185. autoConfigure(material: NodeMaterial): void;
  62186. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  62187. protected _buildBlock(state: NodeMaterialBuildState): this;
  62188. }
  62189. }
  62190. declare module BABYLON {
  62191. /**
  62192. * Block used to add morph targets support to vertex shader
  62193. */
  62194. export class MorphTargetsBlock extends NodeMaterialBlock {
  62195. private _repeatableContentAnchor;
  62196. /**
  62197. * Create a new MorphTargetsBlock
  62198. * @param name defines the block name
  62199. */
  62200. constructor(name: string);
  62201. /**
  62202. * Gets the current class name
  62203. * @returns the class name
  62204. */
  62205. getClassName(): string;
  62206. /**
  62207. * Gets the position input component
  62208. */
  62209. get position(): NodeMaterialConnectionPoint;
  62210. /**
  62211. * Gets the normal input component
  62212. */
  62213. get normal(): NodeMaterialConnectionPoint;
  62214. /**
  62215. * Gets the tangent input component
  62216. */
  62217. get tangent(): NodeMaterialConnectionPoint;
  62218. /**
  62219. * Gets the tangent input component
  62220. */
  62221. get uv(): NodeMaterialConnectionPoint;
  62222. /**
  62223. * Gets the position output component
  62224. */
  62225. get positionOutput(): NodeMaterialConnectionPoint;
  62226. /**
  62227. * Gets the normal output component
  62228. */
  62229. get normalOutput(): NodeMaterialConnectionPoint;
  62230. /**
  62231. * Gets the tangent output component
  62232. */
  62233. get tangentOutput(): NodeMaterialConnectionPoint;
  62234. /**
  62235. * Gets the tangent output component
  62236. */
  62237. get uvOutput(): NodeMaterialConnectionPoint;
  62238. initialize(state: NodeMaterialBuildState): void;
  62239. autoConfigure(material: NodeMaterial): void;
  62240. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62241. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62242. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  62243. protected _buildBlock(state: NodeMaterialBuildState): this;
  62244. }
  62245. }
  62246. declare module BABYLON {
  62247. /**
  62248. * Block used to get data information from a light
  62249. */
  62250. export class LightInformationBlock extends NodeMaterialBlock {
  62251. private _lightDataUniformName;
  62252. private _lightColorUniformName;
  62253. private _lightTypeDefineName;
  62254. /**
  62255. * Gets or sets the light associated with this block
  62256. */
  62257. light: Nullable<Light>;
  62258. /**
  62259. * Creates a new LightInformationBlock
  62260. * @param name defines the block name
  62261. */
  62262. constructor(name: string);
  62263. /**
  62264. * Gets the current class name
  62265. * @returns the class name
  62266. */
  62267. getClassName(): string;
  62268. /**
  62269. * Gets the world position input component
  62270. */
  62271. get worldPosition(): NodeMaterialConnectionPoint;
  62272. /**
  62273. * Gets the direction output component
  62274. */
  62275. get direction(): NodeMaterialConnectionPoint;
  62276. /**
  62277. * Gets the direction output component
  62278. */
  62279. get color(): NodeMaterialConnectionPoint;
  62280. /**
  62281. * Gets the direction output component
  62282. */
  62283. get intensity(): NodeMaterialConnectionPoint;
  62284. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62285. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62286. protected _buildBlock(state: NodeMaterialBuildState): this;
  62287. serialize(): any;
  62288. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62289. }
  62290. }
  62291. declare module BABYLON {
  62292. /**
  62293. * Block used to add image processing support to fragment shader
  62294. */
  62295. export class ImageProcessingBlock extends NodeMaterialBlock {
  62296. /**
  62297. * Create a new ImageProcessingBlock
  62298. * @param name defines the block name
  62299. */
  62300. constructor(name: string);
  62301. /**
  62302. * Gets the current class name
  62303. * @returns the class name
  62304. */
  62305. getClassName(): string;
  62306. /**
  62307. * Gets the color input component
  62308. */
  62309. get color(): NodeMaterialConnectionPoint;
  62310. /**
  62311. * Gets the output component
  62312. */
  62313. get output(): NodeMaterialConnectionPoint;
  62314. /**
  62315. * Initialize the block and prepare the context for build
  62316. * @param state defines the state that will be used for the build
  62317. */
  62318. initialize(state: NodeMaterialBuildState): void;
  62319. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  62320. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62321. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62322. protected _buildBlock(state: NodeMaterialBuildState): this;
  62323. }
  62324. }
  62325. declare module BABYLON {
  62326. /**
  62327. * Block used to pertub normals based on a normal map
  62328. */
  62329. export class PerturbNormalBlock extends NodeMaterialBlock {
  62330. private _tangentSpaceParameterName;
  62331. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62332. invertX: boolean;
  62333. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  62334. invertY: boolean;
  62335. /**
  62336. * Create a new PerturbNormalBlock
  62337. * @param name defines the block name
  62338. */
  62339. constructor(name: string);
  62340. /**
  62341. * Gets the current class name
  62342. * @returns the class name
  62343. */
  62344. getClassName(): string;
  62345. /**
  62346. * Gets the world position input component
  62347. */
  62348. get worldPosition(): NodeMaterialConnectionPoint;
  62349. /**
  62350. * Gets the world normal input component
  62351. */
  62352. get worldNormal(): NodeMaterialConnectionPoint;
  62353. /**
  62354. * Gets the world tangent input component
  62355. */
  62356. get worldTangent(): NodeMaterialConnectionPoint;
  62357. /**
  62358. * Gets the uv input component
  62359. */
  62360. get uv(): NodeMaterialConnectionPoint;
  62361. /**
  62362. * Gets the normal map color input component
  62363. */
  62364. get normalMapColor(): NodeMaterialConnectionPoint;
  62365. /**
  62366. * Gets the strength input component
  62367. */
  62368. get strength(): NodeMaterialConnectionPoint;
  62369. /**
  62370. * Gets the output component
  62371. */
  62372. get output(): NodeMaterialConnectionPoint;
  62373. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62374. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62375. autoConfigure(material: NodeMaterial): void;
  62376. protected _buildBlock(state: NodeMaterialBuildState): this;
  62377. protected _dumpPropertiesCode(): string;
  62378. serialize(): any;
  62379. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62380. }
  62381. }
  62382. declare module BABYLON {
  62383. /**
  62384. * Block used to discard a pixel if a value is smaller than a cutoff
  62385. */
  62386. export class DiscardBlock extends NodeMaterialBlock {
  62387. /**
  62388. * Create a new DiscardBlock
  62389. * @param name defines the block name
  62390. */
  62391. constructor(name: string);
  62392. /**
  62393. * Gets the current class name
  62394. * @returns the class name
  62395. */
  62396. getClassName(): string;
  62397. /**
  62398. * Gets the color input component
  62399. */
  62400. get value(): NodeMaterialConnectionPoint;
  62401. /**
  62402. * Gets the cutoff input component
  62403. */
  62404. get cutoff(): NodeMaterialConnectionPoint;
  62405. protected _buildBlock(state: NodeMaterialBuildState): this;
  62406. }
  62407. }
  62408. declare module BABYLON {
  62409. /**
  62410. * Block used to test if the fragment shader is front facing
  62411. */
  62412. export class FrontFacingBlock extends NodeMaterialBlock {
  62413. /**
  62414. * Creates a new FrontFacingBlock
  62415. * @param name defines the block name
  62416. */
  62417. constructor(name: string);
  62418. /**
  62419. * Gets the current class name
  62420. * @returns the class name
  62421. */
  62422. getClassName(): string;
  62423. /**
  62424. * Gets the output component
  62425. */
  62426. get output(): NodeMaterialConnectionPoint;
  62427. protected _buildBlock(state: NodeMaterialBuildState): this;
  62428. }
  62429. }
  62430. declare module BABYLON {
  62431. /**
  62432. * Block used to get the derivative value on x and y of a given input
  62433. */
  62434. export class DerivativeBlock extends NodeMaterialBlock {
  62435. /**
  62436. * Create a new DerivativeBlock
  62437. * @param name defines the block name
  62438. */
  62439. constructor(name: string);
  62440. /**
  62441. * Gets the current class name
  62442. * @returns the class name
  62443. */
  62444. getClassName(): string;
  62445. /**
  62446. * Gets the input component
  62447. */
  62448. get input(): NodeMaterialConnectionPoint;
  62449. /**
  62450. * Gets the derivative output on x
  62451. */
  62452. get dx(): NodeMaterialConnectionPoint;
  62453. /**
  62454. * Gets the derivative output on y
  62455. */
  62456. get dy(): NodeMaterialConnectionPoint;
  62457. protected _buildBlock(state: NodeMaterialBuildState): this;
  62458. }
  62459. }
  62460. declare module BABYLON {
  62461. /**
  62462. * Block used to make gl_FragCoord available
  62463. */
  62464. export class FragCoordBlock extends NodeMaterialBlock {
  62465. /**
  62466. * Creates a new FragCoordBlock
  62467. * @param name defines the block name
  62468. */
  62469. constructor(name: string);
  62470. /**
  62471. * Gets the current class name
  62472. * @returns the class name
  62473. */
  62474. getClassName(): string;
  62475. /**
  62476. * Gets the xy component
  62477. */
  62478. get xy(): NodeMaterialConnectionPoint;
  62479. /**
  62480. * Gets the xyz component
  62481. */
  62482. get xyz(): NodeMaterialConnectionPoint;
  62483. /**
  62484. * Gets the xyzw component
  62485. */
  62486. get xyzw(): NodeMaterialConnectionPoint;
  62487. /**
  62488. * Gets the x component
  62489. */
  62490. get x(): NodeMaterialConnectionPoint;
  62491. /**
  62492. * Gets the y component
  62493. */
  62494. get y(): NodeMaterialConnectionPoint;
  62495. /**
  62496. * Gets the z component
  62497. */
  62498. get z(): NodeMaterialConnectionPoint;
  62499. /**
  62500. * Gets the w component
  62501. */
  62502. get output(): NodeMaterialConnectionPoint;
  62503. protected writeOutputs(state: NodeMaterialBuildState): string;
  62504. protected _buildBlock(state: NodeMaterialBuildState): this;
  62505. }
  62506. }
  62507. declare module BABYLON {
  62508. /**
  62509. * Block used to get the screen sizes
  62510. */
  62511. export class ScreenSizeBlock extends NodeMaterialBlock {
  62512. private _varName;
  62513. private _scene;
  62514. /**
  62515. * Creates a new ScreenSizeBlock
  62516. * @param name defines the block name
  62517. */
  62518. constructor(name: string);
  62519. /**
  62520. * Gets the current class name
  62521. * @returns the class name
  62522. */
  62523. getClassName(): string;
  62524. /**
  62525. * Gets the xy component
  62526. */
  62527. get xy(): NodeMaterialConnectionPoint;
  62528. /**
  62529. * Gets the x component
  62530. */
  62531. get x(): NodeMaterialConnectionPoint;
  62532. /**
  62533. * Gets the y component
  62534. */
  62535. get y(): NodeMaterialConnectionPoint;
  62536. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62537. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  62538. protected _buildBlock(state: NodeMaterialBuildState): this;
  62539. }
  62540. }
  62541. declare module BABYLON {
  62542. /**
  62543. * Block used to add support for scene fog
  62544. */
  62545. export class FogBlock extends NodeMaterialBlock {
  62546. private _fogDistanceName;
  62547. private _fogParameters;
  62548. /**
  62549. * Create a new FogBlock
  62550. * @param name defines the block name
  62551. */
  62552. constructor(name: string);
  62553. /**
  62554. * Gets the current class name
  62555. * @returns the class name
  62556. */
  62557. getClassName(): string;
  62558. /**
  62559. * Gets the world position input component
  62560. */
  62561. get worldPosition(): NodeMaterialConnectionPoint;
  62562. /**
  62563. * Gets the view input component
  62564. */
  62565. get view(): NodeMaterialConnectionPoint;
  62566. /**
  62567. * Gets the color input component
  62568. */
  62569. get input(): NodeMaterialConnectionPoint;
  62570. /**
  62571. * Gets the fog color input component
  62572. */
  62573. get fogColor(): NodeMaterialConnectionPoint;
  62574. /**
  62575. * Gets the output component
  62576. */
  62577. get output(): NodeMaterialConnectionPoint;
  62578. autoConfigure(material: NodeMaterial): void;
  62579. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62580. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62581. protected _buildBlock(state: NodeMaterialBuildState): this;
  62582. }
  62583. }
  62584. declare module BABYLON {
  62585. /**
  62586. * Block used to add light in the fragment shader
  62587. */
  62588. export class LightBlock extends NodeMaterialBlock {
  62589. private _lightId;
  62590. /**
  62591. * Gets or sets the light associated with this block
  62592. */
  62593. light: Nullable<Light>;
  62594. /**
  62595. * Create a new LightBlock
  62596. * @param name defines the block name
  62597. */
  62598. constructor(name: string);
  62599. /**
  62600. * Gets the current class name
  62601. * @returns the class name
  62602. */
  62603. getClassName(): string;
  62604. /**
  62605. * Gets the world position input component
  62606. */
  62607. get worldPosition(): NodeMaterialConnectionPoint;
  62608. /**
  62609. * Gets the world normal input component
  62610. */
  62611. get worldNormal(): NodeMaterialConnectionPoint;
  62612. /**
  62613. * Gets the camera (or eye) position component
  62614. */
  62615. get cameraPosition(): NodeMaterialConnectionPoint;
  62616. /**
  62617. * Gets the glossiness component
  62618. */
  62619. get glossiness(): NodeMaterialConnectionPoint;
  62620. /**
  62621. * Gets the glossinness power component
  62622. */
  62623. get glossPower(): NodeMaterialConnectionPoint;
  62624. /**
  62625. * Gets the diffuse color component
  62626. */
  62627. get diffuseColor(): NodeMaterialConnectionPoint;
  62628. /**
  62629. * Gets the specular color component
  62630. */
  62631. get specularColor(): NodeMaterialConnectionPoint;
  62632. /**
  62633. * Gets the diffuse output component
  62634. */
  62635. get diffuseOutput(): NodeMaterialConnectionPoint;
  62636. /**
  62637. * Gets the specular output component
  62638. */
  62639. get specularOutput(): NodeMaterialConnectionPoint;
  62640. /**
  62641. * Gets the shadow output component
  62642. */
  62643. get shadow(): NodeMaterialConnectionPoint;
  62644. autoConfigure(material: NodeMaterial): void;
  62645. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62646. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62647. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62648. private _injectVertexCode;
  62649. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62650. serialize(): any;
  62651. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62652. }
  62653. }
  62654. declare module BABYLON {
  62655. /**
  62656. * Block used to read a reflection texture from a sampler
  62657. */
  62658. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  62659. /**
  62660. * Create a new ReflectionTextureBlock
  62661. * @param name defines the block name
  62662. */
  62663. constructor(name: string);
  62664. /**
  62665. * Gets the current class name
  62666. * @returns the class name
  62667. */
  62668. getClassName(): string;
  62669. /**
  62670. * Gets the world position input component
  62671. */
  62672. get position(): NodeMaterialConnectionPoint;
  62673. /**
  62674. * Gets the world position input component
  62675. */
  62676. get worldPosition(): NodeMaterialConnectionPoint;
  62677. /**
  62678. * Gets the world normal input component
  62679. */
  62680. get worldNormal(): NodeMaterialConnectionPoint;
  62681. /**
  62682. * Gets the world input component
  62683. */
  62684. get world(): NodeMaterialConnectionPoint;
  62685. /**
  62686. * Gets the camera (or eye) position component
  62687. */
  62688. get cameraPosition(): NodeMaterialConnectionPoint;
  62689. /**
  62690. * Gets the view input component
  62691. */
  62692. get view(): NodeMaterialConnectionPoint;
  62693. /**
  62694. * Gets the rgb output component
  62695. */
  62696. get rgb(): NodeMaterialConnectionPoint;
  62697. /**
  62698. * Gets the rgba output component
  62699. */
  62700. get rgba(): NodeMaterialConnectionPoint;
  62701. /**
  62702. * Gets the r output component
  62703. */
  62704. get r(): NodeMaterialConnectionPoint;
  62705. /**
  62706. * Gets the g output component
  62707. */
  62708. get g(): NodeMaterialConnectionPoint;
  62709. /**
  62710. * Gets the b output component
  62711. */
  62712. get b(): NodeMaterialConnectionPoint;
  62713. /**
  62714. * Gets the a output component
  62715. */
  62716. get a(): NodeMaterialConnectionPoint;
  62717. autoConfigure(material: NodeMaterial): void;
  62718. protected _buildBlock(state: NodeMaterialBuildState): this;
  62719. }
  62720. }
  62721. declare module BABYLON {
  62722. /**
  62723. * Block used to add 2 vectors
  62724. */
  62725. export class AddBlock extends NodeMaterialBlock {
  62726. /**
  62727. * Creates a new AddBlock
  62728. * @param name defines the block name
  62729. */
  62730. constructor(name: string);
  62731. /**
  62732. * Gets the current class name
  62733. * @returns the class name
  62734. */
  62735. getClassName(): string;
  62736. /**
  62737. * Gets the left operand input component
  62738. */
  62739. get left(): NodeMaterialConnectionPoint;
  62740. /**
  62741. * Gets the right operand input component
  62742. */
  62743. get right(): NodeMaterialConnectionPoint;
  62744. /**
  62745. * Gets the output component
  62746. */
  62747. get output(): NodeMaterialConnectionPoint;
  62748. protected _buildBlock(state: NodeMaterialBuildState): this;
  62749. }
  62750. }
  62751. declare module BABYLON {
  62752. /**
  62753. * Block used to scale a vector by a float
  62754. */
  62755. export class ScaleBlock extends NodeMaterialBlock {
  62756. /**
  62757. * Creates a new ScaleBlock
  62758. * @param name defines the block name
  62759. */
  62760. constructor(name: string);
  62761. /**
  62762. * Gets the current class name
  62763. * @returns the class name
  62764. */
  62765. getClassName(): string;
  62766. /**
  62767. * Gets the input component
  62768. */
  62769. get input(): NodeMaterialConnectionPoint;
  62770. /**
  62771. * Gets the factor input component
  62772. */
  62773. get factor(): NodeMaterialConnectionPoint;
  62774. /**
  62775. * Gets the output component
  62776. */
  62777. get output(): NodeMaterialConnectionPoint;
  62778. protected _buildBlock(state: NodeMaterialBuildState): this;
  62779. }
  62780. }
  62781. declare module BABYLON {
  62782. /**
  62783. * Block used to clamp a float
  62784. */
  62785. export class ClampBlock extends NodeMaterialBlock {
  62786. /** Gets or sets the minimum range */
  62787. minimum: number;
  62788. /** Gets or sets the maximum range */
  62789. maximum: number;
  62790. /**
  62791. * Creates a new ClampBlock
  62792. * @param name defines the block name
  62793. */
  62794. constructor(name: string);
  62795. /**
  62796. * Gets the current class name
  62797. * @returns the class name
  62798. */
  62799. getClassName(): string;
  62800. /**
  62801. * Gets the value input component
  62802. */
  62803. get value(): NodeMaterialConnectionPoint;
  62804. /**
  62805. * Gets the output component
  62806. */
  62807. get output(): NodeMaterialConnectionPoint;
  62808. protected _buildBlock(state: NodeMaterialBuildState): this;
  62809. protected _dumpPropertiesCode(): string;
  62810. serialize(): any;
  62811. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62812. }
  62813. }
  62814. declare module BABYLON {
  62815. /**
  62816. * Block used to apply a cross product between 2 vectors
  62817. */
  62818. export class CrossBlock extends NodeMaterialBlock {
  62819. /**
  62820. * Creates a new CrossBlock
  62821. * @param name defines the block name
  62822. */
  62823. constructor(name: string);
  62824. /**
  62825. * Gets the current class name
  62826. * @returns the class name
  62827. */
  62828. getClassName(): string;
  62829. /**
  62830. * Gets the left operand input component
  62831. */
  62832. get left(): NodeMaterialConnectionPoint;
  62833. /**
  62834. * Gets the right operand input component
  62835. */
  62836. get right(): NodeMaterialConnectionPoint;
  62837. /**
  62838. * Gets the output component
  62839. */
  62840. get output(): NodeMaterialConnectionPoint;
  62841. protected _buildBlock(state: NodeMaterialBuildState): this;
  62842. }
  62843. }
  62844. declare module BABYLON {
  62845. /**
  62846. * Block used to apply a dot product between 2 vectors
  62847. */
  62848. export class DotBlock extends NodeMaterialBlock {
  62849. /**
  62850. * Creates a new DotBlock
  62851. * @param name defines the block name
  62852. */
  62853. constructor(name: string);
  62854. /**
  62855. * Gets the current class name
  62856. * @returns the class name
  62857. */
  62858. getClassName(): string;
  62859. /**
  62860. * Gets the left operand input component
  62861. */
  62862. get left(): NodeMaterialConnectionPoint;
  62863. /**
  62864. * Gets the right operand input component
  62865. */
  62866. get right(): NodeMaterialConnectionPoint;
  62867. /**
  62868. * Gets the output component
  62869. */
  62870. get output(): NodeMaterialConnectionPoint;
  62871. protected _buildBlock(state: NodeMaterialBuildState): this;
  62872. }
  62873. }
  62874. declare module BABYLON {
  62875. /**
  62876. * Block used to normalize a vector
  62877. */
  62878. export class NormalizeBlock extends NodeMaterialBlock {
  62879. /**
  62880. * Creates a new NormalizeBlock
  62881. * @param name defines the block name
  62882. */
  62883. constructor(name: string);
  62884. /**
  62885. * Gets the current class name
  62886. * @returns the class name
  62887. */
  62888. getClassName(): string;
  62889. /**
  62890. * Gets the input component
  62891. */
  62892. get input(): NodeMaterialConnectionPoint;
  62893. /**
  62894. * Gets the output component
  62895. */
  62896. get output(): NodeMaterialConnectionPoint;
  62897. protected _buildBlock(state: NodeMaterialBuildState): this;
  62898. }
  62899. }
  62900. declare module BABYLON {
  62901. /**
  62902. * Operations supported by the Trigonometry block
  62903. */
  62904. export enum TrigonometryBlockOperations {
  62905. /** Cos */
  62906. Cos = 0,
  62907. /** Sin */
  62908. Sin = 1,
  62909. /** Abs */
  62910. Abs = 2,
  62911. /** Exp */
  62912. Exp = 3,
  62913. /** Exp2 */
  62914. Exp2 = 4,
  62915. /** Round */
  62916. Round = 5,
  62917. /** Floor */
  62918. Floor = 6,
  62919. /** Ceiling */
  62920. Ceiling = 7,
  62921. /** Square root */
  62922. Sqrt = 8,
  62923. /** Log */
  62924. Log = 9,
  62925. /** Tangent */
  62926. Tan = 10,
  62927. /** Arc tangent */
  62928. ArcTan = 11,
  62929. /** Arc cosinus */
  62930. ArcCos = 12,
  62931. /** Arc sinus */
  62932. ArcSin = 13,
  62933. /** Fraction */
  62934. Fract = 14,
  62935. /** Sign */
  62936. Sign = 15,
  62937. /** To radians (from degrees) */
  62938. Radians = 16,
  62939. /** To degrees (from radians) */
  62940. Degrees = 17
  62941. }
  62942. /**
  62943. * Block used to apply trigonometry operation to floats
  62944. */
  62945. export class TrigonometryBlock extends NodeMaterialBlock {
  62946. /**
  62947. * Gets or sets the operation applied by the block
  62948. */
  62949. operation: TrigonometryBlockOperations;
  62950. /**
  62951. * Creates a new TrigonometryBlock
  62952. * @param name defines the block name
  62953. */
  62954. constructor(name: string);
  62955. /**
  62956. * Gets the current class name
  62957. * @returns the class name
  62958. */
  62959. getClassName(): string;
  62960. /**
  62961. * Gets the input component
  62962. */
  62963. get input(): NodeMaterialConnectionPoint;
  62964. /**
  62965. * Gets the output component
  62966. */
  62967. get output(): NodeMaterialConnectionPoint;
  62968. protected _buildBlock(state: NodeMaterialBuildState): this;
  62969. serialize(): any;
  62970. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62971. protected _dumpPropertiesCode(): string;
  62972. }
  62973. }
  62974. declare module BABYLON {
  62975. /**
  62976. * Block used to create a Color3/4 out of individual inputs (one for each component)
  62977. */
  62978. export class ColorMergerBlock extends NodeMaterialBlock {
  62979. /**
  62980. * Create a new ColorMergerBlock
  62981. * @param name defines the block name
  62982. */
  62983. constructor(name: string);
  62984. /**
  62985. * Gets the current class name
  62986. * @returns the class name
  62987. */
  62988. getClassName(): string;
  62989. /**
  62990. * Gets the rgb component (input)
  62991. */
  62992. get rgbIn(): NodeMaterialConnectionPoint;
  62993. /**
  62994. * Gets the r component (input)
  62995. */
  62996. get r(): NodeMaterialConnectionPoint;
  62997. /**
  62998. * Gets the g component (input)
  62999. */
  63000. get g(): NodeMaterialConnectionPoint;
  63001. /**
  63002. * Gets the b component (input)
  63003. */
  63004. get b(): NodeMaterialConnectionPoint;
  63005. /**
  63006. * Gets the a component (input)
  63007. */
  63008. get a(): NodeMaterialConnectionPoint;
  63009. /**
  63010. * Gets the rgba component (output)
  63011. */
  63012. get rgba(): NodeMaterialConnectionPoint;
  63013. /**
  63014. * Gets the rgb component (output)
  63015. */
  63016. get rgbOut(): NodeMaterialConnectionPoint;
  63017. /**
  63018. * Gets the rgb component (output)
  63019. * @deprecated Please use rgbOut instead.
  63020. */
  63021. get rgb(): NodeMaterialConnectionPoint;
  63022. protected _buildBlock(state: NodeMaterialBuildState): this;
  63023. }
  63024. }
  63025. declare module BABYLON {
  63026. /**
  63027. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  63028. */
  63029. export class VectorSplitterBlock extends NodeMaterialBlock {
  63030. /**
  63031. * Create a new VectorSplitterBlock
  63032. * @param name defines the block name
  63033. */
  63034. constructor(name: string);
  63035. /**
  63036. * Gets the current class name
  63037. * @returns the class name
  63038. */
  63039. getClassName(): string;
  63040. /**
  63041. * Gets the xyzw component (input)
  63042. */
  63043. get xyzw(): NodeMaterialConnectionPoint;
  63044. /**
  63045. * Gets the xyz component (input)
  63046. */
  63047. get xyzIn(): NodeMaterialConnectionPoint;
  63048. /**
  63049. * Gets the xy component (input)
  63050. */
  63051. get xyIn(): NodeMaterialConnectionPoint;
  63052. /**
  63053. * Gets the xyz component (output)
  63054. */
  63055. get xyzOut(): NodeMaterialConnectionPoint;
  63056. /**
  63057. * Gets the xy component (output)
  63058. */
  63059. get xyOut(): NodeMaterialConnectionPoint;
  63060. /**
  63061. * Gets the x component (output)
  63062. */
  63063. get x(): NodeMaterialConnectionPoint;
  63064. /**
  63065. * Gets the y component (output)
  63066. */
  63067. get y(): NodeMaterialConnectionPoint;
  63068. /**
  63069. * Gets the z component (output)
  63070. */
  63071. get z(): NodeMaterialConnectionPoint;
  63072. /**
  63073. * Gets the w component (output)
  63074. */
  63075. get w(): NodeMaterialConnectionPoint;
  63076. protected _inputRename(name: string): string;
  63077. protected _outputRename(name: string): string;
  63078. protected _buildBlock(state: NodeMaterialBuildState): this;
  63079. }
  63080. }
  63081. declare module BABYLON {
  63082. /**
  63083. * Block used to lerp between 2 values
  63084. */
  63085. export class LerpBlock extends NodeMaterialBlock {
  63086. /**
  63087. * Creates a new LerpBlock
  63088. * @param name defines the block name
  63089. */
  63090. constructor(name: string);
  63091. /**
  63092. * Gets the current class name
  63093. * @returns the class name
  63094. */
  63095. getClassName(): string;
  63096. /**
  63097. * Gets the left operand input component
  63098. */
  63099. get left(): NodeMaterialConnectionPoint;
  63100. /**
  63101. * Gets the right operand input component
  63102. */
  63103. get right(): NodeMaterialConnectionPoint;
  63104. /**
  63105. * Gets the gradient operand input component
  63106. */
  63107. get gradient(): NodeMaterialConnectionPoint;
  63108. /**
  63109. * Gets the output component
  63110. */
  63111. get output(): NodeMaterialConnectionPoint;
  63112. protected _buildBlock(state: NodeMaterialBuildState): this;
  63113. }
  63114. }
  63115. declare module BABYLON {
  63116. /**
  63117. * Block used to divide 2 vectors
  63118. */
  63119. export class DivideBlock extends NodeMaterialBlock {
  63120. /**
  63121. * Creates a new DivideBlock
  63122. * @param name defines the block name
  63123. */
  63124. constructor(name: string);
  63125. /**
  63126. * Gets the current class name
  63127. * @returns the class name
  63128. */
  63129. getClassName(): string;
  63130. /**
  63131. * Gets the left operand input component
  63132. */
  63133. get left(): NodeMaterialConnectionPoint;
  63134. /**
  63135. * Gets the right operand input component
  63136. */
  63137. get right(): NodeMaterialConnectionPoint;
  63138. /**
  63139. * Gets the output component
  63140. */
  63141. get output(): NodeMaterialConnectionPoint;
  63142. protected _buildBlock(state: NodeMaterialBuildState): this;
  63143. }
  63144. }
  63145. declare module BABYLON {
  63146. /**
  63147. * Block used to subtract 2 vectors
  63148. */
  63149. export class SubtractBlock extends NodeMaterialBlock {
  63150. /**
  63151. * Creates a new SubtractBlock
  63152. * @param name defines the block name
  63153. */
  63154. constructor(name: string);
  63155. /**
  63156. * Gets the current class name
  63157. * @returns the class name
  63158. */
  63159. getClassName(): string;
  63160. /**
  63161. * Gets the left operand input component
  63162. */
  63163. get left(): NodeMaterialConnectionPoint;
  63164. /**
  63165. * Gets the right operand input component
  63166. */
  63167. get right(): NodeMaterialConnectionPoint;
  63168. /**
  63169. * Gets the output component
  63170. */
  63171. get output(): NodeMaterialConnectionPoint;
  63172. protected _buildBlock(state: NodeMaterialBuildState): this;
  63173. }
  63174. }
  63175. declare module BABYLON {
  63176. /**
  63177. * Block used to step a value
  63178. */
  63179. export class StepBlock extends NodeMaterialBlock {
  63180. /**
  63181. * Creates a new StepBlock
  63182. * @param name defines the block name
  63183. */
  63184. constructor(name: string);
  63185. /**
  63186. * Gets the current class name
  63187. * @returns the class name
  63188. */
  63189. getClassName(): string;
  63190. /**
  63191. * Gets the value operand input component
  63192. */
  63193. get value(): NodeMaterialConnectionPoint;
  63194. /**
  63195. * Gets the edge operand input component
  63196. */
  63197. get edge(): NodeMaterialConnectionPoint;
  63198. /**
  63199. * Gets the output component
  63200. */
  63201. get output(): NodeMaterialConnectionPoint;
  63202. protected _buildBlock(state: NodeMaterialBuildState): this;
  63203. }
  63204. }
  63205. declare module BABYLON {
  63206. /**
  63207. * Block used to get the opposite (1 - x) of a value
  63208. */
  63209. export class OneMinusBlock extends NodeMaterialBlock {
  63210. /**
  63211. * Creates a new OneMinusBlock
  63212. * @param name defines the block name
  63213. */
  63214. constructor(name: string);
  63215. /**
  63216. * Gets the current class name
  63217. * @returns the class name
  63218. */
  63219. getClassName(): string;
  63220. /**
  63221. * Gets the input component
  63222. */
  63223. get input(): NodeMaterialConnectionPoint;
  63224. /**
  63225. * Gets the output component
  63226. */
  63227. get output(): NodeMaterialConnectionPoint;
  63228. protected _buildBlock(state: NodeMaterialBuildState): this;
  63229. }
  63230. }
  63231. declare module BABYLON {
  63232. /**
  63233. * Block used to get the view direction
  63234. */
  63235. export class ViewDirectionBlock extends NodeMaterialBlock {
  63236. /**
  63237. * Creates a new ViewDirectionBlock
  63238. * @param name defines the block name
  63239. */
  63240. constructor(name: string);
  63241. /**
  63242. * Gets the current class name
  63243. * @returns the class name
  63244. */
  63245. getClassName(): string;
  63246. /**
  63247. * Gets the world position component
  63248. */
  63249. get worldPosition(): NodeMaterialConnectionPoint;
  63250. /**
  63251. * Gets the camera position component
  63252. */
  63253. get cameraPosition(): NodeMaterialConnectionPoint;
  63254. /**
  63255. * Gets the output component
  63256. */
  63257. get output(): NodeMaterialConnectionPoint;
  63258. autoConfigure(material: NodeMaterial): void;
  63259. protected _buildBlock(state: NodeMaterialBuildState): this;
  63260. }
  63261. }
  63262. declare module BABYLON {
  63263. /**
  63264. * Block used to compute fresnel value
  63265. */
  63266. export class FresnelBlock extends NodeMaterialBlock {
  63267. /**
  63268. * Create a new FresnelBlock
  63269. * @param name defines the block name
  63270. */
  63271. constructor(name: string);
  63272. /**
  63273. * Gets the current class name
  63274. * @returns the class name
  63275. */
  63276. getClassName(): string;
  63277. /**
  63278. * Gets the world normal input component
  63279. */
  63280. get worldNormal(): NodeMaterialConnectionPoint;
  63281. /**
  63282. * Gets the view direction input component
  63283. */
  63284. get viewDirection(): NodeMaterialConnectionPoint;
  63285. /**
  63286. * Gets the bias input component
  63287. */
  63288. get bias(): NodeMaterialConnectionPoint;
  63289. /**
  63290. * Gets the camera (or eye) position component
  63291. */
  63292. get power(): NodeMaterialConnectionPoint;
  63293. /**
  63294. * Gets the fresnel output component
  63295. */
  63296. get fresnel(): NodeMaterialConnectionPoint;
  63297. autoConfigure(material: NodeMaterial): void;
  63298. protected _buildBlock(state: NodeMaterialBuildState): this;
  63299. }
  63300. }
  63301. declare module BABYLON {
  63302. /**
  63303. * Block used to get the max of 2 values
  63304. */
  63305. export class MaxBlock extends NodeMaterialBlock {
  63306. /**
  63307. * Creates a new MaxBlock
  63308. * @param name defines the block name
  63309. */
  63310. constructor(name: string);
  63311. /**
  63312. * Gets the current class name
  63313. * @returns the class name
  63314. */
  63315. getClassName(): string;
  63316. /**
  63317. * Gets the left operand input component
  63318. */
  63319. get left(): NodeMaterialConnectionPoint;
  63320. /**
  63321. * Gets the right operand input component
  63322. */
  63323. get right(): NodeMaterialConnectionPoint;
  63324. /**
  63325. * Gets the output component
  63326. */
  63327. get output(): NodeMaterialConnectionPoint;
  63328. protected _buildBlock(state: NodeMaterialBuildState): this;
  63329. }
  63330. }
  63331. declare module BABYLON {
  63332. /**
  63333. * Block used to get the min of 2 values
  63334. */
  63335. export class MinBlock extends NodeMaterialBlock {
  63336. /**
  63337. * Creates a new MinBlock
  63338. * @param name defines the block name
  63339. */
  63340. constructor(name: string);
  63341. /**
  63342. * Gets the current class name
  63343. * @returns the class name
  63344. */
  63345. getClassName(): string;
  63346. /**
  63347. * Gets the left operand input component
  63348. */
  63349. get left(): NodeMaterialConnectionPoint;
  63350. /**
  63351. * Gets the right operand input component
  63352. */
  63353. get right(): NodeMaterialConnectionPoint;
  63354. /**
  63355. * Gets the output component
  63356. */
  63357. get output(): NodeMaterialConnectionPoint;
  63358. protected _buildBlock(state: NodeMaterialBuildState): this;
  63359. }
  63360. }
  63361. declare module BABYLON {
  63362. /**
  63363. * Block used to get the distance between 2 values
  63364. */
  63365. export class DistanceBlock extends NodeMaterialBlock {
  63366. /**
  63367. * Creates a new DistanceBlock
  63368. * @param name defines the block name
  63369. */
  63370. constructor(name: string);
  63371. /**
  63372. * Gets the current class name
  63373. * @returns the class name
  63374. */
  63375. getClassName(): string;
  63376. /**
  63377. * Gets the left operand input component
  63378. */
  63379. get left(): NodeMaterialConnectionPoint;
  63380. /**
  63381. * Gets the right operand input component
  63382. */
  63383. get right(): NodeMaterialConnectionPoint;
  63384. /**
  63385. * Gets the output component
  63386. */
  63387. get output(): NodeMaterialConnectionPoint;
  63388. protected _buildBlock(state: NodeMaterialBuildState): this;
  63389. }
  63390. }
  63391. declare module BABYLON {
  63392. /**
  63393. * Block used to get the length of a vector
  63394. */
  63395. export class LengthBlock extends NodeMaterialBlock {
  63396. /**
  63397. * Creates a new LengthBlock
  63398. * @param name defines the block name
  63399. */
  63400. constructor(name: string);
  63401. /**
  63402. * Gets the current class name
  63403. * @returns the class name
  63404. */
  63405. getClassName(): string;
  63406. /**
  63407. * Gets the value input component
  63408. */
  63409. get value(): NodeMaterialConnectionPoint;
  63410. /**
  63411. * Gets the output component
  63412. */
  63413. get output(): NodeMaterialConnectionPoint;
  63414. protected _buildBlock(state: NodeMaterialBuildState): this;
  63415. }
  63416. }
  63417. declare module BABYLON {
  63418. /**
  63419. * Block used to get negative version of a value (i.e. x * -1)
  63420. */
  63421. export class NegateBlock extends NodeMaterialBlock {
  63422. /**
  63423. * Creates a new NegateBlock
  63424. * @param name defines the block name
  63425. */
  63426. constructor(name: string);
  63427. /**
  63428. * Gets the current class name
  63429. * @returns the class name
  63430. */
  63431. getClassName(): string;
  63432. /**
  63433. * Gets the value input component
  63434. */
  63435. get value(): NodeMaterialConnectionPoint;
  63436. /**
  63437. * Gets the output component
  63438. */
  63439. get output(): NodeMaterialConnectionPoint;
  63440. protected _buildBlock(state: NodeMaterialBuildState): this;
  63441. }
  63442. }
  63443. declare module BABYLON {
  63444. /**
  63445. * Block used to get the value of the first parameter raised to the power of the second
  63446. */
  63447. export class PowBlock extends NodeMaterialBlock {
  63448. /**
  63449. * Creates a new PowBlock
  63450. * @param name defines the block name
  63451. */
  63452. constructor(name: string);
  63453. /**
  63454. * Gets the current class name
  63455. * @returns the class name
  63456. */
  63457. getClassName(): string;
  63458. /**
  63459. * Gets the value operand input component
  63460. */
  63461. get value(): NodeMaterialConnectionPoint;
  63462. /**
  63463. * Gets the power operand input component
  63464. */
  63465. get power(): NodeMaterialConnectionPoint;
  63466. /**
  63467. * Gets the output component
  63468. */
  63469. get output(): NodeMaterialConnectionPoint;
  63470. protected _buildBlock(state: NodeMaterialBuildState): this;
  63471. }
  63472. }
  63473. declare module BABYLON {
  63474. /**
  63475. * Block used to get a random number
  63476. */
  63477. export class RandomNumberBlock extends NodeMaterialBlock {
  63478. /**
  63479. * Creates a new RandomNumberBlock
  63480. * @param name defines the block name
  63481. */
  63482. constructor(name: string);
  63483. /**
  63484. * Gets the current class name
  63485. * @returns the class name
  63486. */
  63487. getClassName(): string;
  63488. /**
  63489. * Gets the seed input component
  63490. */
  63491. get seed(): NodeMaterialConnectionPoint;
  63492. /**
  63493. * Gets the output component
  63494. */
  63495. get output(): NodeMaterialConnectionPoint;
  63496. protected _buildBlock(state: NodeMaterialBuildState): this;
  63497. }
  63498. }
  63499. declare module BABYLON {
  63500. /**
  63501. * Block used to compute arc tangent of 2 values
  63502. */
  63503. export class ArcTan2Block extends NodeMaterialBlock {
  63504. /**
  63505. * Creates a new ArcTan2Block
  63506. * @param name defines the block name
  63507. */
  63508. constructor(name: string);
  63509. /**
  63510. * Gets the current class name
  63511. * @returns the class name
  63512. */
  63513. getClassName(): string;
  63514. /**
  63515. * Gets the x operand input component
  63516. */
  63517. get x(): NodeMaterialConnectionPoint;
  63518. /**
  63519. * Gets the y operand input component
  63520. */
  63521. get y(): NodeMaterialConnectionPoint;
  63522. /**
  63523. * Gets the output component
  63524. */
  63525. get output(): NodeMaterialConnectionPoint;
  63526. protected _buildBlock(state: NodeMaterialBuildState): this;
  63527. }
  63528. }
  63529. declare module BABYLON {
  63530. /**
  63531. * Block used to smooth step a value
  63532. */
  63533. export class SmoothStepBlock extends NodeMaterialBlock {
  63534. /**
  63535. * Creates a new SmoothStepBlock
  63536. * @param name defines the block name
  63537. */
  63538. constructor(name: string);
  63539. /**
  63540. * Gets the current class name
  63541. * @returns the class name
  63542. */
  63543. getClassName(): string;
  63544. /**
  63545. * Gets the value operand input component
  63546. */
  63547. get value(): NodeMaterialConnectionPoint;
  63548. /**
  63549. * Gets the first edge operand input component
  63550. */
  63551. get edge0(): NodeMaterialConnectionPoint;
  63552. /**
  63553. * Gets the second edge operand input component
  63554. */
  63555. get edge1(): NodeMaterialConnectionPoint;
  63556. /**
  63557. * Gets the output component
  63558. */
  63559. get output(): NodeMaterialConnectionPoint;
  63560. protected _buildBlock(state: NodeMaterialBuildState): this;
  63561. }
  63562. }
  63563. declare module BABYLON {
  63564. /**
  63565. * Block used to get the reciprocal (1 / x) of a value
  63566. */
  63567. export class ReciprocalBlock extends NodeMaterialBlock {
  63568. /**
  63569. * Creates a new ReciprocalBlock
  63570. * @param name defines the block name
  63571. */
  63572. constructor(name: string);
  63573. /**
  63574. * Gets the current class name
  63575. * @returns the class name
  63576. */
  63577. getClassName(): string;
  63578. /**
  63579. * Gets the input component
  63580. */
  63581. get input(): NodeMaterialConnectionPoint;
  63582. /**
  63583. * Gets the output component
  63584. */
  63585. get output(): NodeMaterialConnectionPoint;
  63586. protected _buildBlock(state: NodeMaterialBuildState): this;
  63587. }
  63588. }
  63589. declare module BABYLON {
  63590. /**
  63591. * Block used to replace a color by another one
  63592. */
  63593. export class ReplaceColorBlock extends NodeMaterialBlock {
  63594. /**
  63595. * Creates a new ReplaceColorBlock
  63596. * @param name defines the block name
  63597. */
  63598. constructor(name: string);
  63599. /**
  63600. * Gets the current class name
  63601. * @returns the class name
  63602. */
  63603. getClassName(): string;
  63604. /**
  63605. * Gets the value input component
  63606. */
  63607. get value(): NodeMaterialConnectionPoint;
  63608. /**
  63609. * Gets the reference input component
  63610. */
  63611. get reference(): NodeMaterialConnectionPoint;
  63612. /**
  63613. * Gets the distance input component
  63614. */
  63615. get distance(): NodeMaterialConnectionPoint;
  63616. /**
  63617. * Gets the replacement input component
  63618. */
  63619. get replacement(): NodeMaterialConnectionPoint;
  63620. /**
  63621. * Gets the output component
  63622. */
  63623. get output(): NodeMaterialConnectionPoint;
  63624. protected _buildBlock(state: NodeMaterialBuildState): this;
  63625. }
  63626. }
  63627. declare module BABYLON {
  63628. /**
  63629. * Block used to posterize a value
  63630. * @see https://en.wikipedia.org/wiki/Posterization
  63631. */
  63632. export class PosterizeBlock extends NodeMaterialBlock {
  63633. /**
  63634. * Creates a new PosterizeBlock
  63635. * @param name defines the block name
  63636. */
  63637. constructor(name: string);
  63638. /**
  63639. * Gets the current class name
  63640. * @returns the class name
  63641. */
  63642. getClassName(): string;
  63643. /**
  63644. * Gets the value input component
  63645. */
  63646. get value(): NodeMaterialConnectionPoint;
  63647. /**
  63648. * Gets the steps input component
  63649. */
  63650. get steps(): NodeMaterialConnectionPoint;
  63651. /**
  63652. * Gets the output component
  63653. */
  63654. get output(): NodeMaterialConnectionPoint;
  63655. protected _buildBlock(state: NodeMaterialBuildState): this;
  63656. }
  63657. }
  63658. declare module BABYLON {
  63659. /**
  63660. * Operations supported by the Wave block
  63661. */
  63662. export enum WaveBlockKind {
  63663. /** SawTooth */
  63664. SawTooth = 0,
  63665. /** Square */
  63666. Square = 1,
  63667. /** Triangle */
  63668. Triangle = 2
  63669. }
  63670. /**
  63671. * Block used to apply wave operation to floats
  63672. */
  63673. export class WaveBlock extends NodeMaterialBlock {
  63674. /**
  63675. * Gets or sets the kibnd of wave to be applied by the block
  63676. */
  63677. kind: WaveBlockKind;
  63678. /**
  63679. * Creates a new WaveBlock
  63680. * @param name defines the block name
  63681. */
  63682. constructor(name: string);
  63683. /**
  63684. * Gets the current class name
  63685. * @returns the class name
  63686. */
  63687. getClassName(): string;
  63688. /**
  63689. * Gets the input component
  63690. */
  63691. get input(): NodeMaterialConnectionPoint;
  63692. /**
  63693. * Gets the output component
  63694. */
  63695. get output(): NodeMaterialConnectionPoint;
  63696. protected _buildBlock(state: NodeMaterialBuildState): this;
  63697. serialize(): any;
  63698. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63699. }
  63700. }
  63701. declare module BABYLON {
  63702. /**
  63703. * Class used to store a color step for the GradientBlock
  63704. */
  63705. export class GradientBlockColorStep {
  63706. /**
  63707. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63708. */
  63709. step: number;
  63710. /**
  63711. * Gets or sets the color associated with this step
  63712. */
  63713. color: Color3;
  63714. /**
  63715. * Creates a new GradientBlockColorStep
  63716. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  63717. * @param color defines the color associated with this step
  63718. */
  63719. constructor(
  63720. /**
  63721. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63722. */
  63723. step: number,
  63724. /**
  63725. * Gets or sets the color associated with this step
  63726. */
  63727. color: Color3);
  63728. }
  63729. /**
  63730. * Block used to return a color from a gradient based on an input value between 0 and 1
  63731. */
  63732. export class GradientBlock extends NodeMaterialBlock {
  63733. /**
  63734. * Gets or sets the list of color steps
  63735. */
  63736. colorSteps: GradientBlockColorStep[];
  63737. /**
  63738. * Creates a new GradientBlock
  63739. * @param name defines the block name
  63740. */
  63741. constructor(name: string);
  63742. /**
  63743. * Gets the current class name
  63744. * @returns the class name
  63745. */
  63746. getClassName(): string;
  63747. /**
  63748. * Gets the gradient input component
  63749. */
  63750. get gradient(): NodeMaterialConnectionPoint;
  63751. /**
  63752. * Gets the output component
  63753. */
  63754. get output(): NodeMaterialConnectionPoint;
  63755. private _writeColorConstant;
  63756. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63757. serialize(): any;
  63758. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63759. protected _dumpPropertiesCode(): string;
  63760. }
  63761. }
  63762. declare module BABYLON {
  63763. /**
  63764. * Block used to normalize lerp between 2 values
  63765. */
  63766. export class NLerpBlock extends NodeMaterialBlock {
  63767. /**
  63768. * Creates a new NLerpBlock
  63769. * @param name defines the block name
  63770. */
  63771. constructor(name: string);
  63772. /**
  63773. * Gets the current class name
  63774. * @returns the class name
  63775. */
  63776. getClassName(): string;
  63777. /**
  63778. * Gets the left operand input component
  63779. */
  63780. get left(): NodeMaterialConnectionPoint;
  63781. /**
  63782. * Gets the right operand input component
  63783. */
  63784. get right(): NodeMaterialConnectionPoint;
  63785. /**
  63786. * Gets the gradient operand input component
  63787. */
  63788. get gradient(): NodeMaterialConnectionPoint;
  63789. /**
  63790. * Gets the output component
  63791. */
  63792. get output(): NodeMaterialConnectionPoint;
  63793. protected _buildBlock(state: NodeMaterialBuildState): this;
  63794. }
  63795. }
  63796. declare module BABYLON {
  63797. /**
  63798. * block used to Generate a Worley Noise 3D Noise Pattern
  63799. */
  63800. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  63801. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63802. manhattanDistance: boolean;
  63803. /**
  63804. * Creates a new WorleyNoise3DBlock
  63805. * @param name defines the block name
  63806. */
  63807. constructor(name: string);
  63808. /**
  63809. * Gets the current class name
  63810. * @returns the class name
  63811. */
  63812. getClassName(): string;
  63813. /**
  63814. * Gets the seed input component
  63815. */
  63816. get seed(): NodeMaterialConnectionPoint;
  63817. /**
  63818. * Gets the jitter input component
  63819. */
  63820. get jitter(): NodeMaterialConnectionPoint;
  63821. /**
  63822. * Gets the output component
  63823. */
  63824. get output(): NodeMaterialConnectionPoint;
  63825. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63826. /**
  63827. * Exposes the properties to the UI?
  63828. */
  63829. protected _dumpPropertiesCode(): string;
  63830. /**
  63831. * Exposes the properties to the Seralize?
  63832. */
  63833. serialize(): any;
  63834. /**
  63835. * Exposes the properties to the deseralize?
  63836. */
  63837. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63838. }
  63839. }
  63840. declare module BABYLON {
  63841. /**
  63842. * block used to Generate a Simplex Perlin 3d Noise Pattern
  63843. */
  63844. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  63845. /**
  63846. * Creates a new SimplexPerlin3DBlock
  63847. * @param name defines the block name
  63848. */
  63849. constructor(name: string);
  63850. /**
  63851. * Gets the current class name
  63852. * @returns the class name
  63853. */
  63854. getClassName(): string;
  63855. /**
  63856. * Gets the seed operand input component
  63857. */
  63858. get seed(): NodeMaterialConnectionPoint;
  63859. /**
  63860. * Gets the output component
  63861. */
  63862. get output(): NodeMaterialConnectionPoint;
  63863. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63864. }
  63865. }
  63866. declare module BABYLON {
  63867. /**
  63868. * Block used to blend normals
  63869. */
  63870. export class NormalBlendBlock extends NodeMaterialBlock {
  63871. /**
  63872. * Creates a new NormalBlendBlock
  63873. * @param name defines the block name
  63874. */
  63875. constructor(name: string);
  63876. /**
  63877. * Gets the current class name
  63878. * @returns the class name
  63879. */
  63880. getClassName(): string;
  63881. /**
  63882. * Gets the first input component
  63883. */
  63884. get normalMap0(): NodeMaterialConnectionPoint;
  63885. /**
  63886. * Gets the second input component
  63887. */
  63888. get normalMap1(): NodeMaterialConnectionPoint;
  63889. /**
  63890. * Gets the output component
  63891. */
  63892. get output(): NodeMaterialConnectionPoint;
  63893. protected _buildBlock(state: NodeMaterialBuildState): this;
  63894. }
  63895. }
  63896. declare module BABYLON {
  63897. /**
  63898. * Block used to rotate a 2d vector by a given angle
  63899. */
  63900. export class Rotate2dBlock extends NodeMaterialBlock {
  63901. /**
  63902. * Creates a new Rotate2dBlock
  63903. * @param name defines the block name
  63904. */
  63905. constructor(name: string);
  63906. /**
  63907. * Gets the current class name
  63908. * @returns the class name
  63909. */
  63910. getClassName(): string;
  63911. /**
  63912. * Gets the input vector
  63913. */
  63914. get input(): NodeMaterialConnectionPoint;
  63915. /**
  63916. * Gets the input angle
  63917. */
  63918. get angle(): NodeMaterialConnectionPoint;
  63919. /**
  63920. * Gets the output component
  63921. */
  63922. get output(): NodeMaterialConnectionPoint;
  63923. autoConfigure(material: NodeMaterial): void;
  63924. protected _buildBlock(state: NodeMaterialBuildState): this;
  63925. }
  63926. }
  63927. declare module BABYLON {
  63928. /**
  63929. * Block used to get the reflected vector from a direction and a normal
  63930. */
  63931. export class ReflectBlock extends NodeMaterialBlock {
  63932. /**
  63933. * Creates a new ReflectBlock
  63934. * @param name defines the block name
  63935. */
  63936. constructor(name: string);
  63937. /**
  63938. * Gets the current class name
  63939. * @returns the class name
  63940. */
  63941. getClassName(): string;
  63942. /**
  63943. * Gets the incident component
  63944. */
  63945. get incident(): NodeMaterialConnectionPoint;
  63946. /**
  63947. * Gets the normal component
  63948. */
  63949. get normal(): NodeMaterialConnectionPoint;
  63950. /**
  63951. * Gets the output component
  63952. */
  63953. get output(): NodeMaterialConnectionPoint;
  63954. protected _buildBlock(state: NodeMaterialBuildState): this;
  63955. }
  63956. }
  63957. declare module BABYLON {
  63958. /**
  63959. * Block used to get the refracted vector from a direction and a normal
  63960. */
  63961. export class RefractBlock extends NodeMaterialBlock {
  63962. /**
  63963. * Creates a new RefractBlock
  63964. * @param name defines the block name
  63965. */
  63966. constructor(name: string);
  63967. /**
  63968. * Gets the current class name
  63969. * @returns the class name
  63970. */
  63971. getClassName(): string;
  63972. /**
  63973. * Gets the incident component
  63974. */
  63975. get incident(): NodeMaterialConnectionPoint;
  63976. /**
  63977. * Gets the normal component
  63978. */
  63979. get normal(): NodeMaterialConnectionPoint;
  63980. /**
  63981. * Gets the index of refraction component
  63982. */
  63983. get ior(): NodeMaterialConnectionPoint;
  63984. /**
  63985. * Gets the output component
  63986. */
  63987. get output(): NodeMaterialConnectionPoint;
  63988. protected _buildBlock(state: NodeMaterialBuildState): this;
  63989. }
  63990. }
  63991. declare module BABYLON {
  63992. /**
  63993. * Block used to desaturate a color
  63994. */
  63995. export class DesaturateBlock extends NodeMaterialBlock {
  63996. /**
  63997. * Creates a new DesaturateBlock
  63998. * @param name defines the block name
  63999. */
  64000. constructor(name: string);
  64001. /**
  64002. * Gets the current class name
  64003. * @returns the class name
  64004. */
  64005. getClassName(): string;
  64006. /**
  64007. * Gets the color operand input component
  64008. */
  64009. get color(): NodeMaterialConnectionPoint;
  64010. /**
  64011. * Gets the level operand input component
  64012. */
  64013. get level(): NodeMaterialConnectionPoint;
  64014. /**
  64015. * Gets the output component
  64016. */
  64017. get output(): NodeMaterialConnectionPoint;
  64018. protected _buildBlock(state: NodeMaterialBuildState): this;
  64019. }
  64020. }
  64021. declare module BABYLON {
  64022. /**
  64023. * Block used to implement the ambient occlusion module of the PBR material
  64024. */
  64025. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  64026. /**
  64027. * Create a new AmbientOcclusionBlock
  64028. * @param name defines the block name
  64029. */
  64030. constructor(name: string);
  64031. /**
  64032. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  64033. */
  64034. useAmbientInGrayScale: boolean;
  64035. /**
  64036. * Initialize the block and prepare the context for build
  64037. * @param state defines the state that will be used for the build
  64038. */
  64039. initialize(state: NodeMaterialBuildState): void;
  64040. /**
  64041. * Gets the current class name
  64042. * @returns the class name
  64043. */
  64044. getClassName(): string;
  64045. /**
  64046. * Gets the texture input component
  64047. */
  64048. get texture(): NodeMaterialConnectionPoint;
  64049. /**
  64050. * Gets the texture intensity component
  64051. */
  64052. get intensity(): NodeMaterialConnectionPoint;
  64053. /**
  64054. * Gets the direct light intensity input component
  64055. */
  64056. get directLightIntensity(): NodeMaterialConnectionPoint;
  64057. /**
  64058. * Gets the ambient occlusion object output component
  64059. */
  64060. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64061. /**
  64062. * Gets the main code of the block (fragment side)
  64063. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  64064. * @returns the shader code
  64065. */
  64066. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  64067. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64068. protected _buildBlock(state: NodeMaterialBuildState): this;
  64069. protected _dumpPropertiesCode(): string;
  64070. serialize(): any;
  64071. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64072. }
  64073. }
  64074. declare module BABYLON {
  64075. /**
  64076. * Block used to implement the reflection module of the PBR material
  64077. */
  64078. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  64079. /** @hidden */
  64080. _defineLODReflectionAlpha: string;
  64081. /** @hidden */
  64082. _defineLinearSpecularReflection: string;
  64083. private _vEnvironmentIrradianceName;
  64084. /** @hidden */
  64085. _vReflectionMicrosurfaceInfosName: string;
  64086. /** @hidden */
  64087. _vReflectionInfosName: string;
  64088. /** @hidden */
  64089. _vReflectionFilteringInfoName: string;
  64090. private _scene;
  64091. /**
  64092. * The three properties below are set by the main PBR block prior to calling methods of this class.
  64093. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64094. * It's less burden on the user side in the editor part.
  64095. */
  64096. /** @hidden */
  64097. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64098. /** @hidden */
  64099. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64100. /** @hidden */
  64101. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  64102. /**
  64103. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  64104. * diffuse part of the IBL.
  64105. */
  64106. useSphericalHarmonics: boolean;
  64107. /**
  64108. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  64109. */
  64110. forceIrradianceInFragment: boolean;
  64111. /**
  64112. * Create a new ReflectionBlock
  64113. * @param name defines the block name
  64114. */
  64115. constructor(name: string);
  64116. /**
  64117. * Gets the current class name
  64118. * @returns the class name
  64119. */
  64120. getClassName(): string;
  64121. /**
  64122. * Gets the position input component
  64123. */
  64124. get position(): NodeMaterialConnectionPoint;
  64125. /**
  64126. * Gets the world position input component
  64127. */
  64128. get worldPosition(): NodeMaterialConnectionPoint;
  64129. /**
  64130. * Gets the world normal input component
  64131. */
  64132. get worldNormal(): NodeMaterialConnectionPoint;
  64133. /**
  64134. * Gets the world input component
  64135. */
  64136. get world(): NodeMaterialConnectionPoint;
  64137. /**
  64138. * Gets the camera (or eye) position component
  64139. */
  64140. get cameraPosition(): NodeMaterialConnectionPoint;
  64141. /**
  64142. * Gets the view input component
  64143. */
  64144. get view(): NodeMaterialConnectionPoint;
  64145. /**
  64146. * Gets the color input component
  64147. */
  64148. get color(): NodeMaterialConnectionPoint;
  64149. /**
  64150. * Gets the reflection object output component
  64151. */
  64152. get reflection(): NodeMaterialConnectionPoint;
  64153. /**
  64154. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  64155. */
  64156. get hasTexture(): boolean;
  64157. /**
  64158. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  64159. */
  64160. get reflectionColor(): string;
  64161. protected _getTexture(): Nullable<BaseTexture>;
  64162. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64163. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64164. /**
  64165. * Gets the code to inject in the vertex shader
  64166. * @param state current state of the node material building
  64167. * @returns the shader code
  64168. */
  64169. handleVertexSide(state: NodeMaterialBuildState): string;
  64170. /**
  64171. * Gets the main code of the block (fragment side)
  64172. * @param state current state of the node material building
  64173. * @param normalVarName name of the existing variable corresponding to the normal
  64174. * @returns the shader code
  64175. */
  64176. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  64177. protected _buildBlock(state: NodeMaterialBuildState): this;
  64178. protected _dumpPropertiesCode(): string;
  64179. serialize(): any;
  64180. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64181. }
  64182. }
  64183. declare module BABYLON {
  64184. /**
  64185. * Block used to implement the sheen module of the PBR material
  64186. */
  64187. export class SheenBlock extends NodeMaterialBlock {
  64188. /**
  64189. * Create a new SheenBlock
  64190. * @param name defines the block name
  64191. */
  64192. constructor(name: string);
  64193. /**
  64194. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  64195. * It allows the strength of the sheen effect to not depend on the base color of the material,
  64196. * making it easier to setup and tweak the effect
  64197. */
  64198. albedoScaling: boolean;
  64199. /**
  64200. * Defines if the sheen is linked to the sheen color.
  64201. */
  64202. linkSheenWithAlbedo: boolean;
  64203. /**
  64204. * Initialize the block and prepare the context for build
  64205. * @param state defines the state that will be used for the build
  64206. */
  64207. initialize(state: NodeMaterialBuildState): void;
  64208. /**
  64209. * Gets the current class name
  64210. * @returns the class name
  64211. */
  64212. getClassName(): string;
  64213. /**
  64214. * Gets the intensity input component
  64215. */
  64216. get intensity(): NodeMaterialConnectionPoint;
  64217. /**
  64218. * Gets the color input component
  64219. */
  64220. get color(): NodeMaterialConnectionPoint;
  64221. /**
  64222. * Gets the roughness input component
  64223. */
  64224. get roughness(): NodeMaterialConnectionPoint;
  64225. /**
  64226. * Gets the sheen object output component
  64227. */
  64228. get sheen(): NodeMaterialConnectionPoint;
  64229. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64230. /**
  64231. * Gets the main code of the block (fragment side)
  64232. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64233. * @returns the shader code
  64234. */
  64235. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  64236. protected _buildBlock(state: NodeMaterialBuildState): this;
  64237. protected _dumpPropertiesCode(): string;
  64238. serialize(): any;
  64239. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64240. }
  64241. }
  64242. declare module BABYLON {
  64243. /**
  64244. * Block used to implement the reflectivity module of the PBR material
  64245. */
  64246. export class ReflectivityBlock extends NodeMaterialBlock {
  64247. private _metallicReflectanceColor;
  64248. private _metallicF0Factor;
  64249. /** @hidden */
  64250. _vMetallicReflectanceFactorsName: string;
  64251. /**
  64252. * The property below is set by the main PBR block prior to calling methods of this class.
  64253. */
  64254. /** @hidden */
  64255. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  64256. /**
  64257. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  64258. */
  64259. useAmbientOcclusionFromMetallicTextureRed: boolean;
  64260. /**
  64261. * Specifies if the metallic texture contains the metallness information in its blue channel.
  64262. */
  64263. useMetallnessFromMetallicTextureBlue: boolean;
  64264. /**
  64265. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  64266. */
  64267. useRoughnessFromMetallicTextureAlpha: boolean;
  64268. /**
  64269. * Specifies if the metallic texture contains the roughness information in its green channel.
  64270. */
  64271. useRoughnessFromMetallicTextureGreen: boolean;
  64272. /**
  64273. * Create a new ReflectivityBlock
  64274. * @param name defines the block name
  64275. */
  64276. constructor(name: string);
  64277. /**
  64278. * Initialize the block and prepare the context for build
  64279. * @param state defines the state that will be used for the build
  64280. */
  64281. initialize(state: NodeMaterialBuildState): void;
  64282. /**
  64283. * Gets the current class name
  64284. * @returns the class name
  64285. */
  64286. getClassName(): string;
  64287. /**
  64288. * Gets the metallic input component
  64289. */
  64290. get metallic(): NodeMaterialConnectionPoint;
  64291. /**
  64292. * Gets the roughness input component
  64293. */
  64294. get roughness(): NodeMaterialConnectionPoint;
  64295. /**
  64296. * Gets the texture input component
  64297. */
  64298. get texture(): NodeMaterialConnectionPoint;
  64299. /**
  64300. * Gets the reflectivity object output component
  64301. */
  64302. get reflectivity(): NodeMaterialConnectionPoint;
  64303. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64304. /**
  64305. * Gets the main code of the block (fragment side)
  64306. * @param state current state of the node material building
  64307. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  64308. * @returns the shader code
  64309. */
  64310. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  64311. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64312. protected _buildBlock(state: NodeMaterialBuildState): this;
  64313. protected _dumpPropertiesCode(): string;
  64314. serialize(): any;
  64315. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64316. }
  64317. }
  64318. declare module BABYLON {
  64319. /**
  64320. * Block used to implement the anisotropy module of the PBR material
  64321. */
  64322. export class AnisotropyBlock extends NodeMaterialBlock {
  64323. /**
  64324. * The two properties below are set by the main PBR block prior to calling methods of this class.
  64325. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64326. * It's less burden on the user side in the editor part.
  64327. */
  64328. /** @hidden */
  64329. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64330. /** @hidden */
  64331. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64332. /**
  64333. * Create a new AnisotropyBlock
  64334. * @param name defines the block name
  64335. */
  64336. constructor(name: string);
  64337. /**
  64338. * Initialize the block and prepare the context for build
  64339. * @param state defines the state that will be used for the build
  64340. */
  64341. initialize(state: NodeMaterialBuildState): void;
  64342. /**
  64343. * Gets the current class name
  64344. * @returns the class name
  64345. */
  64346. getClassName(): string;
  64347. /**
  64348. * Gets the intensity input component
  64349. */
  64350. get intensity(): NodeMaterialConnectionPoint;
  64351. /**
  64352. * Gets the direction input component
  64353. */
  64354. get direction(): NodeMaterialConnectionPoint;
  64355. /**
  64356. * Gets the texture input component
  64357. */
  64358. get texture(): NodeMaterialConnectionPoint;
  64359. /**
  64360. * Gets the uv input component
  64361. */
  64362. get uv(): NodeMaterialConnectionPoint;
  64363. /**
  64364. * Gets the worldTangent input component
  64365. */
  64366. get worldTangent(): NodeMaterialConnectionPoint;
  64367. /**
  64368. * Gets the anisotropy object output component
  64369. */
  64370. get anisotropy(): NodeMaterialConnectionPoint;
  64371. private _generateTBNSpace;
  64372. /**
  64373. * Gets the main code of the block (fragment side)
  64374. * @param state current state of the node material building
  64375. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64376. * @returns the shader code
  64377. */
  64378. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  64379. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64380. protected _buildBlock(state: NodeMaterialBuildState): this;
  64381. }
  64382. }
  64383. declare module BABYLON {
  64384. /**
  64385. * Block used to implement the clear coat module of the PBR material
  64386. */
  64387. export class ClearCoatBlock extends NodeMaterialBlock {
  64388. private _scene;
  64389. /**
  64390. * Create a new ClearCoatBlock
  64391. * @param name defines the block name
  64392. */
  64393. constructor(name: string);
  64394. /**
  64395. * Initialize the block and prepare the context for build
  64396. * @param state defines the state that will be used for the build
  64397. */
  64398. initialize(state: NodeMaterialBuildState): void;
  64399. /**
  64400. * Gets the current class name
  64401. * @returns the class name
  64402. */
  64403. getClassName(): string;
  64404. /**
  64405. * Gets the intensity input component
  64406. */
  64407. get intensity(): NodeMaterialConnectionPoint;
  64408. /**
  64409. * Gets the roughness input component
  64410. */
  64411. get roughness(): NodeMaterialConnectionPoint;
  64412. /**
  64413. * Gets the ior input component
  64414. */
  64415. get ior(): NodeMaterialConnectionPoint;
  64416. /**
  64417. * Gets the texture input component
  64418. */
  64419. get texture(): NodeMaterialConnectionPoint;
  64420. /**
  64421. * Gets the bump texture input component
  64422. */
  64423. get bumpTexture(): NodeMaterialConnectionPoint;
  64424. /**
  64425. * Gets the uv input component
  64426. */
  64427. get uv(): NodeMaterialConnectionPoint;
  64428. /**
  64429. * Gets the tint color input component
  64430. */
  64431. get tintColor(): NodeMaterialConnectionPoint;
  64432. /**
  64433. * Gets the tint "at distance" input component
  64434. */
  64435. get tintAtDistance(): NodeMaterialConnectionPoint;
  64436. /**
  64437. * Gets the tint thickness input component
  64438. */
  64439. get tintThickness(): NodeMaterialConnectionPoint;
  64440. /**
  64441. * Gets the world tangent input component
  64442. */
  64443. get worldTangent(): NodeMaterialConnectionPoint;
  64444. /**
  64445. * Gets the clear coat object output component
  64446. */
  64447. get clearcoat(): NodeMaterialConnectionPoint;
  64448. autoConfigure(material: NodeMaterial): void;
  64449. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64450. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64451. private _generateTBNSpace;
  64452. /**
  64453. * Gets the main code of the block (fragment side)
  64454. * @param state current state of the node material building
  64455. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  64456. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64457. * @param worldPosVarName name of the variable holding the world position
  64458. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64459. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  64460. * @param worldNormalVarName name of the variable holding the world normal
  64461. * @returns the shader code
  64462. */
  64463. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  64464. protected _buildBlock(state: NodeMaterialBuildState): this;
  64465. }
  64466. }
  64467. declare module BABYLON {
  64468. /**
  64469. * Block used to implement the sub surface module of the PBR material
  64470. */
  64471. export class SubSurfaceBlock extends NodeMaterialBlock {
  64472. /**
  64473. * Create a new SubSurfaceBlock
  64474. * @param name defines the block name
  64475. */
  64476. constructor(name: string);
  64477. /**
  64478. * Stores the intensity of the different subsurface effects in the thickness texture.
  64479. * * the green channel is the translucency intensity.
  64480. * * the blue channel is the scattering intensity.
  64481. * * the alpha channel is the refraction intensity.
  64482. */
  64483. useMaskFromThicknessTexture: boolean;
  64484. /**
  64485. * Initialize the block and prepare the context for build
  64486. * @param state defines the state that will be used for the build
  64487. */
  64488. initialize(state: NodeMaterialBuildState): void;
  64489. /**
  64490. * Gets the current class name
  64491. * @returns the class name
  64492. */
  64493. getClassName(): string;
  64494. /**
  64495. * Gets the min thickness input component
  64496. */
  64497. get minThickness(): NodeMaterialConnectionPoint;
  64498. /**
  64499. * Gets the max thickness input component
  64500. */
  64501. get maxThickness(): NodeMaterialConnectionPoint;
  64502. /**
  64503. * Gets the thickness texture component
  64504. */
  64505. get thicknessTexture(): NodeMaterialConnectionPoint;
  64506. /**
  64507. * Gets the tint color input component
  64508. */
  64509. get tintColor(): NodeMaterialConnectionPoint;
  64510. /**
  64511. * Gets the translucency intensity input component
  64512. */
  64513. get translucencyIntensity(): NodeMaterialConnectionPoint;
  64514. /**
  64515. * Gets the translucency diffusion distance input component
  64516. */
  64517. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  64518. /**
  64519. * Gets the refraction object parameters
  64520. */
  64521. get refraction(): NodeMaterialConnectionPoint;
  64522. /**
  64523. * Gets the sub surface object output component
  64524. */
  64525. get subsurface(): NodeMaterialConnectionPoint;
  64526. autoConfigure(material: NodeMaterial): void;
  64527. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64528. /**
  64529. * Gets the main code of the block (fragment side)
  64530. * @param state current state of the node material building
  64531. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  64532. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64533. * @param worldPosVarName name of the variable holding the world position
  64534. * @returns the shader code
  64535. */
  64536. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  64537. protected _buildBlock(state: NodeMaterialBuildState): this;
  64538. }
  64539. }
  64540. declare module BABYLON {
  64541. /**
  64542. * Block used to implement the PBR metallic/roughness model
  64543. */
  64544. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  64545. /**
  64546. * Gets or sets the light associated with this block
  64547. */
  64548. light: Nullable<Light>;
  64549. private _lightId;
  64550. private _scene;
  64551. private _environmentBRDFTexture;
  64552. private _environmentBrdfSamplerName;
  64553. private _vNormalWName;
  64554. private _invertNormalName;
  64555. /**
  64556. * Create a new ReflectionBlock
  64557. * @param name defines the block name
  64558. */
  64559. constructor(name: string);
  64560. /**
  64561. * Intensity of the direct lights e.g. the four lights available in your scene.
  64562. * This impacts both the direct diffuse and specular highlights.
  64563. */
  64564. directIntensity: number;
  64565. /**
  64566. * Intensity of the environment e.g. how much the environment will light the object
  64567. * either through harmonics for rough material or through the refelction for shiny ones.
  64568. */
  64569. environmentIntensity: number;
  64570. /**
  64571. * This is a special control allowing the reduction of the specular highlights coming from the
  64572. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  64573. */
  64574. specularIntensity: number;
  64575. /**
  64576. * Defines the falloff type used in this material.
  64577. * It by default is Physical.
  64578. */
  64579. lightFalloff: number;
  64580. /**
  64581. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  64582. */
  64583. useAlphaFromAlbedoTexture: boolean;
  64584. /**
  64585. * Specifies that alpha test should be used
  64586. */
  64587. useAlphaTest: boolean;
  64588. /**
  64589. * Defines the alpha limits in alpha test mode.
  64590. */
  64591. alphaTestCutoff: number;
  64592. /**
  64593. * Specifies that alpha blending should be used
  64594. */
  64595. useAlphaBlending: boolean;
  64596. /**
  64597. * Defines if the alpha value should be determined via the rgb values.
  64598. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  64599. */
  64600. opacityRGB: boolean;
  64601. /**
  64602. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  64603. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  64604. */
  64605. useRadianceOverAlpha: boolean;
  64606. /**
  64607. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  64608. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  64609. */
  64610. useSpecularOverAlpha: boolean;
  64611. /**
  64612. * Enables specular anti aliasing in the PBR shader.
  64613. * It will both interacts on the Geometry for analytical and IBL lighting.
  64614. * It also prefilter the roughness map based on the bump values.
  64615. */
  64616. enableSpecularAntiAliasing: boolean;
  64617. /**
  64618. * Enables realtime filtering on the texture.
  64619. */
  64620. realTimeFiltering: boolean;
  64621. /**
  64622. * Quality switch for realtime filtering
  64623. */
  64624. realTimeFilteringQuality: number;
  64625. /**
  64626. * Defines if the material uses energy conservation.
  64627. */
  64628. useEnergyConservation: boolean;
  64629. /**
  64630. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  64631. * too much the area relying on ambient texture to define their ambient occlusion.
  64632. */
  64633. useRadianceOcclusion: boolean;
  64634. /**
  64635. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  64636. * makes the reflect vector face the model (under horizon).
  64637. */
  64638. useHorizonOcclusion: boolean;
  64639. /**
  64640. * If set to true, no lighting calculations will be applied.
  64641. */
  64642. unlit: boolean;
  64643. /**
  64644. * Force normal to face away from face.
  64645. */
  64646. forceNormalForward: boolean;
  64647. /**
  64648. * Defines the material debug mode.
  64649. * It helps seeing only some components of the material while troubleshooting.
  64650. */
  64651. debugMode: number;
  64652. /**
  64653. * Specify from where on screen the debug mode should start.
  64654. * The value goes from -1 (full screen) to 1 (not visible)
  64655. * It helps with side by side comparison against the final render
  64656. * This defaults to 0
  64657. */
  64658. debugLimit: number;
  64659. /**
  64660. * As the default viewing range might not be enough (if the ambient is really small for instance)
  64661. * You can use the factor to better multiply the final value.
  64662. */
  64663. debugFactor: number;
  64664. /**
  64665. * Initialize the block and prepare the context for build
  64666. * @param state defines the state that will be used for the build
  64667. */
  64668. initialize(state: NodeMaterialBuildState): void;
  64669. /**
  64670. * Gets the current class name
  64671. * @returns the class name
  64672. */
  64673. getClassName(): string;
  64674. /**
  64675. * Gets the world position input component
  64676. */
  64677. get worldPosition(): NodeMaterialConnectionPoint;
  64678. /**
  64679. * Gets the world normal input component
  64680. */
  64681. get worldNormal(): NodeMaterialConnectionPoint;
  64682. /**
  64683. * Gets the perturbed normal input component
  64684. */
  64685. get perturbedNormal(): NodeMaterialConnectionPoint;
  64686. /**
  64687. * Gets the camera position input component
  64688. */
  64689. get cameraPosition(): NodeMaterialConnectionPoint;
  64690. /**
  64691. * Gets the base color input component
  64692. */
  64693. get baseColor(): NodeMaterialConnectionPoint;
  64694. /**
  64695. * Gets the opacity texture input component
  64696. */
  64697. get opacityTexture(): NodeMaterialConnectionPoint;
  64698. /**
  64699. * Gets the ambient color input component
  64700. */
  64701. get ambientColor(): NodeMaterialConnectionPoint;
  64702. /**
  64703. * Gets the reflectivity object parameters
  64704. */
  64705. get reflectivity(): NodeMaterialConnectionPoint;
  64706. /**
  64707. * Gets the ambient occlusion object parameters
  64708. */
  64709. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64710. /**
  64711. * Gets the reflection object parameters
  64712. */
  64713. get reflection(): NodeMaterialConnectionPoint;
  64714. /**
  64715. * Gets the sheen object parameters
  64716. */
  64717. get sheen(): NodeMaterialConnectionPoint;
  64718. /**
  64719. * Gets the clear coat object parameters
  64720. */
  64721. get clearcoat(): NodeMaterialConnectionPoint;
  64722. /**
  64723. * Gets the sub surface object parameters
  64724. */
  64725. get subsurface(): NodeMaterialConnectionPoint;
  64726. /**
  64727. * Gets the anisotropy object parameters
  64728. */
  64729. get anisotropy(): NodeMaterialConnectionPoint;
  64730. /**
  64731. * Gets the ambient output component
  64732. */
  64733. get ambient(): NodeMaterialConnectionPoint;
  64734. /**
  64735. * Gets the diffuse output component
  64736. */
  64737. get diffuse(): NodeMaterialConnectionPoint;
  64738. /**
  64739. * Gets the specular output component
  64740. */
  64741. get specular(): NodeMaterialConnectionPoint;
  64742. /**
  64743. * Gets the sheen output component
  64744. */
  64745. get sheenDir(): NodeMaterialConnectionPoint;
  64746. /**
  64747. * Gets the clear coat output component
  64748. */
  64749. get clearcoatDir(): NodeMaterialConnectionPoint;
  64750. /**
  64751. * Gets the indirect diffuse output component
  64752. */
  64753. get diffuseIndirect(): NodeMaterialConnectionPoint;
  64754. /**
  64755. * Gets the indirect specular output component
  64756. */
  64757. get specularIndirect(): NodeMaterialConnectionPoint;
  64758. /**
  64759. * Gets the indirect sheen output component
  64760. */
  64761. get sheenIndirect(): NodeMaterialConnectionPoint;
  64762. /**
  64763. * Gets the indirect clear coat output component
  64764. */
  64765. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  64766. /**
  64767. * Gets the refraction output component
  64768. */
  64769. get refraction(): NodeMaterialConnectionPoint;
  64770. /**
  64771. * Gets the global lighting output component
  64772. */
  64773. get lighting(): NodeMaterialConnectionPoint;
  64774. /**
  64775. * Gets the shadow output component
  64776. */
  64777. get shadow(): NodeMaterialConnectionPoint;
  64778. /**
  64779. * Gets the alpha output component
  64780. */
  64781. get alpha(): NodeMaterialConnectionPoint;
  64782. autoConfigure(material: NodeMaterial): void;
  64783. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64784. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64785. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64786. private _injectVertexCode;
  64787. /**
  64788. * Gets the code corresponding to the albedo/opacity module
  64789. * @returns the shader code
  64790. */
  64791. getAlbedoOpacityCode(): string;
  64792. protected _buildBlock(state: NodeMaterialBuildState): this;
  64793. protected _dumpPropertiesCode(): string;
  64794. serialize(): any;
  64795. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64796. }
  64797. }
  64798. declare module BABYLON {
  64799. /**
  64800. * Block used to compute value of one parameter modulo another
  64801. */
  64802. export class ModBlock extends NodeMaterialBlock {
  64803. /**
  64804. * Creates a new ModBlock
  64805. * @param name defines the block name
  64806. */
  64807. constructor(name: string);
  64808. /**
  64809. * Gets the current class name
  64810. * @returns the class name
  64811. */
  64812. getClassName(): string;
  64813. /**
  64814. * Gets the left operand input component
  64815. */
  64816. get left(): NodeMaterialConnectionPoint;
  64817. /**
  64818. * Gets the right operand input component
  64819. */
  64820. get right(): NodeMaterialConnectionPoint;
  64821. /**
  64822. * Gets the output component
  64823. */
  64824. get output(): NodeMaterialConnectionPoint;
  64825. protected _buildBlock(state: NodeMaterialBuildState): this;
  64826. }
  64827. }
  64828. declare module BABYLON {
  64829. /**
  64830. * Helper class to push actions to a pool of workers.
  64831. */
  64832. export class WorkerPool implements IDisposable {
  64833. private _workerInfos;
  64834. private _pendingActions;
  64835. /**
  64836. * Constructor
  64837. * @param workers Array of workers to use for actions
  64838. */
  64839. constructor(workers: Array<Worker>);
  64840. /**
  64841. * Terminates all workers and clears any pending actions.
  64842. */
  64843. dispose(): void;
  64844. /**
  64845. * Pushes an action to the worker pool. If all the workers are active, the action will be
  64846. * pended until a worker has completed its action.
  64847. * @param action The action to perform. Call onComplete when the action is complete.
  64848. */
  64849. push(action: (worker: Worker, onComplete: () => void) => void): void;
  64850. private _execute;
  64851. }
  64852. }
  64853. declare module BABYLON {
  64854. /**
  64855. * Configuration for Draco compression
  64856. */
  64857. export interface IDracoCompressionConfiguration {
  64858. /**
  64859. * Configuration for the decoder.
  64860. */
  64861. decoder: {
  64862. /**
  64863. * The url to the WebAssembly module.
  64864. */
  64865. wasmUrl?: string;
  64866. /**
  64867. * The url to the WebAssembly binary.
  64868. */
  64869. wasmBinaryUrl?: string;
  64870. /**
  64871. * The url to the fallback JavaScript module.
  64872. */
  64873. fallbackUrl?: string;
  64874. };
  64875. }
  64876. /**
  64877. * Draco compression (https://google.github.io/draco/)
  64878. *
  64879. * This class wraps the Draco module.
  64880. *
  64881. * **Encoder**
  64882. *
  64883. * The encoder is not currently implemented.
  64884. *
  64885. * **Decoder**
  64886. *
  64887. * 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.
  64888. *
  64889. * To update the configuration, use the following code:
  64890. * ```javascript
  64891. * DracoCompression.Configuration = {
  64892. * decoder: {
  64893. * wasmUrl: "<url to the WebAssembly library>",
  64894. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  64895. * fallbackUrl: "<url to the fallback JavaScript library>",
  64896. * }
  64897. * };
  64898. * ```
  64899. *
  64900. * 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.
  64901. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  64902. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  64903. *
  64904. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  64905. * ```javascript
  64906. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  64907. * ```
  64908. *
  64909. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  64910. */
  64911. export class DracoCompression implements IDisposable {
  64912. private _workerPoolPromise?;
  64913. private _decoderModulePromise?;
  64914. /**
  64915. * The configuration. Defaults to the following urls:
  64916. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  64917. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  64918. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  64919. */
  64920. static Configuration: IDracoCompressionConfiguration;
  64921. /**
  64922. * Returns true if the decoder configuration is available.
  64923. */
  64924. static get DecoderAvailable(): boolean;
  64925. /**
  64926. * Default number of workers to create when creating the draco compression object.
  64927. */
  64928. static DefaultNumWorkers: number;
  64929. private static GetDefaultNumWorkers;
  64930. private static _Default;
  64931. /**
  64932. * Default instance for the draco compression object.
  64933. */
  64934. static get Default(): DracoCompression;
  64935. /**
  64936. * Constructor
  64937. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  64938. */
  64939. constructor(numWorkers?: number);
  64940. /**
  64941. * Stop all async operations and release resources.
  64942. */
  64943. dispose(): void;
  64944. /**
  64945. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  64946. * @returns a promise that resolves when ready
  64947. */
  64948. whenReadyAsync(): Promise<void>;
  64949. /**
  64950. * Decode Draco compressed mesh data to vertex data.
  64951. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  64952. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  64953. * @returns A promise that resolves with the decoded vertex data
  64954. */
  64955. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  64956. [kind: string]: number;
  64957. }): Promise<VertexData>;
  64958. }
  64959. }
  64960. declare module BABYLON {
  64961. /**
  64962. * Class for building Constructive Solid Geometry
  64963. */
  64964. export class CSG {
  64965. private polygons;
  64966. /**
  64967. * The world matrix
  64968. */
  64969. matrix: Matrix;
  64970. /**
  64971. * Stores the position
  64972. */
  64973. position: Vector3;
  64974. /**
  64975. * Stores the rotation
  64976. */
  64977. rotation: Vector3;
  64978. /**
  64979. * Stores the rotation quaternion
  64980. */
  64981. rotationQuaternion: Nullable<Quaternion>;
  64982. /**
  64983. * Stores the scaling vector
  64984. */
  64985. scaling: Vector3;
  64986. /**
  64987. * Convert the Mesh to CSG
  64988. * @param mesh The Mesh to convert to CSG
  64989. * @returns A new CSG from the Mesh
  64990. */
  64991. static FromMesh(mesh: Mesh): CSG;
  64992. /**
  64993. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  64994. * @param polygons Polygons used to construct a CSG solid
  64995. */
  64996. private static FromPolygons;
  64997. /**
  64998. * Clones, or makes a deep copy, of the CSG
  64999. * @returns A new CSG
  65000. */
  65001. clone(): CSG;
  65002. /**
  65003. * Unions this CSG with another CSG
  65004. * @param csg The CSG to union against this CSG
  65005. * @returns The unioned CSG
  65006. */
  65007. union(csg: CSG): CSG;
  65008. /**
  65009. * Unions this CSG with another CSG in place
  65010. * @param csg The CSG to union against this CSG
  65011. */
  65012. unionInPlace(csg: CSG): void;
  65013. /**
  65014. * Subtracts this CSG with another CSG
  65015. * @param csg The CSG to subtract against this CSG
  65016. * @returns A new CSG
  65017. */
  65018. subtract(csg: CSG): CSG;
  65019. /**
  65020. * Subtracts this CSG with another CSG in place
  65021. * @param csg The CSG to subtact against this CSG
  65022. */
  65023. subtractInPlace(csg: CSG): void;
  65024. /**
  65025. * Intersect this CSG with another CSG
  65026. * @param csg The CSG to intersect against this CSG
  65027. * @returns A new CSG
  65028. */
  65029. intersect(csg: CSG): CSG;
  65030. /**
  65031. * Intersects this CSG with another CSG in place
  65032. * @param csg The CSG to intersect against this CSG
  65033. */
  65034. intersectInPlace(csg: CSG): void;
  65035. /**
  65036. * Return a new CSG solid with solid and empty space switched. This solid is
  65037. * not modified.
  65038. * @returns A new CSG solid with solid and empty space switched
  65039. */
  65040. inverse(): CSG;
  65041. /**
  65042. * Inverses the CSG in place
  65043. */
  65044. inverseInPlace(): void;
  65045. /**
  65046. * This is used to keep meshes transformations so they can be restored
  65047. * when we build back a Babylon Mesh
  65048. * NB : All CSG operations are performed in world coordinates
  65049. * @param csg The CSG to copy the transform attributes from
  65050. * @returns This CSG
  65051. */
  65052. copyTransformAttributes(csg: CSG): CSG;
  65053. /**
  65054. * Build Raw mesh from CSG
  65055. * Coordinates here are in world space
  65056. * @param name The name of the mesh geometry
  65057. * @param scene The Scene
  65058. * @param keepSubMeshes Specifies if the submeshes should be kept
  65059. * @returns A new Mesh
  65060. */
  65061. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65062. /**
  65063. * Build Mesh from CSG taking material and transforms into account
  65064. * @param name The name of the Mesh
  65065. * @param material The material of the Mesh
  65066. * @param scene The Scene
  65067. * @param keepSubMeshes Specifies if submeshes should be kept
  65068. * @returns The new Mesh
  65069. */
  65070. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65071. }
  65072. }
  65073. declare module BABYLON {
  65074. /**
  65075. * Class used to create a trail following a mesh
  65076. */
  65077. export class TrailMesh extends Mesh {
  65078. private _generator;
  65079. private _autoStart;
  65080. private _running;
  65081. private _diameter;
  65082. private _length;
  65083. private _sectionPolygonPointsCount;
  65084. private _sectionVectors;
  65085. private _sectionNormalVectors;
  65086. private _beforeRenderObserver;
  65087. /**
  65088. * @constructor
  65089. * @param name The value used by scene.getMeshByName() to do a lookup.
  65090. * @param generator The mesh or transform node to generate a trail.
  65091. * @param scene The scene to add this mesh to.
  65092. * @param diameter Diameter of trailing mesh. Default is 1.
  65093. * @param length Length of trailing mesh. Default is 60.
  65094. * @param autoStart Automatically start trailing mesh. Default true.
  65095. */
  65096. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  65097. /**
  65098. * "TrailMesh"
  65099. * @returns "TrailMesh"
  65100. */
  65101. getClassName(): string;
  65102. private _createMesh;
  65103. /**
  65104. * Start trailing mesh.
  65105. */
  65106. start(): void;
  65107. /**
  65108. * Stop trailing mesh.
  65109. */
  65110. stop(): void;
  65111. /**
  65112. * Update trailing mesh geometry.
  65113. */
  65114. update(): void;
  65115. /**
  65116. * Returns a new TrailMesh object.
  65117. * @param name is a string, the name given to the new mesh
  65118. * @param newGenerator use new generator object for cloned trail mesh
  65119. * @returns a new mesh
  65120. */
  65121. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  65122. /**
  65123. * Serializes this trail mesh
  65124. * @param serializationObject object to write serialization to
  65125. */
  65126. serialize(serializationObject: any): void;
  65127. /**
  65128. * Parses a serialized trail mesh
  65129. * @param parsedMesh the serialized mesh
  65130. * @param scene the scene to create the trail mesh in
  65131. * @returns the created trail mesh
  65132. */
  65133. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  65134. }
  65135. }
  65136. declare module BABYLON {
  65137. /**
  65138. * Class containing static functions to help procedurally build meshes
  65139. */
  65140. export class TiledBoxBuilder {
  65141. /**
  65142. * Creates a box mesh
  65143. * 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)
  65144. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65145. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65146. * * 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
  65147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65148. * @param name defines the name of the mesh
  65149. * @param options defines the options used to create the mesh
  65150. * @param scene defines the hosting scene
  65151. * @returns the box mesh
  65152. */
  65153. static CreateTiledBox(name: string, options: {
  65154. pattern?: number;
  65155. width?: number;
  65156. height?: number;
  65157. depth?: number;
  65158. tileSize?: number;
  65159. tileWidth?: number;
  65160. tileHeight?: number;
  65161. alignHorizontal?: number;
  65162. alignVertical?: number;
  65163. faceUV?: Vector4[];
  65164. faceColors?: Color4[];
  65165. sideOrientation?: number;
  65166. updatable?: boolean;
  65167. }, scene?: Nullable<Scene>): Mesh;
  65168. }
  65169. }
  65170. declare module BABYLON {
  65171. /**
  65172. * Class containing static functions to help procedurally build meshes
  65173. */
  65174. export class TorusKnotBuilder {
  65175. /**
  65176. * Creates a torus knot mesh
  65177. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65178. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65179. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65180. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65181. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65182. * * 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
  65183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65184. * @param name defines the name of the mesh
  65185. * @param options defines the options used to create the mesh
  65186. * @param scene defines the hosting scene
  65187. * @returns the torus knot mesh
  65188. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65189. */
  65190. static CreateTorusKnot(name: string, options: {
  65191. radius?: number;
  65192. tube?: number;
  65193. radialSegments?: number;
  65194. tubularSegments?: number;
  65195. p?: number;
  65196. q?: number;
  65197. updatable?: boolean;
  65198. sideOrientation?: number;
  65199. frontUVs?: Vector4;
  65200. backUVs?: Vector4;
  65201. }, scene: any): Mesh;
  65202. }
  65203. }
  65204. declare module BABYLON {
  65205. /**
  65206. * Polygon
  65207. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  65208. */
  65209. export class Polygon {
  65210. /**
  65211. * Creates a rectangle
  65212. * @param xmin bottom X coord
  65213. * @param ymin bottom Y coord
  65214. * @param xmax top X coord
  65215. * @param ymax top Y coord
  65216. * @returns points that make the resulting rectation
  65217. */
  65218. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  65219. /**
  65220. * Creates a circle
  65221. * @param radius radius of circle
  65222. * @param cx scale in x
  65223. * @param cy scale in y
  65224. * @param numberOfSides number of sides that make up the circle
  65225. * @returns points that make the resulting circle
  65226. */
  65227. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  65228. /**
  65229. * Creates a polygon from input string
  65230. * @param input Input polygon data
  65231. * @returns the parsed points
  65232. */
  65233. static Parse(input: string): Vector2[];
  65234. /**
  65235. * Starts building a polygon from x and y coordinates
  65236. * @param x x coordinate
  65237. * @param y y coordinate
  65238. * @returns the started path2
  65239. */
  65240. static StartingAt(x: number, y: number): Path2;
  65241. }
  65242. /**
  65243. * Builds a polygon
  65244. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  65245. */
  65246. export class PolygonMeshBuilder {
  65247. private _points;
  65248. private _outlinepoints;
  65249. private _holes;
  65250. private _name;
  65251. private _scene;
  65252. private _epoints;
  65253. private _eholes;
  65254. private _addToepoint;
  65255. /**
  65256. * Babylon reference to the earcut plugin.
  65257. */
  65258. bjsEarcut: any;
  65259. /**
  65260. * Creates a PolygonMeshBuilder
  65261. * @param name name of the builder
  65262. * @param contours Path of the polygon
  65263. * @param scene scene to add to when creating the mesh
  65264. * @param earcutInjection can be used to inject your own earcut reference
  65265. */
  65266. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  65267. /**
  65268. * Adds a whole within the polygon
  65269. * @param hole Array of points defining the hole
  65270. * @returns this
  65271. */
  65272. addHole(hole: Vector2[]): PolygonMeshBuilder;
  65273. /**
  65274. * Creates the polygon
  65275. * @param updatable If the mesh should be updatable
  65276. * @param depth The depth of the mesh created
  65277. * @returns the created mesh
  65278. */
  65279. build(updatable?: boolean, depth?: number): Mesh;
  65280. /**
  65281. * Creates the polygon
  65282. * @param depth The depth of the mesh created
  65283. * @returns the created VertexData
  65284. */
  65285. buildVertexData(depth?: number): VertexData;
  65286. /**
  65287. * Adds a side to the polygon
  65288. * @param positions points that make the polygon
  65289. * @param normals normals of the polygon
  65290. * @param uvs uvs of the polygon
  65291. * @param indices indices of the polygon
  65292. * @param bounds bounds of the polygon
  65293. * @param points points of the polygon
  65294. * @param depth depth of the polygon
  65295. * @param flip flip of the polygon
  65296. */
  65297. private addSide;
  65298. }
  65299. }
  65300. declare module BABYLON {
  65301. /**
  65302. * Class containing static functions to help procedurally build meshes
  65303. */
  65304. export class PolygonBuilder {
  65305. /**
  65306. * Creates a polygon mesh
  65307. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65308. * * 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
  65309. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65311. * * 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)
  65312. * * Remember you can only change the shape positions, not their number when updating a polygon
  65313. * @param name defines the name of the mesh
  65314. * @param options defines the options used to create the mesh
  65315. * @param scene defines the hosting scene
  65316. * @param earcutInjection can be used to inject your own earcut reference
  65317. * @returns the polygon mesh
  65318. */
  65319. static CreatePolygon(name: string, options: {
  65320. shape: Vector3[];
  65321. holes?: Vector3[][];
  65322. depth?: number;
  65323. faceUV?: Vector4[];
  65324. faceColors?: Color4[];
  65325. updatable?: boolean;
  65326. sideOrientation?: number;
  65327. frontUVs?: Vector4;
  65328. backUVs?: Vector4;
  65329. wrap?: boolean;
  65330. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65331. /**
  65332. * Creates an extruded polygon mesh, with depth in the Y direction.
  65333. * * 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)
  65334. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65335. * @param name defines the name of the mesh
  65336. * @param options defines the options used to create the mesh
  65337. * @param scene defines the hosting scene
  65338. * @param earcutInjection can be used to inject your own earcut reference
  65339. * @returns the polygon mesh
  65340. */
  65341. static ExtrudePolygon(name: string, options: {
  65342. shape: Vector3[];
  65343. holes?: Vector3[][];
  65344. depth?: number;
  65345. faceUV?: Vector4[];
  65346. faceColors?: Color4[];
  65347. updatable?: boolean;
  65348. sideOrientation?: number;
  65349. frontUVs?: Vector4;
  65350. backUVs?: Vector4;
  65351. wrap?: boolean;
  65352. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65353. }
  65354. }
  65355. declare module BABYLON {
  65356. /**
  65357. * Class containing static functions to help procedurally build meshes
  65358. */
  65359. export class LatheBuilder {
  65360. /**
  65361. * Creates lathe mesh.
  65362. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65363. * * 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
  65364. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65365. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65366. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65367. * * 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
  65368. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65369. * * 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
  65370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65371. * * 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
  65372. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65374. * @param name defines the name of the mesh
  65375. * @param options defines the options used to create the mesh
  65376. * @param scene defines the hosting scene
  65377. * @returns the lathe mesh
  65378. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65379. */
  65380. static CreateLathe(name: string, options: {
  65381. shape: Vector3[];
  65382. radius?: number;
  65383. tessellation?: number;
  65384. clip?: number;
  65385. arc?: number;
  65386. closed?: boolean;
  65387. updatable?: boolean;
  65388. sideOrientation?: number;
  65389. frontUVs?: Vector4;
  65390. backUVs?: Vector4;
  65391. cap?: number;
  65392. invertUV?: boolean;
  65393. }, scene?: Nullable<Scene>): Mesh;
  65394. }
  65395. }
  65396. declare module BABYLON {
  65397. /**
  65398. * Class containing static functions to help procedurally build meshes
  65399. */
  65400. export class TiledPlaneBuilder {
  65401. /**
  65402. * Creates a tiled plane mesh
  65403. * * The parameter `pattern` will, depending on value, do nothing or
  65404. * * * flip (reflect about central vertical) alternate tiles across and up
  65405. * * * flip every tile on alternate rows
  65406. * * * rotate (180 degs) alternate tiles across and up
  65407. * * * rotate every tile on alternate rows
  65408. * * * flip and rotate alternate tiles across and up
  65409. * * * flip and rotate every tile on alternate rows
  65410. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  65411. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  65412. * * 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
  65413. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65414. * * 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)
  65415. * * 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)
  65416. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65417. * @param name defines the name of the mesh
  65418. * @param options defines the options used to create the mesh
  65419. * @param scene defines the hosting scene
  65420. * @returns the box mesh
  65421. */
  65422. static CreateTiledPlane(name: string, options: {
  65423. pattern?: number;
  65424. tileSize?: number;
  65425. tileWidth?: number;
  65426. tileHeight?: number;
  65427. size?: number;
  65428. width?: number;
  65429. height?: number;
  65430. alignHorizontal?: number;
  65431. alignVertical?: number;
  65432. sideOrientation?: number;
  65433. frontUVs?: Vector4;
  65434. backUVs?: Vector4;
  65435. updatable?: boolean;
  65436. }, scene?: Nullable<Scene>): Mesh;
  65437. }
  65438. }
  65439. declare module BABYLON {
  65440. /**
  65441. * Class containing static functions to help procedurally build meshes
  65442. */
  65443. export class TubeBuilder {
  65444. /**
  65445. * Creates a tube mesh.
  65446. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65447. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65448. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65449. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65450. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65451. * * 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)
  65452. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65453. * * 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
  65454. * * 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
  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 tube mesh
  65463. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65464. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65465. */
  65466. static CreateTube(name: string, options: {
  65467. path: Vector3[];
  65468. radius?: number;
  65469. tessellation?: number;
  65470. radiusFunction?: {
  65471. (i: number, distance: number): number;
  65472. };
  65473. cap?: number;
  65474. arc?: number;
  65475. updatable?: boolean;
  65476. sideOrientation?: number;
  65477. frontUVs?: Vector4;
  65478. backUVs?: Vector4;
  65479. instance?: Mesh;
  65480. invertUV?: boolean;
  65481. }, scene?: Nullable<Scene>): Mesh;
  65482. }
  65483. }
  65484. declare module BABYLON {
  65485. /**
  65486. * Class containing static functions to help procedurally build meshes
  65487. */
  65488. export class IcoSphereBuilder {
  65489. /**
  65490. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65491. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65492. * * 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`)
  65493. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65494. * * 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
  65495. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65496. * * 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
  65497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65498. * @param name defines the name of the mesh
  65499. * @param options defines the options used to create the mesh
  65500. * @param scene defines the hosting scene
  65501. * @returns the icosahedron mesh
  65502. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65503. */
  65504. static CreateIcoSphere(name: string, options: {
  65505. radius?: number;
  65506. radiusX?: number;
  65507. radiusY?: number;
  65508. radiusZ?: number;
  65509. flat?: boolean;
  65510. subdivisions?: number;
  65511. sideOrientation?: number;
  65512. frontUVs?: Vector4;
  65513. backUVs?: Vector4;
  65514. updatable?: boolean;
  65515. }, scene?: Nullable<Scene>): Mesh;
  65516. }
  65517. }
  65518. declare module BABYLON {
  65519. /**
  65520. * Class containing static functions to help procedurally build meshes
  65521. */
  65522. export class DecalBuilder {
  65523. /**
  65524. * Creates a decal mesh.
  65525. * 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
  65526. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65527. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65528. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65529. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65530. * @param name defines the name of the mesh
  65531. * @param sourceMesh defines the mesh where the decal must be applied
  65532. * @param options defines the options used to create the mesh
  65533. * @param scene defines the hosting scene
  65534. * @returns the decal mesh
  65535. * @see https://doc.babylonjs.com/how_to/decals
  65536. */
  65537. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65538. position?: Vector3;
  65539. normal?: Vector3;
  65540. size?: Vector3;
  65541. angle?: number;
  65542. }): Mesh;
  65543. }
  65544. }
  65545. declare module BABYLON {
  65546. /**
  65547. * Class containing static functions to help procedurally build meshes
  65548. */
  65549. export class MeshBuilder {
  65550. /**
  65551. * Creates a box mesh
  65552. * * The parameter `size` sets the size (float) of each box side (default 1)
  65553. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  65554. * * 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)
  65555. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65556. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65557. * * 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
  65558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65559. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65560. * @param name defines the name of the mesh
  65561. * @param options defines the options used to create the mesh
  65562. * @param scene defines the hosting scene
  65563. * @returns the box mesh
  65564. */
  65565. static CreateBox(name: string, options: {
  65566. size?: number;
  65567. width?: number;
  65568. height?: number;
  65569. depth?: number;
  65570. faceUV?: Vector4[];
  65571. faceColors?: Color4[];
  65572. sideOrientation?: number;
  65573. frontUVs?: Vector4;
  65574. backUVs?: Vector4;
  65575. wrap?: boolean;
  65576. topBaseAt?: number;
  65577. bottomBaseAt?: number;
  65578. updatable?: boolean;
  65579. }, scene?: Nullable<Scene>): Mesh;
  65580. /**
  65581. * Creates a tiled box mesh
  65582. * * faceTiles sets the pattern, tile size and number of tiles for a face
  65583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65584. * @param name defines the name of the mesh
  65585. * @param options defines the options used to create the mesh
  65586. * @param scene defines the hosting scene
  65587. * @returns the tiled box mesh
  65588. */
  65589. static CreateTiledBox(name: string, options: {
  65590. pattern?: number;
  65591. size?: number;
  65592. width?: number;
  65593. height?: number;
  65594. depth: number;
  65595. tileSize?: number;
  65596. tileWidth?: number;
  65597. tileHeight?: number;
  65598. faceUV?: Vector4[];
  65599. faceColors?: Color4[];
  65600. alignHorizontal?: number;
  65601. alignVertical?: number;
  65602. sideOrientation?: number;
  65603. updatable?: boolean;
  65604. }, scene?: Nullable<Scene>): Mesh;
  65605. /**
  65606. * Creates a sphere mesh
  65607. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  65608. * * 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`)
  65609. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  65610. * * 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
  65611. * * 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)
  65612. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65613. * * 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
  65614. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65615. * @param name defines the name of the mesh
  65616. * @param options defines the options used to create the mesh
  65617. * @param scene defines the hosting scene
  65618. * @returns the sphere mesh
  65619. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  65620. */
  65621. static CreateSphere(name: string, options: {
  65622. segments?: number;
  65623. diameter?: number;
  65624. diameterX?: number;
  65625. diameterY?: number;
  65626. diameterZ?: number;
  65627. arc?: number;
  65628. slice?: number;
  65629. sideOrientation?: number;
  65630. frontUVs?: Vector4;
  65631. backUVs?: Vector4;
  65632. updatable?: boolean;
  65633. }, scene?: Nullable<Scene>): Mesh;
  65634. /**
  65635. * Creates a plane polygonal mesh. By default, this is a disc
  65636. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  65637. * * 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
  65638. * * 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
  65639. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65640. * * 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
  65641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65642. * @param name defines the name of the mesh
  65643. * @param options defines the options used to create the mesh
  65644. * @param scene defines the hosting scene
  65645. * @returns the plane polygonal mesh
  65646. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  65647. */
  65648. static CreateDisc(name: string, options: {
  65649. radius?: number;
  65650. tessellation?: number;
  65651. arc?: number;
  65652. updatable?: boolean;
  65653. sideOrientation?: number;
  65654. frontUVs?: Vector4;
  65655. backUVs?: Vector4;
  65656. }, scene?: Nullable<Scene>): Mesh;
  65657. /**
  65658. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65659. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65660. * * 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`)
  65661. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65662. * * 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
  65663. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65664. * * 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
  65665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65666. * @param name defines the name of the mesh
  65667. * @param options defines the options used to create the mesh
  65668. * @param scene defines the hosting scene
  65669. * @returns the icosahedron mesh
  65670. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65671. */
  65672. static CreateIcoSphere(name: string, options: {
  65673. radius?: number;
  65674. radiusX?: number;
  65675. radiusY?: number;
  65676. radiusZ?: number;
  65677. flat?: boolean;
  65678. subdivisions?: number;
  65679. sideOrientation?: number;
  65680. frontUVs?: Vector4;
  65681. backUVs?: Vector4;
  65682. updatable?: boolean;
  65683. }, scene?: Nullable<Scene>): Mesh;
  65684. /**
  65685. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65686. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  65687. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  65688. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  65689. * * 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
  65690. * * 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
  65691. * * 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
  65692. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65693. * * 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
  65694. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65695. * * 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
  65696. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  65697. * * 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
  65698. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  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 ribbon mesh
  65704. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  65705. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65706. */
  65707. static CreateRibbon(name: string, options: {
  65708. pathArray: Vector3[][];
  65709. closeArray?: boolean;
  65710. closePath?: boolean;
  65711. offset?: number;
  65712. updatable?: boolean;
  65713. sideOrientation?: number;
  65714. frontUVs?: Vector4;
  65715. backUVs?: Vector4;
  65716. instance?: Mesh;
  65717. invertUV?: boolean;
  65718. uvs?: Vector2[];
  65719. colors?: Color4[];
  65720. }, scene?: Nullable<Scene>): Mesh;
  65721. /**
  65722. * Creates a cylinder or a cone mesh
  65723. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  65724. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  65725. * * 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.
  65726. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  65727. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  65728. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  65729. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  65730. * * 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).
  65731. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  65732. * * 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).
  65733. * * 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
  65734. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  65735. * * 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
  65736. * * 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.
  65737. * * If `enclose` is false, a ring surface is one element.
  65738. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  65739. * * 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
  65740. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65741. * * 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
  65742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65743. * @param name defines the name of the mesh
  65744. * @param options defines the options used to create the mesh
  65745. * @param scene defines the hosting scene
  65746. * @returns the cylinder mesh
  65747. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  65748. */
  65749. static CreateCylinder(name: string, options: {
  65750. height?: number;
  65751. diameterTop?: number;
  65752. diameterBottom?: number;
  65753. diameter?: number;
  65754. tessellation?: number;
  65755. subdivisions?: number;
  65756. arc?: number;
  65757. faceColors?: Color4[];
  65758. faceUV?: Vector4[];
  65759. updatable?: boolean;
  65760. hasRings?: boolean;
  65761. enclose?: boolean;
  65762. cap?: number;
  65763. sideOrientation?: number;
  65764. frontUVs?: Vector4;
  65765. backUVs?: Vector4;
  65766. }, scene?: Nullable<Scene>): Mesh;
  65767. /**
  65768. * Creates a torus mesh
  65769. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  65770. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  65771. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  65772. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65773. * * 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
  65774. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65775. * @param name defines the name of the mesh
  65776. * @param options defines the options used to create the mesh
  65777. * @param scene defines the hosting scene
  65778. * @returns the torus mesh
  65779. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  65780. */
  65781. static CreateTorus(name: string, options: {
  65782. diameter?: number;
  65783. thickness?: number;
  65784. tessellation?: number;
  65785. updatable?: boolean;
  65786. sideOrientation?: number;
  65787. frontUVs?: Vector4;
  65788. backUVs?: Vector4;
  65789. }, scene?: Nullable<Scene>): Mesh;
  65790. /**
  65791. * Creates a torus knot mesh
  65792. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65793. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65794. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65795. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65797. * * 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
  65798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65799. * @param name defines the name of the mesh
  65800. * @param options defines the options used to create the mesh
  65801. * @param scene defines the hosting scene
  65802. * @returns the torus knot mesh
  65803. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65804. */
  65805. static CreateTorusKnot(name: string, options: {
  65806. radius?: number;
  65807. tube?: number;
  65808. radialSegments?: number;
  65809. tubularSegments?: number;
  65810. p?: number;
  65811. q?: number;
  65812. updatable?: boolean;
  65813. sideOrientation?: number;
  65814. frontUVs?: Vector4;
  65815. backUVs?: Vector4;
  65816. }, scene?: Nullable<Scene>): Mesh;
  65817. /**
  65818. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  65819. * * 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
  65820. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  65821. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  65822. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  65823. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  65824. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  65825. * * 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
  65826. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  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. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  65829. * @param name defines the name of the new line system
  65830. * @param options defines the options used to create the line system
  65831. * @param scene defines the hosting scene
  65832. * @returns a new line system mesh
  65833. */
  65834. static CreateLineSystem(name: string, options: {
  65835. lines: Vector3[][];
  65836. updatable?: boolean;
  65837. instance?: Nullable<LinesMesh>;
  65838. colors?: Nullable<Color4[][]>;
  65839. useVertexAlpha?: boolean;
  65840. }, scene: Nullable<Scene>): LinesMesh;
  65841. /**
  65842. * Creates a line mesh
  65843. * 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
  65844. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65845. * * The parameter `points` is an array successive Vector3
  65846. * * 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
  65847. * * The optional parameter `colors` is an array of successive Color4, one per line point
  65848. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  65849. * * When updating an instance, remember that only point positions can change, not the number of points
  65850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65851. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  65852. * @param name defines the name of the new line system
  65853. * @param options defines the options used to create the line system
  65854. * @param scene defines the hosting scene
  65855. * @returns a new line mesh
  65856. */
  65857. static CreateLines(name: string, options: {
  65858. points: Vector3[];
  65859. updatable?: boolean;
  65860. instance?: Nullable<LinesMesh>;
  65861. colors?: Color4[];
  65862. useVertexAlpha?: boolean;
  65863. }, scene?: Nullable<Scene>): LinesMesh;
  65864. /**
  65865. * Creates a dashed line mesh
  65866. * * 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
  65867. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65868. * * The parameter `points` is an array successive Vector3
  65869. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  65870. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  65871. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  65872. * * 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
  65873. * * When updating an instance, remember that only point positions can change, not the number of points
  65874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65875. * @param name defines the name of the mesh
  65876. * @param options defines the options used to create the mesh
  65877. * @param scene defines the hosting scene
  65878. * @returns the dashed line mesh
  65879. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  65880. */
  65881. static CreateDashedLines(name: string, options: {
  65882. points: Vector3[];
  65883. dashSize?: number;
  65884. gapSize?: number;
  65885. dashNb?: number;
  65886. updatable?: boolean;
  65887. instance?: LinesMesh;
  65888. }, scene?: Nullable<Scene>): LinesMesh;
  65889. /**
  65890. * 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.
  65891. * * 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.
  65892. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65893. * * 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.
  65894. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  65895. * * 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
  65896. * * 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
  65897. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  65898. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65899. * * 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
  65900. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  65901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65902. * @param name defines the name of the mesh
  65903. * @param options defines the options used to create the mesh
  65904. * @param scene defines the hosting scene
  65905. * @returns the extruded shape mesh
  65906. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65907. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65908. */
  65909. static ExtrudeShape(name: string, options: {
  65910. shape: Vector3[];
  65911. path: Vector3[];
  65912. scale?: number;
  65913. rotation?: number;
  65914. cap?: number;
  65915. updatable?: boolean;
  65916. sideOrientation?: number;
  65917. frontUVs?: Vector4;
  65918. backUVs?: Vector4;
  65919. instance?: Mesh;
  65920. invertUV?: boolean;
  65921. }, scene?: Nullable<Scene>): Mesh;
  65922. /**
  65923. * Creates an custom extruded shape mesh.
  65924. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  65925. * * 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.
  65926. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65927. * * 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
  65928. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  65929. * * 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
  65930. * * It must returns a float value that will be the scale value applied to the shape on each path point
  65931. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  65932. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  65933. * * 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
  65934. * * 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
  65935. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  65936. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65937. * * 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
  65938. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65940. * @param name defines the name of the mesh
  65941. * @param options defines the options used to create the mesh
  65942. * @param scene defines the hosting scene
  65943. * @returns the custom extruded shape mesh
  65944. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  65945. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65946. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65947. */
  65948. static ExtrudeShapeCustom(name: string, options: {
  65949. shape: Vector3[];
  65950. path: Vector3[];
  65951. scaleFunction?: any;
  65952. rotationFunction?: any;
  65953. ribbonCloseArray?: boolean;
  65954. ribbonClosePath?: boolean;
  65955. cap?: number;
  65956. updatable?: boolean;
  65957. sideOrientation?: number;
  65958. frontUVs?: Vector4;
  65959. backUVs?: Vector4;
  65960. instance?: Mesh;
  65961. invertUV?: boolean;
  65962. }, scene?: Nullable<Scene>): Mesh;
  65963. /**
  65964. * Creates lathe mesh.
  65965. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65966. * * 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
  65967. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65968. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65969. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65970. * * 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
  65971. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65972. * * 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
  65973. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65974. * * 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
  65975. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65977. * @param name defines the name of the mesh
  65978. * @param options defines the options used to create the mesh
  65979. * @param scene defines the hosting scene
  65980. * @returns the lathe mesh
  65981. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65982. */
  65983. static CreateLathe(name: string, options: {
  65984. shape: Vector3[];
  65985. radius?: number;
  65986. tessellation?: number;
  65987. clip?: number;
  65988. arc?: number;
  65989. closed?: boolean;
  65990. updatable?: boolean;
  65991. sideOrientation?: number;
  65992. frontUVs?: Vector4;
  65993. backUVs?: Vector4;
  65994. cap?: number;
  65995. invertUV?: boolean;
  65996. }, scene?: Nullable<Scene>): Mesh;
  65997. /**
  65998. * Creates a tiled plane mesh
  65999. * * You can set a limited pattern arrangement with the tiles
  66000. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66001. * * 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
  66002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66003. * @param name defines the name of the mesh
  66004. * @param options defines the options used to create the mesh
  66005. * @param scene defines the hosting scene
  66006. * @returns the plane mesh
  66007. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66008. */
  66009. static CreateTiledPlane(name: string, options: {
  66010. pattern?: number;
  66011. tileSize?: number;
  66012. tileWidth?: number;
  66013. tileHeight?: number;
  66014. size?: number;
  66015. width?: number;
  66016. height?: number;
  66017. alignHorizontal?: number;
  66018. alignVertical?: number;
  66019. sideOrientation?: number;
  66020. frontUVs?: Vector4;
  66021. backUVs?: Vector4;
  66022. updatable?: boolean;
  66023. }, scene?: Nullable<Scene>): Mesh;
  66024. /**
  66025. * Creates a plane mesh
  66026. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  66027. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  66028. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  66029. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66030. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66031. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66032. * @param name defines the name of the mesh
  66033. * @param options defines the options used to create the mesh
  66034. * @param scene defines the hosting scene
  66035. * @returns the plane mesh
  66036. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66037. */
  66038. static CreatePlane(name: string, options: {
  66039. size?: number;
  66040. width?: number;
  66041. height?: number;
  66042. sideOrientation?: number;
  66043. frontUVs?: Vector4;
  66044. backUVs?: Vector4;
  66045. updatable?: boolean;
  66046. sourcePlane?: Plane;
  66047. }, scene?: Nullable<Scene>): Mesh;
  66048. /**
  66049. * Creates a ground mesh
  66050. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  66051. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  66052. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66053. * @param name defines the name of the mesh
  66054. * @param options defines the options used to create the mesh
  66055. * @param scene defines the hosting scene
  66056. * @returns the ground mesh
  66057. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  66058. */
  66059. static CreateGround(name: string, options: {
  66060. width?: number;
  66061. height?: number;
  66062. subdivisions?: number;
  66063. subdivisionsX?: number;
  66064. subdivisionsY?: number;
  66065. updatable?: boolean;
  66066. }, scene?: Nullable<Scene>): Mesh;
  66067. /**
  66068. * Creates a tiled ground mesh
  66069. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  66070. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  66071. * * 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
  66072. * * 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
  66073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66074. * @param name defines the name of the mesh
  66075. * @param options defines the options used to create the mesh
  66076. * @param scene defines the hosting scene
  66077. * @returns the tiled ground mesh
  66078. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  66079. */
  66080. static CreateTiledGround(name: string, options: {
  66081. xmin: number;
  66082. zmin: number;
  66083. xmax: number;
  66084. zmax: number;
  66085. subdivisions?: {
  66086. w: number;
  66087. h: number;
  66088. };
  66089. precision?: {
  66090. w: number;
  66091. h: number;
  66092. };
  66093. updatable?: boolean;
  66094. }, scene?: Nullable<Scene>): Mesh;
  66095. /**
  66096. * Creates a ground mesh from a height map
  66097. * * The parameter `url` sets the URL of the height map image resource.
  66098. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  66099. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  66100. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  66101. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  66102. * * 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.
  66103. * * 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).
  66104. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  66105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66106. * @param name defines the name of the mesh
  66107. * @param url defines the url to the height map
  66108. * @param options defines the options used to create the mesh
  66109. * @param scene defines the hosting scene
  66110. * @returns the ground mesh
  66111. * @see https://doc.babylonjs.com/babylon101/height_map
  66112. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  66113. */
  66114. static CreateGroundFromHeightMap(name: string, url: string, options: {
  66115. width?: number;
  66116. height?: number;
  66117. subdivisions?: number;
  66118. minHeight?: number;
  66119. maxHeight?: number;
  66120. colorFilter?: Color3;
  66121. alphaFilter?: number;
  66122. updatable?: boolean;
  66123. onReady?: (mesh: GroundMesh) => void;
  66124. }, scene?: Nullable<Scene>): GroundMesh;
  66125. /**
  66126. * Creates a polygon mesh
  66127. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66128. * * 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
  66129. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66131. * * 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)
  66132. * * Remember you can only change the shape positions, not their number when updating a polygon
  66133. * @param name defines the name of the mesh
  66134. * @param options defines the options used to create the mesh
  66135. * @param scene defines the hosting scene
  66136. * @param earcutInjection can be used to inject your own earcut reference
  66137. * @returns the polygon mesh
  66138. */
  66139. static CreatePolygon(name: string, options: {
  66140. shape: Vector3[];
  66141. holes?: Vector3[][];
  66142. depth?: number;
  66143. faceUV?: Vector4[];
  66144. faceColors?: Color4[];
  66145. updatable?: boolean;
  66146. sideOrientation?: number;
  66147. frontUVs?: Vector4;
  66148. backUVs?: Vector4;
  66149. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66150. /**
  66151. * Creates an extruded polygon mesh, with depth in the Y direction.
  66152. * * 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)
  66153. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66154. * @param name defines the name of the mesh
  66155. * @param options defines the options used to create the mesh
  66156. * @param scene defines the hosting scene
  66157. * @param earcutInjection can be used to inject your own earcut reference
  66158. * @returns the polygon mesh
  66159. */
  66160. static ExtrudePolygon(name: string, options: {
  66161. shape: Vector3[];
  66162. holes?: Vector3[][];
  66163. depth?: number;
  66164. faceUV?: Vector4[];
  66165. faceColors?: Color4[];
  66166. updatable?: boolean;
  66167. sideOrientation?: number;
  66168. frontUVs?: Vector4;
  66169. backUVs?: Vector4;
  66170. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66171. /**
  66172. * Creates a tube mesh.
  66173. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66174. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66175. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66176. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66177. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66178. * * 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)
  66179. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66180. * * 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
  66181. * * 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
  66182. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66183. * * 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
  66184. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66186. * @param name defines the name of the mesh
  66187. * @param options defines the options used to create the mesh
  66188. * @param scene defines the hosting scene
  66189. * @returns the tube mesh
  66190. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66191. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66192. */
  66193. static CreateTube(name: string, options: {
  66194. path: Vector3[];
  66195. radius?: number;
  66196. tessellation?: number;
  66197. radiusFunction?: {
  66198. (i: number, distance: number): number;
  66199. };
  66200. cap?: number;
  66201. arc?: number;
  66202. updatable?: boolean;
  66203. sideOrientation?: number;
  66204. frontUVs?: Vector4;
  66205. backUVs?: Vector4;
  66206. instance?: Mesh;
  66207. invertUV?: boolean;
  66208. }, scene?: Nullable<Scene>): Mesh;
  66209. /**
  66210. * Creates a polyhedron mesh
  66211. * * 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
  66212. * * The parameter `size` (positive float, default 1) sets the polygon size
  66213. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  66214. * * 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`
  66215. * * 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
  66216. * * 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)`)
  66217. * * 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
  66218. * * 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
  66219. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66220. * * 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
  66221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66222. * @param name defines the name of the mesh
  66223. * @param options defines the options used to create the mesh
  66224. * @param scene defines the hosting scene
  66225. * @returns the polyhedron mesh
  66226. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  66227. */
  66228. static CreatePolyhedron(name: string, options: {
  66229. type?: number;
  66230. size?: number;
  66231. sizeX?: number;
  66232. sizeY?: number;
  66233. sizeZ?: number;
  66234. custom?: any;
  66235. faceUV?: Vector4[];
  66236. faceColors?: Color4[];
  66237. flat?: boolean;
  66238. updatable?: boolean;
  66239. sideOrientation?: number;
  66240. frontUVs?: Vector4;
  66241. backUVs?: Vector4;
  66242. }, scene?: Nullable<Scene>): Mesh;
  66243. /**
  66244. * Creates a decal mesh.
  66245. * 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
  66246. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66247. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66248. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66249. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66250. * @param name defines the name of the mesh
  66251. * @param sourceMesh defines the mesh where the decal must be applied
  66252. * @param options defines the options used to create the mesh
  66253. * @param scene defines the hosting scene
  66254. * @returns the decal mesh
  66255. * @see https://doc.babylonjs.com/how_to/decals
  66256. */
  66257. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66258. position?: Vector3;
  66259. normal?: Vector3;
  66260. size?: Vector3;
  66261. angle?: number;
  66262. }): Mesh;
  66263. }
  66264. }
  66265. declare module BABYLON {
  66266. /**
  66267. * A simplifier interface for future simplification implementations
  66268. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66269. */
  66270. export interface ISimplifier {
  66271. /**
  66272. * Simplification of a given mesh according to the given settings.
  66273. * Since this requires computation, it is assumed that the function runs async.
  66274. * @param settings The settings of the simplification, including quality and distance
  66275. * @param successCallback A callback that will be called after the mesh was simplified.
  66276. * @param errorCallback in case of an error, this callback will be called. optional.
  66277. */
  66278. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  66279. }
  66280. /**
  66281. * Expected simplification settings.
  66282. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  66283. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66284. */
  66285. export interface ISimplificationSettings {
  66286. /**
  66287. * Gets or sets the expected quality
  66288. */
  66289. quality: number;
  66290. /**
  66291. * Gets or sets the distance when this optimized version should be used
  66292. */
  66293. distance: number;
  66294. /**
  66295. * Gets an already optimized mesh
  66296. */
  66297. optimizeMesh?: boolean;
  66298. }
  66299. /**
  66300. * Class used to specify simplification options
  66301. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66302. */
  66303. export class SimplificationSettings implements ISimplificationSettings {
  66304. /** expected quality */
  66305. quality: number;
  66306. /** distance when this optimized version should be used */
  66307. distance: number;
  66308. /** already optimized mesh */
  66309. optimizeMesh?: boolean | undefined;
  66310. /**
  66311. * Creates a SimplificationSettings
  66312. * @param quality expected quality
  66313. * @param distance distance when this optimized version should be used
  66314. * @param optimizeMesh already optimized mesh
  66315. */
  66316. constructor(
  66317. /** expected quality */
  66318. quality: number,
  66319. /** distance when this optimized version should be used */
  66320. distance: number,
  66321. /** already optimized mesh */
  66322. optimizeMesh?: boolean | undefined);
  66323. }
  66324. /**
  66325. * Interface used to define a simplification task
  66326. */
  66327. export interface ISimplificationTask {
  66328. /**
  66329. * Array of settings
  66330. */
  66331. settings: Array<ISimplificationSettings>;
  66332. /**
  66333. * Simplification type
  66334. */
  66335. simplificationType: SimplificationType;
  66336. /**
  66337. * Mesh to simplify
  66338. */
  66339. mesh: Mesh;
  66340. /**
  66341. * Callback called on success
  66342. */
  66343. successCallback?: () => void;
  66344. /**
  66345. * Defines if parallel processing can be used
  66346. */
  66347. parallelProcessing: boolean;
  66348. }
  66349. /**
  66350. * Queue used to order the simplification tasks
  66351. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66352. */
  66353. export class SimplificationQueue {
  66354. private _simplificationArray;
  66355. /**
  66356. * Gets a boolean indicating that the process is still running
  66357. */
  66358. running: boolean;
  66359. /**
  66360. * Creates a new queue
  66361. */
  66362. constructor();
  66363. /**
  66364. * Adds a new simplification task
  66365. * @param task defines a task to add
  66366. */
  66367. addTask(task: ISimplificationTask): void;
  66368. /**
  66369. * Execute next task
  66370. */
  66371. executeNext(): void;
  66372. /**
  66373. * Execute a simplification task
  66374. * @param task defines the task to run
  66375. */
  66376. runSimplification(task: ISimplificationTask): void;
  66377. private getSimplifier;
  66378. }
  66379. /**
  66380. * The implemented types of simplification
  66381. * At the moment only Quadratic Error Decimation is implemented
  66382. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66383. */
  66384. export enum SimplificationType {
  66385. /** Quadratic error decimation */
  66386. QUADRATIC = 0
  66387. }
  66388. /**
  66389. * An implementation of the Quadratic Error simplification algorithm.
  66390. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  66391. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  66392. * @author RaananW
  66393. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66394. */
  66395. export class QuadraticErrorSimplification implements ISimplifier {
  66396. private _mesh;
  66397. private triangles;
  66398. private vertices;
  66399. private references;
  66400. private _reconstructedMesh;
  66401. /** Gets or sets the number pf sync interations */
  66402. syncIterations: number;
  66403. /** Gets or sets the aggressiveness of the simplifier */
  66404. aggressiveness: number;
  66405. /** Gets or sets the number of allowed iterations for decimation */
  66406. decimationIterations: number;
  66407. /** Gets or sets the espilon to use for bounding box computation */
  66408. boundingBoxEpsilon: number;
  66409. /**
  66410. * Creates a new QuadraticErrorSimplification
  66411. * @param _mesh defines the target mesh
  66412. */
  66413. constructor(_mesh: Mesh);
  66414. /**
  66415. * Simplification of a given mesh according to the given settings.
  66416. * Since this requires computation, it is assumed that the function runs async.
  66417. * @param settings The settings of the simplification, including quality and distance
  66418. * @param successCallback A callback that will be called after the mesh was simplified.
  66419. */
  66420. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  66421. private runDecimation;
  66422. private initWithMesh;
  66423. private init;
  66424. private reconstructMesh;
  66425. private initDecimatedMesh;
  66426. private isFlipped;
  66427. private updateTriangles;
  66428. private identifyBorder;
  66429. private updateMesh;
  66430. private vertexError;
  66431. private calculateError;
  66432. }
  66433. }
  66434. declare module BABYLON {
  66435. interface Scene {
  66436. /** @hidden (Backing field) */
  66437. _simplificationQueue: SimplificationQueue;
  66438. /**
  66439. * Gets or sets the simplification queue attached to the scene
  66440. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66441. */
  66442. simplificationQueue: SimplificationQueue;
  66443. }
  66444. interface Mesh {
  66445. /**
  66446. * Simplify the mesh according to the given array of settings.
  66447. * Function will return immediately and will simplify async
  66448. * @param settings a collection of simplification settings
  66449. * @param parallelProcessing should all levels calculate parallel or one after the other
  66450. * @param simplificationType the type of simplification to run
  66451. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  66452. * @returns the current mesh
  66453. */
  66454. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  66455. }
  66456. /**
  66457. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  66458. * created in a scene
  66459. */
  66460. export class SimplicationQueueSceneComponent implements ISceneComponent {
  66461. /**
  66462. * The component name helpfull to identify the component in the list of scene components.
  66463. */
  66464. readonly name: string;
  66465. /**
  66466. * The scene the component belongs to.
  66467. */
  66468. scene: Scene;
  66469. /**
  66470. * Creates a new instance of the component for the given scene
  66471. * @param scene Defines the scene to register the component in
  66472. */
  66473. constructor(scene: Scene);
  66474. /**
  66475. * Registers the component in a given scene
  66476. */
  66477. register(): void;
  66478. /**
  66479. * Rebuilds the elements related to this component in case of
  66480. * context lost for instance.
  66481. */
  66482. rebuild(): void;
  66483. /**
  66484. * Disposes the component and the associated ressources
  66485. */
  66486. dispose(): void;
  66487. private _beforeCameraUpdate;
  66488. }
  66489. }
  66490. declare module BABYLON {
  66491. interface Mesh {
  66492. /**
  66493. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  66494. */
  66495. thinInstanceEnablePicking: boolean;
  66496. /**
  66497. * Creates a new thin instance
  66498. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  66499. * @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
  66500. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  66501. */
  66502. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  66503. /**
  66504. * Adds the transformation (matrix) of the current mesh as a thin instance
  66505. * @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
  66506. * @returns the thin instance index number
  66507. */
  66508. thinInstanceAddSelf(refresh: boolean): number;
  66509. /**
  66510. * Registers a custom attribute to be used with thin instances
  66511. * @param kind name of the attribute
  66512. * @param stride size in floats of the attribute
  66513. */
  66514. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  66515. /**
  66516. * Sets the matrix of a thin instance
  66517. * @param index index of the thin instance
  66518. * @param matrix matrix to set
  66519. * @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
  66520. */
  66521. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  66522. /**
  66523. * Sets the value of a custom attribute for a thin instance
  66524. * @param kind name of the attribute
  66525. * @param index index of the thin instance
  66526. * @param value value to set
  66527. * @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
  66528. */
  66529. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  66530. /**
  66531. * 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.
  66532. */
  66533. thinInstanceCount: number;
  66534. /**
  66535. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  66536. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  66537. * @param buffer buffer to set
  66538. * @param stride size in floats of each value of the buffer
  66539. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  66540. */
  66541. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  66542. /**
  66543. * Gets the list of world matrices
  66544. * @return an array containing all the world matrices from the thin instances
  66545. */
  66546. thinInstanceGetWorldMatrices(): Matrix[];
  66547. /**
  66548. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  66549. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66550. */
  66551. thinInstanceBufferUpdated(kind: string): void;
  66552. /**
  66553. * Refreshes the bounding info, taking into account all the thin instances defined
  66554. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  66555. */
  66556. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  66557. /** @hidden */
  66558. _thinInstanceInitializeUserStorage(): void;
  66559. /** @hidden */
  66560. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  66561. /** @hidden */
  66562. _userThinInstanceBuffersStorage: {
  66563. data: {
  66564. [key: string]: Float32Array;
  66565. };
  66566. sizes: {
  66567. [key: string]: number;
  66568. };
  66569. vertexBuffers: {
  66570. [key: string]: Nullable<VertexBuffer>;
  66571. };
  66572. strides: {
  66573. [key: string]: number;
  66574. };
  66575. };
  66576. }
  66577. }
  66578. declare module BABYLON {
  66579. /**
  66580. * Navigation plugin interface to add navigation constrained by a navigation mesh
  66581. */
  66582. export interface INavigationEnginePlugin {
  66583. /**
  66584. * plugin name
  66585. */
  66586. name: string;
  66587. /**
  66588. * Creates a navigation mesh
  66589. * @param meshes array of all the geometry used to compute the navigatio mesh
  66590. * @param parameters bunch of parameters used to filter geometry
  66591. */
  66592. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66593. /**
  66594. * Create a navigation mesh debug mesh
  66595. * @param scene is where the mesh will be added
  66596. * @returns debug display mesh
  66597. */
  66598. createDebugNavMesh(scene: Scene): Mesh;
  66599. /**
  66600. * Get a navigation mesh constrained position, closest to the parameter position
  66601. * @param position world position
  66602. * @returns the closest point to position constrained by the navigation mesh
  66603. */
  66604. getClosestPoint(position: Vector3): Vector3;
  66605. /**
  66606. * Get a navigation mesh constrained position, closest to the parameter position
  66607. * @param position world position
  66608. * @param result output the closest point to position constrained by the navigation mesh
  66609. */
  66610. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66611. /**
  66612. * Get a navigation mesh constrained position, within a particular radius
  66613. * @param position world position
  66614. * @param maxRadius the maximum distance to the constrained world position
  66615. * @returns the closest point to position constrained by the navigation mesh
  66616. */
  66617. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66618. /**
  66619. * Get a navigation mesh constrained position, within a particular radius
  66620. * @param position world position
  66621. * @param maxRadius the maximum distance to the constrained world position
  66622. * @param result output the closest point to position constrained by the navigation mesh
  66623. */
  66624. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66625. /**
  66626. * Compute the final position from a segment made of destination-position
  66627. * @param position world position
  66628. * @param destination world position
  66629. * @returns the resulting point along the navmesh
  66630. */
  66631. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66632. /**
  66633. * Compute the final position from a segment made of destination-position
  66634. * @param position world position
  66635. * @param destination world position
  66636. * @param result output the resulting point along the navmesh
  66637. */
  66638. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66639. /**
  66640. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66641. * @param start world position
  66642. * @param end world position
  66643. * @returns array containing world position composing the path
  66644. */
  66645. computePath(start: Vector3, end: Vector3): Vector3[];
  66646. /**
  66647. * If this plugin is supported
  66648. * @returns true if plugin is supported
  66649. */
  66650. isSupported(): boolean;
  66651. /**
  66652. * Create a new Crowd so you can add agents
  66653. * @param maxAgents the maximum agent count in the crowd
  66654. * @param maxAgentRadius the maximum radius an agent can have
  66655. * @param scene to attach the crowd to
  66656. * @returns the crowd you can add agents to
  66657. */
  66658. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66659. /**
  66660. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66661. * The queries will try to find a solution within those bounds
  66662. * default is (1,1,1)
  66663. * @param extent x,y,z value that define the extent around the queries point of reference
  66664. */
  66665. setDefaultQueryExtent(extent: Vector3): void;
  66666. /**
  66667. * Get the Bounding box extent specified by setDefaultQueryExtent
  66668. * @returns the box extent values
  66669. */
  66670. getDefaultQueryExtent(): Vector3;
  66671. /**
  66672. * build the navmesh from a previously saved state using getNavmeshData
  66673. * @param data the Uint8Array returned by getNavmeshData
  66674. */
  66675. buildFromNavmeshData(data: Uint8Array): void;
  66676. /**
  66677. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66678. * @returns data the Uint8Array that can be saved and reused
  66679. */
  66680. getNavmeshData(): Uint8Array;
  66681. /**
  66682. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66683. * @param result output the box extent values
  66684. */
  66685. getDefaultQueryExtentToRef(result: Vector3): void;
  66686. /**
  66687. * Release all resources
  66688. */
  66689. dispose(): void;
  66690. }
  66691. /**
  66692. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  66693. */
  66694. export interface ICrowd {
  66695. /**
  66696. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66697. * You can attach anything to that node. The node position is updated in the scene update tick.
  66698. * @param pos world position that will be constrained by the navigation mesh
  66699. * @param parameters agent parameters
  66700. * @param transform hooked to the agent that will be update by the scene
  66701. * @returns agent index
  66702. */
  66703. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66704. /**
  66705. * Returns the agent position in world space
  66706. * @param index agent index returned by addAgent
  66707. * @returns world space position
  66708. */
  66709. getAgentPosition(index: number): Vector3;
  66710. /**
  66711. * Gets the agent position result in world space
  66712. * @param index agent index returned by addAgent
  66713. * @param result output world space position
  66714. */
  66715. getAgentPositionToRef(index: number, result: Vector3): void;
  66716. /**
  66717. * Gets the agent velocity in world space
  66718. * @param index agent index returned by addAgent
  66719. * @returns world space velocity
  66720. */
  66721. getAgentVelocity(index: number): Vector3;
  66722. /**
  66723. * Gets the agent velocity result in world space
  66724. * @param index agent index returned by addAgent
  66725. * @param result output world space velocity
  66726. */
  66727. getAgentVelocityToRef(index: number, result: Vector3): void;
  66728. /**
  66729. * remove a particular agent previously created
  66730. * @param index agent index returned by addAgent
  66731. */
  66732. removeAgent(index: number): void;
  66733. /**
  66734. * get the list of all agents attached to this crowd
  66735. * @returns list of agent indices
  66736. */
  66737. getAgents(): number[];
  66738. /**
  66739. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66740. * @param deltaTime in seconds
  66741. */
  66742. update(deltaTime: number): void;
  66743. /**
  66744. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66745. * @param index agent index returned by addAgent
  66746. * @param destination targeted world position
  66747. */
  66748. agentGoto(index: number, destination: Vector3): void;
  66749. /**
  66750. * Teleport the agent to a new position
  66751. * @param index agent index returned by addAgent
  66752. * @param destination targeted world position
  66753. */
  66754. agentTeleport(index: number, destination: Vector3): void;
  66755. /**
  66756. * Update agent parameters
  66757. * @param index agent index returned by addAgent
  66758. * @param parameters agent parameters
  66759. */
  66760. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66761. /**
  66762. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66763. * The queries will try to find a solution within those bounds
  66764. * default is (1,1,1)
  66765. * @param extent x,y,z value that define the extent around the queries point of reference
  66766. */
  66767. setDefaultQueryExtent(extent: Vector3): void;
  66768. /**
  66769. * Get the Bounding box extent specified by setDefaultQueryExtent
  66770. * @returns the box extent values
  66771. */
  66772. getDefaultQueryExtent(): Vector3;
  66773. /**
  66774. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66775. * @param result output the box extent values
  66776. */
  66777. getDefaultQueryExtentToRef(result: Vector3): void;
  66778. /**
  66779. * Release all resources
  66780. */
  66781. dispose(): void;
  66782. }
  66783. /**
  66784. * Configures an agent
  66785. */
  66786. export interface IAgentParameters {
  66787. /**
  66788. * Agent radius. [Limit: >= 0]
  66789. */
  66790. radius: number;
  66791. /**
  66792. * Agent height. [Limit: > 0]
  66793. */
  66794. height: number;
  66795. /**
  66796. * Maximum allowed acceleration. [Limit: >= 0]
  66797. */
  66798. maxAcceleration: number;
  66799. /**
  66800. * Maximum allowed speed. [Limit: >= 0]
  66801. */
  66802. maxSpeed: number;
  66803. /**
  66804. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  66805. */
  66806. collisionQueryRange: number;
  66807. /**
  66808. * The path visibility optimization range. [Limit: > 0]
  66809. */
  66810. pathOptimizationRange: number;
  66811. /**
  66812. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  66813. */
  66814. separationWeight: number;
  66815. }
  66816. /**
  66817. * Configures the navigation mesh creation
  66818. */
  66819. export interface INavMeshParameters {
  66820. /**
  66821. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  66822. */
  66823. cs: number;
  66824. /**
  66825. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  66826. */
  66827. ch: number;
  66828. /**
  66829. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  66830. */
  66831. walkableSlopeAngle: number;
  66832. /**
  66833. * Minimum floor to 'ceiling' height that will still allow the floor area to
  66834. * be considered walkable. [Limit: >= 3] [Units: vx]
  66835. */
  66836. walkableHeight: number;
  66837. /**
  66838. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  66839. */
  66840. walkableClimb: number;
  66841. /**
  66842. * The distance to erode/shrink the walkable area of the heightfield away from
  66843. * obstructions. [Limit: >=0] [Units: vx]
  66844. */
  66845. walkableRadius: number;
  66846. /**
  66847. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  66848. */
  66849. maxEdgeLen: number;
  66850. /**
  66851. * The maximum distance a simplfied contour's border edges should deviate
  66852. * the original raw contour. [Limit: >=0] [Units: vx]
  66853. */
  66854. maxSimplificationError: number;
  66855. /**
  66856. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  66857. */
  66858. minRegionArea: number;
  66859. /**
  66860. * Any regions with a span count smaller than this value will, if possible,
  66861. * be merged with larger regions. [Limit: >=0] [Units: vx]
  66862. */
  66863. mergeRegionArea: number;
  66864. /**
  66865. * The maximum number of vertices allowed for polygons generated during the
  66866. * contour to polygon conversion process. [Limit: >= 3]
  66867. */
  66868. maxVertsPerPoly: number;
  66869. /**
  66870. * Sets the sampling distance to use when generating the detail mesh.
  66871. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  66872. */
  66873. detailSampleDist: number;
  66874. /**
  66875. * The maximum distance the detail mesh surface should deviate from heightfield
  66876. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  66877. */
  66878. detailSampleMaxError: number;
  66879. }
  66880. }
  66881. declare module BABYLON {
  66882. /**
  66883. * RecastJS navigation plugin
  66884. */
  66885. export class RecastJSPlugin implements INavigationEnginePlugin {
  66886. /**
  66887. * Reference to the Recast library
  66888. */
  66889. bjsRECAST: any;
  66890. /**
  66891. * plugin name
  66892. */
  66893. name: string;
  66894. /**
  66895. * the first navmesh created. We might extend this to support multiple navmeshes
  66896. */
  66897. navMesh: any;
  66898. /**
  66899. * Initializes the recastJS plugin
  66900. * @param recastInjection can be used to inject your own recast reference
  66901. */
  66902. constructor(recastInjection?: any);
  66903. /**
  66904. * Creates a navigation mesh
  66905. * @param meshes array of all the geometry used to compute the navigatio mesh
  66906. * @param parameters bunch of parameters used to filter geometry
  66907. */
  66908. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66909. /**
  66910. * Create a navigation mesh debug mesh
  66911. * @param scene is where the mesh will be added
  66912. * @returns debug display mesh
  66913. */
  66914. createDebugNavMesh(scene: Scene): Mesh;
  66915. /**
  66916. * Get a navigation mesh constrained position, closest to the parameter position
  66917. * @param position world position
  66918. * @returns the closest point to position constrained by the navigation mesh
  66919. */
  66920. getClosestPoint(position: Vector3): Vector3;
  66921. /**
  66922. * Get a navigation mesh constrained position, closest to the parameter position
  66923. * @param position world position
  66924. * @param result output the closest point to position constrained by the navigation mesh
  66925. */
  66926. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66927. /**
  66928. * Get a navigation mesh constrained position, within a particular radius
  66929. * @param position world position
  66930. * @param maxRadius the maximum distance to the constrained world position
  66931. * @returns the closest point to position constrained by the navigation mesh
  66932. */
  66933. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66934. /**
  66935. * Get a navigation mesh constrained position, within a particular radius
  66936. * @param position world position
  66937. * @param maxRadius the maximum distance to the constrained world position
  66938. * @param result output the closest point to position constrained by the navigation mesh
  66939. */
  66940. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66941. /**
  66942. * Compute the final position from a segment made of destination-position
  66943. * @param position world position
  66944. * @param destination world position
  66945. * @returns the resulting point along the navmesh
  66946. */
  66947. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66948. /**
  66949. * Compute the final position from a segment made of destination-position
  66950. * @param position world position
  66951. * @param destination world position
  66952. * @param result output the resulting point along the navmesh
  66953. */
  66954. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66955. /**
  66956. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66957. * @param start world position
  66958. * @param end world position
  66959. * @returns array containing world position composing the path
  66960. */
  66961. computePath(start: Vector3, end: Vector3): Vector3[];
  66962. /**
  66963. * Create a new Crowd so you can add agents
  66964. * @param maxAgents the maximum agent count in the crowd
  66965. * @param maxAgentRadius the maximum radius an agent can have
  66966. * @param scene to attach the crowd to
  66967. * @returns the crowd you can add agents to
  66968. */
  66969. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66970. /**
  66971. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66972. * The queries will try to find a solution within those bounds
  66973. * default is (1,1,1)
  66974. * @param extent x,y,z value that define the extent around the queries point of reference
  66975. */
  66976. setDefaultQueryExtent(extent: Vector3): void;
  66977. /**
  66978. * Get the Bounding box extent specified by setDefaultQueryExtent
  66979. * @returns the box extent values
  66980. */
  66981. getDefaultQueryExtent(): Vector3;
  66982. /**
  66983. * build the navmesh from a previously saved state using getNavmeshData
  66984. * @param data the Uint8Array returned by getNavmeshData
  66985. */
  66986. buildFromNavmeshData(data: Uint8Array): void;
  66987. /**
  66988. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66989. * @returns data the Uint8Array that can be saved and reused
  66990. */
  66991. getNavmeshData(): Uint8Array;
  66992. /**
  66993. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66994. * @param result output the box extent values
  66995. */
  66996. getDefaultQueryExtentToRef(result: Vector3): void;
  66997. /**
  66998. * Disposes
  66999. */
  67000. dispose(): void;
  67001. /**
  67002. * If this plugin is supported
  67003. * @returns true if plugin is supported
  67004. */
  67005. isSupported(): boolean;
  67006. }
  67007. /**
  67008. * Recast detour crowd implementation
  67009. */
  67010. export class RecastJSCrowd implements ICrowd {
  67011. /**
  67012. * Recast/detour plugin
  67013. */
  67014. bjsRECASTPlugin: RecastJSPlugin;
  67015. /**
  67016. * Link to the detour crowd
  67017. */
  67018. recastCrowd: any;
  67019. /**
  67020. * One transform per agent
  67021. */
  67022. transforms: TransformNode[];
  67023. /**
  67024. * All agents created
  67025. */
  67026. agents: number[];
  67027. /**
  67028. * Link to the scene is kept to unregister the crowd from the scene
  67029. */
  67030. private _scene;
  67031. /**
  67032. * Observer for crowd updates
  67033. */
  67034. private _onBeforeAnimationsObserver;
  67035. /**
  67036. * Constructor
  67037. * @param plugin recastJS plugin
  67038. * @param maxAgents the maximum agent count in the crowd
  67039. * @param maxAgentRadius the maximum radius an agent can have
  67040. * @param scene to attach the crowd to
  67041. * @returns the crowd you can add agents to
  67042. */
  67043. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  67044. /**
  67045. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67046. * You can attach anything to that node. The node position is updated in the scene update tick.
  67047. * @param pos world position that will be constrained by the navigation mesh
  67048. * @param parameters agent parameters
  67049. * @param transform hooked to the agent that will be update by the scene
  67050. * @returns agent index
  67051. */
  67052. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67053. /**
  67054. * Returns the agent position in world space
  67055. * @param index agent index returned by addAgent
  67056. * @returns world space position
  67057. */
  67058. getAgentPosition(index: number): Vector3;
  67059. /**
  67060. * Returns the agent position result in world space
  67061. * @param index agent index returned by addAgent
  67062. * @param result output world space position
  67063. */
  67064. getAgentPositionToRef(index: number, result: Vector3): void;
  67065. /**
  67066. * Returns the agent velocity in world space
  67067. * @param index agent index returned by addAgent
  67068. * @returns world space velocity
  67069. */
  67070. getAgentVelocity(index: number): Vector3;
  67071. /**
  67072. * Returns the agent velocity result in world space
  67073. * @param index agent index returned by addAgent
  67074. * @param result output world space velocity
  67075. */
  67076. getAgentVelocityToRef(index: number, result: Vector3): void;
  67077. /**
  67078. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67079. * @param index agent index returned by addAgent
  67080. * @param destination targeted world position
  67081. */
  67082. agentGoto(index: number, destination: Vector3): void;
  67083. /**
  67084. * Teleport the agent to a new position
  67085. * @param index agent index returned by addAgent
  67086. * @param destination targeted world position
  67087. */
  67088. agentTeleport(index: number, destination: Vector3): void;
  67089. /**
  67090. * Update agent parameters
  67091. * @param index agent index returned by addAgent
  67092. * @param parameters agent parameters
  67093. */
  67094. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67095. /**
  67096. * remove a particular agent previously created
  67097. * @param index agent index returned by addAgent
  67098. */
  67099. removeAgent(index: number): void;
  67100. /**
  67101. * get the list of all agents attached to this crowd
  67102. * @returns list of agent indices
  67103. */
  67104. getAgents(): number[];
  67105. /**
  67106. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67107. * @param deltaTime in seconds
  67108. */
  67109. update(deltaTime: number): void;
  67110. /**
  67111. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67112. * The queries will try to find a solution within those bounds
  67113. * default is (1,1,1)
  67114. * @param extent x,y,z value that define the extent around the queries point of reference
  67115. */
  67116. setDefaultQueryExtent(extent: Vector3): void;
  67117. /**
  67118. * Get the Bounding box extent specified by setDefaultQueryExtent
  67119. * @returns the box extent values
  67120. */
  67121. getDefaultQueryExtent(): Vector3;
  67122. /**
  67123. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67124. * @param result output the box extent values
  67125. */
  67126. getDefaultQueryExtentToRef(result: Vector3): void;
  67127. /**
  67128. * Release all resources
  67129. */
  67130. dispose(): void;
  67131. }
  67132. }
  67133. declare module BABYLON {
  67134. /**
  67135. * Class used to enable access to IndexedDB
  67136. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67137. */
  67138. export class Database implements IOfflineProvider {
  67139. private _callbackManifestChecked;
  67140. private _currentSceneUrl;
  67141. private _db;
  67142. private _enableSceneOffline;
  67143. private _enableTexturesOffline;
  67144. private _manifestVersionFound;
  67145. private _mustUpdateRessources;
  67146. private _hasReachedQuota;
  67147. private _isSupported;
  67148. private _idbFactory;
  67149. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  67150. private static IsUASupportingBlobStorage;
  67151. /**
  67152. * Gets a boolean indicating if Database storate is enabled (off by default)
  67153. */
  67154. static IDBStorageEnabled: boolean;
  67155. /**
  67156. * Gets a boolean indicating if scene must be saved in the database
  67157. */
  67158. get enableSceneOffline(): boolean;
  67159. /**
  67160. * Gets a boolean indicating if textures must be saved in the database
  67161. */
  67162. get enableTexturesOffline(): boolean;
  67163. /**
  67164. * Creates a new Database
  67165. * @param urlToScene defines the url to load the scene
  67166. * @param callbackManifestChecked defines the callback to use when manifest is checked
  67167. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  67168. */
  67169. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  67170. private static _ParseURL;
  67171. private static _ReturnFullUrlLocation;
  67172. private _checkManifestFile;
  67173. /**
  67174. * Open the database and make it available
  67175. * @param successCallback defines the callback to call on success
  67176. * @param errorCallback defines the callback to call on error
  67177. */
  67178. open(successCallback: () => void, errorCallback: () => void): void;
  67179. /**
  67180. * Loads an image from the database
  67181. * @param url defines the url to load from
  67182. * @param image defines the target DOM image
  67183. */
  67184. loadImage(url: string, image: HTMLImageElement): void;
  67185. private _loadImageFromDBAsync;
  67186. private _saveImageIntoDBAsync;
  67187. private _checkVersionFromDB;
  67188. private _loadVersionFromDBAsync;
  67189. private _saveVersionIntoDBAsync;
  67190. /**
  67191. * Loads a file from database
  67192. * @param url defines the URL to load from
  67193. * @param sceneLoaded defines a callback to call on success
  67194. * @param progressCallBack defines a callback to call when progress changed
  67195. * @param errorCallback defines a callback to call on error
  67196. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  67197. */
  67198. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  67199. private _loadFileAsync;
  67200. private _saveFileAsync;
  67201. /**
  67202. * Validates if xhr data is correct
  67203. * @param xhr defines the request to validate
  67204. * @param dataType defines the expected data type
  67205. * @returns true if data is correct
  67206. */
  67207. private static _ValidateXHRData;
  67208. }
  67209. }
  67210. declare module BABYLON {
  67211. /** @hidden */
  67212. export var gpuUpdateParticlesPixelShader: {
  67213. name: string;
  67214. shader: string;
  67215. };
  67216. }
  67217. declare module BABYLON {
  67218. /** @hidden */
  67219. export var gpuUpdateParticlesVertexShader: {
  67220. name: string;
  67221. shader: string;
  67222. };
  67223. }
  67224. declare module BABYLON {
  67225. /** @hidden */
  67226. export var clipPlaneFragmentDeclaration2: {
  67227. name: string;
  67228. shader: string;
  67229. };
  67230. }
  67231. declare module BABYLON {
  67232. /** @hidden */
  67233. export var gpuRenderParticlesPixelShader: {
  67234. name: string;
  67235. shader: string;
  67236. };
  67237. }
  67238. declare module BABYLON {
  67239. /** @hidden */
  67240. export var clipPlaneVertexDeclaration2: {
  67241. name: string;
  67242. shader: string;
  67243. };
  67244. }
  67245. declare module BABYLON {
  67246. /** @hidden */
  67247. export var gpuRenderParticlesVertexShader: {
  67248. name: string;
  67249. shader: string;
  67250. };
  67251. }
  67252. declare module BABYLON {
  67253. /**
  67254. * This represents a GPU particle system in Babylon
  67255. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  67256. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  67257. */
  67258. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  67259. /**
  67260. * The layer mask we are rendering the particles through.
  67261. */
  67262. layerMask: number;
  67263. private _capacity;
  67264. private _activeCount;
  67265. private _currentActiveCount;
  67266. private _accumulatedCount;
  67267. private _renderEffect;
  67268. private _updateEffect;
  67269. private _buffer0;
  67270. private _buffer1;
  67271. private _spriteBuffer;
  67272. private _updateVAO;
  67273. private _renderVAO;
  67274. private _targetIndex;
  67275. private _sourceBuffer;
  67276. private _targetBuffer;
  67277. private _currentRenderId;
  67278. private _started;
  67279. private _stopped;
  67280. private _timeDelta;
  67281. private _randomTexture;
  67282. private _randomTexture2;
  67283. private _attributesStrideSize;
  67284. private _updateEffectOptions;
  67285. private _randomTextureSize;
  67286. private _actualFrame;
  67287. private _customEffect;
  67288. private readonly _rawTextureWidth;
  67289. /**
  67290. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  67291. */
  67292. static get IsSupported(): boolean;
  67293. /**
  67294. * An event triggered when the system is disposed.
  67295. */
  67296. onDisposeObservable: Observable<IParticleSystem>;
  67297. /**
  67298. * Gets the maximum number of particles active at the same time.
  67299. * @returns The max number of active particles.
  67300. */
  67301. getCapacity(): number;
  67302. /**
  67303. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  67304. * to override the particles.
  67305. */
  67306. forceDepthWrite: boolean;
  67307. /**
  67308. * Gets or set the number of active particles
  67309. */
  67310. get activeParticleCount(): number;
  67311. set activeParticleCount(value: number);
  67312. private _preWarmDone;
  67313. /**
  67314. * Specifies if the particles are updated in emitter local space or world space.
  67315. */
  67316. isLocal: boolean;
  67317. /** Gets or sets a matrix to use to compute projection */
  67318. defaultProjectionMatrix: Matrix;
  67319. /**
  67320. * Is this system ready to be used/rendered
  67321. * @return true if the system is ready
  67322. */
  67323. isReady(): boolean;
  67324. /**
  67325. * Gets if the system has been started. (Note: this will still be true after stop is called)
  67326. * @returns True if it has been started, otherwise false.
  67327. */
  67328. isStarted(): boolean;
  67329. /**
  67330. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  67331. * @returns True if it has been stopped, otherwise false.
  67332. */
  67333. isStopped(): boolean;
  67334. /**
  67335. * Gets a boolean indicating that the system is stopping
  67336. * @returns true if the system is currently stopping
  67337. */
  67338. isStopping(): boolean;
  67339. /**
  67340. * Gets the number of particles active at the same time.
  67341. * @returns The number of active particles.
  67342. */
  67343. getActiveCount(): number;
  67344. /**
  67345. * Starts the particle system and begins to emit
  67346. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  67347. */
  67348. start(delay?: number): void;
  67349. /**
  67350. * Stops the particle system.
  67351. */
  67352. stop(): void;
  67353. /**
  67354. * Remove all active particles
  67355. */
  67356. reset(): void;
  67357. /**
  67358. * Returns the string "GPUParticleSystem"
  67359. * @returns a string containing the class name
  67360. */
  67361. getClassName(): string;
  67362. /**
  67363. * Gets the custom effect used to render the particles
  67364. * @param blendMode Blend mode for which the effect should be retrieved
  67365. * @returns The effect
  67366. */
  67367. getCustomEffect(blendMode?: number): Nullable<Effect>;
  67368. /**
  67369. * Sets the custom effect used to render the particles
  67370. * @param effect The effect to set
  67371. * @param blendMode Blend mode for which the effect should be set
  67372. */
  67373. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  67374. /** @hidden */
  67375. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  67376. /**
  67377. * Observable that will be called just before the particles are drawn
  67378. */
  67379. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  67380. /**
  67381. * Gets the name of the particle vertex shader
  67382. */
  67383. get vertexShaderName(): string;
  67384. private _colorGradientsTexture;
  67385. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  67386. /**
  67387. * Adds a new color gradient
  67388. * @param gradient defines the gradient to use (between 0 and 1)
  67389. * @param color1 defines the color to affect to the specified gradient
  67390. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  67391. * @returns the current particle system
  67392. */
  67393. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  67394. private _refreshColorGradient;
  67395. /** Force the system to rebuild all gradients that need to be resync */
  67396. forceRefreshGradients(): void;
  67397. /**
  67398. * Remove a specific color gradient
  67399. * @param gradient defines the gradient to remove
  67400. * @returns the current particle system
  67401. */
  67402. removeColorGradient(gradient: number): GPUParticleSystem;
  67403. private _angularSpeedGradientsTexture;
  67404. private _sizeGradientsTexture;
  67405. private _velocityGradientsTexture;
  67406. private _limitVelocityGradientsTexture;
  67407. private _dragGradientsTexture;
  67408. private _addFactorGradient;
  67409. /**
  67410. * Adds a new size gradient
  67411. * @param gradient defines the gradient to use (between 0 and 1)
  67412. * @param factor defines the size factor to affect to the specified gradient
  67413. * @returns the current particle system
  67414. */
  67415. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  67416. /**
  67417. * Remove a specific size gradient
  67418. * @param gradient defines the gradient to remove
  67419. * @returns the current particle system
  67420. */
  67421. removeSizeGradient(gradient: number): GPUParticleSystem;
  67422. private _refreshFactorGradient;
  67423. /**
  67424. * Adds a new angular speed gradient
  67425. * @param gradient defines the gradient to use (between 0 and 1)
  67426. * @param factor defines the angular speed to affect to the specified gradient
  67427. * @returns the current particle system
  67428. */
  67429. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  67430. /**
  67431. * Remove a specific angular speed gradient
  67432. * @param gradient defines the gradient to remove
  67433. * @returns the current particle system
  67434. */
  67435. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  67436. /**
  67437. * Adds a new velocity gradient
  67438. * @param gradient defines the gradient to use (between 0 and 1)
  67439. * @param factor defines the velocity to affect to the specified gradient
  67440. * @returns the current particle system
  67441. */
  67442. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67443. /**
  67444. * Remove a specific velocity gradient
  67445. * @param gradient defines the gradient to remove
  67446. * @returns the current particle system
  67447. */
  67448. removeVelocityGradient(gradient: number): GPUParticleSystem;
  67449. /**
  67450. * Adds a new limit velocity gradient
  67451. * @param gradient defines the gradient to use (between 0 and 1)
  67452. * @param factor defines the limit velocity value to affect to the specified gradient
  67453. * @returns the current particle system
  67454. */
  67455. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67456. /**
  67457. * Remove a specific limit velocity gradient
  67458. * @param gradient defines the gradient to remove
  67459. * @returns the current particle system
  67460. */
  67461. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  67462. /**
  67463. * Adds a new drag gradient
  67464. * @param gradient defines the gradient to use (between 0 and 1)
  67465. * @param factor defines the drag value to affect to the specified gradient
  67466. * @returns the current particle system
  67467. */
  67468. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  67469. /**
  67470. * Remove a specific drag gradient
  67471. * @param gradient defines the gradient to remove
  67472. * @returns the current particle system
  67473. */
  67474. removeDragGradient(gradient: number): GPUParticleSystem;
  67475. /**
  67476. * Not supported by GPUParticleSystem
  67477. * @param gradient defines the gradient to use (between 0 and 1)
  67478. * @param factor defines the emit rate value to affect to the specified gradient
  67479. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67480. * @returns the current particle system
  67481. */
  67482. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67483. /**
  67484. * Not supported by GPUParticleSystem
  67485. * @param gradient defines the gradient to remove
  67486. * @returns the current particle system
  67487. */
  67488. removeEmitRateGradient(gradient: number): IParticleSystem;
  67489. /**
  67490. * Not supported by GPUParticleSystem
  67491. * @param gradient defines the gradient to use (between 0 and 1)
  67492. * @param factor defines the start size value to affect to the specified gradient
  67493. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67494. * @returns the current particle system
  67495. */
  67496. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67497. /**
  67498. * Not supported by GPUParticleSystem
  67499. * @param gradient defines the gradient to remove
  67500. * @returns the current particle system
  67501. */
  67502. removeStartSizeGradient(gradient: number): IParticleSystem;
  67503. /**
  67504. * Not supported by GPUParticleSystem
  67505. * @param gradient defines the gradient to use (between 0 and 1)
  67506. * @param min defines the color remap minimal range
  67507. * @param max defines the color remap maximal range
  67508. * @returns the current particle system
  67509. */
  67510. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67511. /**
  67512. * Not supported by GPUParticleSystem
  67513. * @param gradient defines the gradient to remove
  67514. * @returns the current particle system
  67515. */
  67516. removeColorRemapGradient(): IParticleSystem;
  67517. /**
  67518. * Not supported by GPUParticleSystem
  67519. * @param gradient defines the gradient to use (between 0 and 1)
  67520. * @param min defines the alpha remap minimal range
  67521. * @param max defines the alpha remap maximal range
  67522. * @returns the current particle system
  67523. */
  67524. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67525. /**
  67526. * Not supported by GPUParticleSystem
  67527. * @param gradient defines the gradient to remove
  67528. * @returns the current particle system
  67529. */
  67530. removeAlphaRemapGradient(): IParticleSystem;
  67531. /**
  67532. * Not supported by GPUParticleSystem
  67533. * @param gradient defines the gradient to use (between 0 and 1)
  67534. * @param color defines the color to affect to the specified gradient
  67535. * @returns the current particle system
  67536. */
  67537. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  67538. /**
  67539. * Not supported by GPUParticleSystem
  67540. * @param gradient defines the gradient to remove
  67541. * @returns the current particle system
  67542. */
  67543. removeRampGradient(): IParticleSystem;
  67544. /**
  67545. * Not supported by GPUParticleSystem
  67546. * @returns the list of ramp gradients
  67547. */
  67548. getRampGradients(): Nullable<Array<Color3Gradient>>;
  67549. /**
  67550. * Not supported by GPUParticleSystem
  67551. * Gets or sets a boolean indicating that ramp gradients must be used
  67552. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  67553. */
  67554. get useRampGradients(): boolean;
  67555. set useRampGradients(value: boolean);
  67556. /**
  67557. * Not supported by GPUParticleSystem
  67558. * @param gradient defines the gradient to use (between 0 and 1)
  67559. * @param factor defines the life time factor to affect to the specified gradient
  67560. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67561. * @returns the current particle system
  67562. */
  67563. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67564. /**
  67565. * Not supported by GPUParticleSystem
  67566. * @param gradient defines the gradient to remove
  67567. * @returns the current particle system
  67568. */
  67569. removeLifeTimeGradient(gradient: number): IParticleSystem;
  67570. /**
  67571. * Instantiates a GPU particle system.
  67572. * 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.
  67573. * @param name The name of the particle system
  67574. * @param options The options used to create the system
  67575. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  67576. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  67577. * @param customEffect a custom effect used to change the way particles are rendered by default
  67578. */
  67579. constructor(name: string, options: Partial<{
  67580. capacity: number;
  67581. randomTextureSize: number;
  67582. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  67583. protected _reset(): void;
  67584. private _createUpdateVAO;
  67585. private _createRenderVAO;
  67586. private _initialize;
  67587. /** @hidden */
  67588. _recreateUpdateEffect(): void;
  67589. private _getEffect;
  67590. /**
  67591. * Fill the defines array according to the current settings of the particle system
  67592. * @param defines Array to be updated
  67593. * @param blendMode blend mode to take into account when updating the array
  67594. */
  67595. fillDefines(defines: Array<string>, blendMode?: number): void;
  67596. /**
  67597. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  67598. * @param uniforms Uniforms array to fill
  67599. * @param attributes Attributes array to fill
  67600. * @param samplers Samplers array to fill
  67601. */
  67602. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  67603. /** @hidden */
  67604. _recreateRenderEffect(): Effect;
  67605. /**
  67606. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  67607. * @param preWarm defines if we are in the pre-warmimg phase
  67608. */
  67609. animate(preWarm?: boolean): void;
  67610. private _createFactorGradientTexture;
  67611. private _createSizeGradientTexture;
  67612. private _createAngularSpeedGradientTexture;
  67613. private _createVelocityGradientTexture;
  67614. private _createLimitVelocityGradientTexture;
  67615. private _createDragGradientTexture;
  67616. private _createColorGradientTexture;
  67617. /**
  67618. * Renders the particle system in its current state
  67619. * @param preWarm defines if the system should only update the particles but not render them
  67620. * @returns the current number of particles
  67621. */
  67622. render(preWarm?: boolean): number;
  67623. /**
  67624. * Rebuilds the particle system
  67625. */
  67626. rebuild(): void;
  67627. private _releaseBuffers;
  67628. private _releaseVAOs;
  67629. /**
  67630. * Disposes the particle system and free the associated resources
  67631. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  67632. */
  67633. dispose(disposeTexture?: boolean): void;
  67634. /**
  67635. * Clones the particle system.
  67636. * @param name The name of the cloned object
  67637. * @param newEmitter The new emitter to use
  67638. * @returns the cloned particle system
  67639. */
  67640. clone(name: string, newEmitter: any): GPUParticleSystem;
  67641. /**
  67642. * Serializes the particle system to a JSON object
  67643. * @param serializeTexture defines if the texture must be serialized as well
  67644. * @returns the JSON object
  67645. */
  67646. serialize(serializeTexture?: boolean): any;
  67647. /**
  67648. * Parses a JSON object to create a GPU particle system.
  67649. * @param parsedParticleSystem The JSON object to parse
  67650. * @param sceneOrEngine The scene or the engine to create the particle system in
  67651. * @param rootUrl The root url to use to load external dependencies like texture
  67652. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  67653. * @returns the parsed GPU particle system
  67654. */
  67655. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  67656. }
  67657. }
  67658. declare module BABYLON {
  67659. /**
  67660. * Represents a set of particle systems working together to create a specific effect
  67661. */
  67662. export class ParticleSystemSet implements IDisposable {
  67663. /**
  67664. * Gets or sets base Assets URL
  67665. */
  67666. static BaseAssetsUrl: string;
  67667. private _emitterCreationOptions;
  67668. private _emitterNode;
  67669. /**
  67670. * Gets the particle system list
  67671. */
  67672. systems: IParticleSystem[];
  67673. /**
  67674. * Gets the emitter node used with this set
  67675. */
  67676. get emitterNode(): Nullable<TransformNode>;
  67677. /**
  67678. * Creates a new emitter mesh as a sphere
  67679. * @param options defines the options used to create the sphere
  67680. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  67681. * @param scene defines the hosting scene
  67682. */
  67683. setEmitterAsSphere(options: {
  67684. diameter: number;
  67685. segments: number;
  67686. color: Color3;
  67687. }, renderingGroupId: number, scene: Scene): void;
  67688. /**
  67689. * Starts all particle systems of the set
  67690. * @param emitter defines an optional mesh to use as emitter for the particle systems
  67691. */
  67692. start(emitter?: AbstractMesh): void;
  67693. /**
  67694. * Release all associated resources
  67695. */
  67696. dispose(): void;
  67697. /**
  67698. * Serialize the set into a JSON compatible object
  67699. * @param serializeTexture defines if the texture must be serialized as well
  67700. * @returns a JSON compatible representation of the set
  67701. */
  67702. serialize(serializeTexture?: boolean): any;
  67703. /**
  67704. * Parse a new ParticleSystemSet from a serialized source
  67705. * @param data defines a JSON compatible representation of the set
  67706. * @param scene defines the hosting scene
  67707. * @param gpu defines if we want GPU particles or CPU particles
  67708. * @returns a new ParticleSystemSet
  67709. */
  67710. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  67711. }
  67712. }
  67713. declare module BABYLON {
  67714. /**
  67715. * This class is made for on one-liner static method to help creating particle system set.
  67716. */
  67717. export class ParticleHelper {
  67718. /**
  67719. * Gets or sets base Assets URL
  67720. */
  67721. static BaseAssetsUrl: string;
  67722. /** Define the Url to load snippets */
  67723. static SnippetUrl: string;
  67724. /**
  67725. * Create a default particle system that you can tweak
  67726. * @param emitter defines the emitter to use
  67727. * @param capacity defines the system capacity (default is 500 particles)
  67728. * @param scene defines the hosting scene
  67729. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  67730. * @returns the new Particle system
  67731. */
  67732. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  67733. /**
  67734. * This is the main static method (one-liner) of this helper to create different particle systems
  67735. * @param type This string represents the type to the particle system to create
  67736. * @param scene The scene where the particle system should live
  67737. * @param gpu If the system will use gpu
  67738. * @returns the ParticleSystemSet created
  67739. */
  67740. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  67741. /**
  67742. * Static function used to export a particle system to a ParticleSystemSet variable.
  67743. * Please note that the emitter shape is not exported
  67744. * @param systems defines the particle systems to export
  67745. * @returns the created particle system set
  67746. */
  67747. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  67748. /**
  67749. * Creates a particle system from a snippet saved in a remote file
  67750. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  67751. * @param url defines the url to load from
  67752. * @param scene defines the hosting scene
  67753. * @param gpu If the system will use gpu
  67754. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67755. * @returns a promise that will resolve to the new particle system
  67756. */
  67757. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67758. /**
  67759. * Creates a particle system from a snippet saved by the particle system editor
  67760. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  67761. * @param scene defines the hosting scene
  67762. * @param gpu If the system will use gpu
  67763. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67764. * @returns a promise that will resolve to the new particle system
  67765. */
  67766. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67767. }
  67768. }
  67769. declare module BABYLON {
  67770. interface Engine {
  67771. /**
  67772. * Create an effect to use with particle systems.
  67773. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  67774. * the particle system for which you want to create a custom effect in the last parameter
  67775. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  67776. * @param uniformsNames defines a list of attribute names
  67777. * @param samplers defines an array of string used to represent textures
  67778. * @param defines defines the string containing the defines to use to compile the shaders
  67779. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  67780. * @param onCompiled defines a function to call when the effect creation is successful
  67781. * @param onError defines a function to call when the effect creation has failed
  67782. * @param particleSystem the particle system you want to create the effect for
  67783. * @returns the new Effect
  67784. */
  67785. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  67786. }
  67787. interface Mesh {
  67788. /**
  67789. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  67790. * @returns an array of IParticleSystem
  67791. */
  67792. getEmittedParticleSystems(): IParticleSystem[];
  67793. /**
  67794. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  67795. * @returns an array of IParticleSystem
  67796. */
  67797. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  67798. }
  67799. }
  67800. declare module BABYLON {
  67801. /** Defines the 4 color options */
  67802. export enum PointColor {
  67803. /** color value */
  67804. Color = 2,
  67805. /** uv value */
  67806. UV = 1,
  67807. /** random value */
  67808. Random = 0,
  67809. /** stated value */
  67810. Stated = 3
  67811. }
  67812. /**
  67813. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  67814. * 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.
  67815. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  67816. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  67817. *
  67818. * Full documentation here : TO BE ENTERED
  67819. */
  67820. export class PointsCloudSystem implements IDisposable {
  67821. /**
  67822. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  67823. * Example : var p = SPS.particles[i];
  67824. */
  67825. particles: CloudPoint[];
  67826. /**
  67827. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  67828. */
  67829. nbParticles: number;
  67830. /**
  67831. * This a counter for your own usage. It's not set by any SPS functions.
  67832. */
  67833. counter: number;
  67834. /**
  67835. * The PCS name. This name is also given to the underlying mesh.
  67836. */
  67837. name: string;
  67838. /**
  67839. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  67840. */
  67841. mesh: Mesh;
  67842. /**
  67843. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  67844. * Please read :
  67845. */
  67846. vars: any;
  67847. /**
  67848. * @hidden
  67849. */
  67850. _size: number;
  67851. private _scene;
  67852. private _promises;
  67853. private _positions;
  67854. private _indices;
  67855. private _normals;
  67856. private _colors;
  67857. private _uvs;
  67858. private _indices32;
  67859. private _positions32;
  67860. private _colors32;
  67861. private _uvs32;
  67862. private _updatable;
  67863. private _isVisibilityBoxLocked;
  67864. private _alwaysVisible;
  67865. private _groups;
  67866. private _groupCounter;
  67867. private _computeParticleColor;
  67868. private _computeParticleTexture;
  67869. private _computeParticleRotation;
  67870. private _computeBoundingBox;
  67871. private _isReady;
  67872. /**
  67873. * Creates a PCS (Points Cloud System) object
  67874. * @param name (String) is the PCS name, this will be the underlying mesh name
  67875. * @param pointSize (number) is the size for each point
  67876. * @param scene (Scene) is the scene in which the PCS is added
  67877. * @param options defines the options of the PCS e.g.
  67878. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  67879. */
  67880. constructor(name: string, pointSize: number, scene: Scene, options?: {
  67881. updatable?: boolean;
  67882. });
  67883. /**
  67884. * Builds the PCS underlying mesh. Returns a standard Mesh.
  67885. * If no points were added to the PCS, the returned mesh is just a single point.
  67886. * @returns a promise for the created mesh
  67887. */
  67888. buildMeshAsync(): Promise<Mesh>;
  67889. /**
  67890. * @hidden
  67891. */
  67892. private _buildMesh;
  67893. private _addParticle;
  67894. private _randomUnitVector;
  67895. private _getColorIndicesForCoord;
  67896. private _setPointsColorOrUV;
  67897. private _colorFromTexture;
  67898. private _calculateDensity;
  67899. /**
  67900. * Adds points to the PCS in random positions within a unit sphere
  67901. * @param nb (positive integer) the number of particles to be created from this model
  67902. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  67903. * @returns the number of groups in the system
  67904. */
  67905. addPoints(nb: number, pointFunction?: any): number;
  67906. /**
  67907. * Adds points to the PCS from the surface of the model shape
  67908. * @param mesh is any Mesh object that will be used as a surface model for the points
  67909. * @param nb (positive integer) the number of particles to be created from this model
  67910. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67911. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67912. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67913. * @returns the number of groups in the system
  67914. */
  67915. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67916. /**
  67917. * Adds points to the PCS inside the model shape
  67918. * @param mesh is any Mesh object that will be used as a surface model for the points
  67919. * @param nb (positive integer) the number of particles to be created from this model
  67920. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67921. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67922. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67923. * @returns the number of groups in the system
  67924. */
  67925. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67926. /**
  67927. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  67928. * This method calls `updateParticle()` for each particle of the SPS.
  67929. * For an animated SPS, it is usually called within the render loop.
  67930. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  67931. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  67932. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  67933. * @returns the PCS.
  67934. */
  67935. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  67936. /**
  67937. * Disposes the PCS.
  67938. */
  67939. dispose(): void;
  67940. /**
  67941. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  67942. * doc :
  67943. * @returns the PCS.
  67944. */
  67945. refreshVisibleSize(): PointsCloudSystem;
  67946. /**
  67947. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  67948. * @param size the size (float) of the visibility box
  67949. * note : this doesn't lock the PCS mesh bounding box.
  67950. * doc :
  67951. */
  67952. setVisibilityBox(size: number): void;
  67953. /**
  67954. * Gets whether the PCS is always visible or not
  67955. * doc :
  67956. */
  67957. get isAlwaysVisible(): boolean;
  67958. /**
  67959. * Sets the PCS as always visible or not
  67960. * doc :
  67961. */
  67962. set isAlwaysVisible(val: boolean);
  67963. /**
  67964. * Tells to `setParticles()` to compute the particle rotations or not
  67965. * Default value : false. The PCS is faster when it's set to false
  67966. * Note : particle rotations are only applied to parent particles
  67967. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  67968. */
  67969. set computeParticleRotation(val: boolean);
  67970. /**
  67971. * Tells to `setParticles()` to compute the particle colors or not.
  67972. * Default value : true. The PCS is faster when it's set to false.
  67973. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67974. */
  67975. set computeParticleColor(val: boolean);
  67976. set computeParticleTexture(val: boolean);
  67977. /**
  67978. * Gets if `setParticles()` computes the particle colors or not.
  67979. * Default value : false. The PCS is faster when it's set to false.
  67980. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67981. */
  67982. get computeParticleColor(): boolean;
  67983. /**
  67984. * Gets if `setParticles()` computes the particle textures or not.
  67985. * Default value : false. The PCS is faster when it's set to false.
  67986. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  67987. */
  67988. get computeParticleTexture(): boolean;
  67989. /**
  67990. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  67991. */
  67992. set computeBoundingBox(val: boolean);
  67993. /**
  67994. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  67995. */
  67996. get computeBoundingBox(): boolean;
  67997. /**
  67998. * This function does nothing. It may be overwritten to set all the particle first values.
  67999. * The PCS doesn't call this function, you may have to call it by your own.
  68000. * doc :
  68001. */
  68002. initParticles(): void;
  68003. /**
  68004. * This function does nothing. It may be overwritten to recycle a particle
  68005. * The PCS doesn't call this function, you can to call it
  68006. * doc :
  68007. * @param particle The particle to recycle
  68008. * @returns the recycled particle
  68009. */
  68010. recycleParticle(particle: CloudPoint): CloudPoint;
  68011. /**
  68012. * Updates a particle : this function should be overwritten by the user.
  68013. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  68014. * doc :
  68015. * @example : just set a particle position or velocity and recycle conditions
  68016. * @param particle The particle to update
  68017. * @returns the updated particle
  68018. */
  68019. updateParticle(particle: CloudPoint): CloudPoint;
  68020. /**
  68021. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  68022. * This does nothing and may be overwritten by the user.
  68023. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68024. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68025. * @param update the boolean update value actually passed to setParticles()
  68026. */
  68027. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68028. /**
  68029. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  68030. * This will be passed three parameters.
  68031. * This does nothing and may be overwritten by the user.
  68032. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68033. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68034. * @param update the boolean update value actually passed to setParticles()
  68035. */
  68036. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68037. }
  68038. }
  68039. declare module BABYLON {
  68040. /**
  68041. * Represents one particle of a points cloud system.
  68042. */
  68043. export class CloudPoint {
  68044. /**
  68045. * particle global index
  68046. */
  68047. idx: number;
  68048. /**
  68049. * The color of the particle
  68050. */
  68051. color: Nullable<Color4>;
  68052. /**
  68053. * The world space position of the particle.
  68054. */
  68055. position: Vector3;
  68056. /**
  68057. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  68058. */
  68059. rotation: Vector3;
  68060. /**
  68061. * The world space rotation quaternion of the particle.
  68062. */
  68063. rotationQuaternion: Nullable<Quaternion>;
  68064. /**
  68065. * The uv of the particle.
  68066. */
  68067. uv: Nullable<Vector2>;
  68068. /**
  68069. * The current speed of the particle.
  68070. */
  68071. velocity: Vector3;
  68072. /**
  68073. * The pivot point in the particle local space.
  68074. */
  68075. pivot: Vector3;
  68076. /**
  68077. * Must the particle be translated from its pivot point in its local space ?
  68078. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  68079. * Default : false
  68080. */
  68081. translateFromPivot: boolean;
  68082. /**
  68083. * Index of this particle in the global "positions" array (Internal use)
  68084. * @hidden
  68085. */
  68086. _pos: number;
  68087. /**
  68088. * @hidden Index of this particle in the global "indices" array (Internal use)
  68089. */
  68090. _ind: number;
  68091. /**
  68092. * Group this particle belongs to
  68093. */
  68094. _group: PointsGroup;
  68095. /**
  68096. * Group id of this particle
  68097. */
  68098. groupId: number;
  68099. /**
  68100. * Index of the particle in its group id (Internal use)
  68101. */
  68102. idxInGroup: number;
  68103. /**
  68104. * @hidden Particle BoundingInfo object (Internal use)
  68105. */
  68106. _boundingInfo: BoundingInfo;
  68107. /**
  68108. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  68109. */
  68110. _pcs: PointsCloudSystem;
  68111. /**
  68112. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  68113. */
  68114. _stillInvisible: boolean;
  68115. /**
  68116. * @hidden Last computed particle rotation matrix
  68117. */
  68118. _rotationMatrix: number[];
  68119. /**
  68120. * Parent particle Id, if any.
  68121. * Default null.
  68122. */
  68123. parentId: Nullable<number>;
  68124. /**
  68125. * @hidden Internal global position in the PCS.
  68126. */
  68127. _globalPosition: Vector3;
  68128. /**
  68129. * Creates a Point Cloud object.
  68130. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  68131. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  68132. * @param group (PointsGroup) is the group the particle belongs to
  68133. * @param groupId (integer) is the group identifier in the PCS.
  68134. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  68135. * @param pcs defines the PCS it is associated to
  68136. */
  68137. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  68138. /**
  68139. * get point size
  68140. */
  68141. get size(): Vector3;
  68142. /**
  68143. * Set point size
  68144. */
  68145. set size(scale: Vector3);
  68146. /**
  68147. * Legacy support, changed quaternion to rotationQuaternion
  68148. */
  68149. get quaternion(): Nullable<Quaternion>;
  68150. /**
  68151. * Legacy support, changed quaternion to rotationQuaternion
  68152. */
  68153. set quaternion(q: Nullable<Quaternion>);
  68154. /**
  68155. * Returns a boolean. True if the particle intersects a mesh, else false
  68156. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  68157. * @param target is the object (point or mesh) what the intersection is computed against
  68158. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  68159. * @returns true if it intersects
  68160. */
  68161. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  68162. /**
  68163. * get the rotation matrix of the particle
  68164. * @hidden
  68165. */
  68166. getRotationMatrix(m: Matrix): void;
  68167. }
  68168. /**
  68169. * Represents a group of points in a points cloud system
  68170. * * PCS internal tool, don't use it manually.
  68171. */
  68172. export class PointsGroup {
  68173. /**
  68174. * The group id
  68175. * @hidden
  68176. */
  68177. groupID: number;
  68178. /**
  68179. * image data for group (internal use)
  68180. * @hidden
  68181. */
  68182. _groupImageData: Nullable<ArrayBufferView>;
  68183. /**
  68184. * Image Width (internal use)
  68185. * @hidden
  68186. */
  68187. _groupImgWidth: number;
  68188. /**
  68189. * Image Height (internal use)
  68190. * @hidden
  68191. */
  68192. _groupImgHeight: number;
  68193. /**
  68194. * Custom position function (internal use)
  68195. * @hidden
  68196. */
  68197. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  68198. /**
  68199. * density per facet for surface points
  68200. * @hidden
  68201. */
  68202. _groupDensity: number[];
  68203. /**
  68204. * Only when points are colored by texture carries pointer to texture list array
  68205. * @hidden
  68206. */
  68207. _textureNb: number;
  68208. /**
  68209. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  68210. * PCS internal tool, don't use it manually.
  68211. * @hidden
  68212. */
  68213. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  68214. }
  68215. }
  68216. declare module BABYLON {
  68217. interface Scene {
  68218. /** @hidden (Backing field) */
  68219. _physicsEngine: Nullable<IPhysicsEngine>;
  68220. /** @hidden */
  68221. _physicsTimeAccumulator: number;
  68222. /**
  68223. * Gets the current physics engine
  68224. * @returns a IPhysicsEngine or null if none attached
  68225. */
  68226. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  68227. /**
  68228. * Enables physics to the current scene
  68229. * @param gravity defines the scene's gravity for the physics engine
  68230. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  68231. * @return a boolean indicating if the physics engine was initialized
  68232. */
  68233. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  68234. /**
  68235. * Disables and disposes the physics engine associated with the scene
  68236. */
  68237. disablePhysicsEngine(): void;
  68238. /**
  68239. * Gets a boolean indicating if there is an active physics engine
  68240. * @returns a boolean indicating if there is an active physics engine
  68241. */
  68242. isPhysicsEnabled(): boolean;
  68243. /**
  68244. * Deletes a physics compound impostor
  68245. * @param compound defines the compound to delete
  68246. */
  68247. deleteCompoundImpostor(compound: any): void;
  68248. /**
  68249. * An event triggered when physic simulation is about to be run
  68250. */
  68251. onBeforePhysicsObservable: Observable<Scene>;
  68252. /**
  68253. * An event triggered when physic simulation has been done
  68254. */
  68255. onAfterPhysicsObservable: Observable<Scene>;
  68256. }
  68257. interface AbstractMesh {
  68258. /** @hidden */
  68259. _physicsImpostor: Nullable<PhysicsImpostor>;
  68260. /**
  68261. * Gets or sets impostor used for physic simulation
  68262. * @see https://doc.babylonjs.com/features/physics_engine
  68263. */
  68264. physicsImpostor: Nullable<PhysicsImpostor>;
  68265. /**
  68266. * Gets the current physics impostor
  68267. * @see https://doc.babylonjs.com/features/physics_engine
  68268. * @returns a physics impostor or null
  68269. */
  68270. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  68271. /** Apply a physic impulse to the mesh
  68272. * @param force defines the force to apply
  68273. * @param contactPoint defines where to apply the force
  68274. * @returns the current mesh
  68275. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  68276. */
  68277. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  68278. /**
  68279. * Creates a physic joint between two meshes
  68280. * @param otherMesh defines the other mesh to use
  68281. * @param pivot1 defines the pivot to use on this mesh
  68282. * @param pivot2 defines the pivot to use on the other mesh
  68283. * @param options defines additional options (can be plugin dependent)
  68284. * @returns the current mesh
  68285. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  68286. */
  68287. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  68288. /** @hidden */
  68289. _disposePhysicsObserver: Nullable<Observer<Node>>;
  68290. }
  68291. /**
  68292. * Defines the physics engine scene component responsible to manage a physics engine
  68293. */
  68294. export class PhysicsEngineSceneComponent implements ISceneComponent {
  68295. /**
  68296. * The component name helpful to identify the component in the list of scene components.
  68297. */
  68298. readonly name: string;
  68299. /**
  68300. * The scene the component belongs to.
  68301. */
  68302. scene: Scene;
  68303. /**
  68304. * Creates a new instance of the component for the given scene
  68305. * @param scene Defines the scene to register the component in
  68306. */
  68307. constructor(scene: Scene);
  68308. /**
  68309. * Registers the component in a given scene
  68310. */
  68311. register(): void;
  68312. /**
  68313. * Rebuilds the elements related to this component in case of
  68314. * context lost for instance.
  68315. */
  68316. rebuild(): void;
  68317. /**
  68318. * Disposes the component and the associated ressources
  68319. */
  68320. dispose(): void;
  68321. }
  68322. }
  68323. declare module BABYLON {
  68324. /**
  68325. * A helper for physics simulations
  68326. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68327. */
  68328. export class PhysicsHelper {
  68329. private _scene;
  68330. private _physicsEngine;
  68331. /**
  68332. * Initializes the Physics helper
  68333. * @param scene Babylon.js scene
  68334. */
  68335. constructor(scene: Scene);
  68336. /**
  68337. * Applies a radial explosion impulse
  68338. * @param origin the origin of the explosion
  68339. * @param radiusOrEventOptions the radius or the options of radial explosion
  68340. * @param strength the explosion strength
  68341. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68342. * @returns A physics radial explosion event, or null
  68343. */
  68344. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68345. /**
  68346. * Applies a radial explosion force
  68347. * @param origin the origin of the explosion
  68348. * @param radiusOrEventOptions the radius or the options of radial explosion
  68349. * @param strength the explosion strength
  68350. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68351. * @returns A physics radial explosion event, or null
  68352. */
  68353. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68354. /**
  68355. * Creates a gravitational field
  68356. * @param origin the origin of the explosion
  68357. * @param radiusOrEventOptions the radius or the options of radial explosion
  68358. * @param strength the explosion strength
  68359. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68360. * @returns A physics gravitational field event, or null
  68361. */
  68362. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  68363. /**
  68364. * Creates a physics updraft event
  68365. * @param origin the origin of the updraft
  68366. * @param radiusOrEventOptions the radius or the options of the updraft
  68367. * @param strength the strength of the updraft
  68368. * @param height the height of the updraft
  68369. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  68370. * @returns A physics updraft event, or null
  68371. */
  68372. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  68373. /**
  68374. * Creates a physics vortex event
  68375. * @param origin the of the vortex
  68376. * @param radiusOrEventOptions the radius or the options of the vortex
  68377. * @param strength the strength of the vortex
  68378. * @param height the height of the vortex
  68379. * @returns a Physics vortex event, or null
  68380. * A physics vortex event or null
  68381. */
  68382. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  68383. }
  68384. /**
  68385. * Represents a physics radial explosion event
  68386. */
  68387. class PhysicsRadialExplosionEvent {
  68388. private _scene;
  68389. private _options;
  68390. private _sphere;
  68391. private _dataFetched;
  68392. /**
  68393. * Initializes a radial explosioin event
  68394. * @param _scene BabylonJS scene
  68395. * @param _options The options for the vortex event
  68396. */
  68397. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  68398. /**
  68399. * Returns the data related to the radial explosion event (sphere).
  68400. * @returns The radial explosion event data
  68401. */
  68402. getData(): PhysicsRadialExplosionEventData;
  68403. /**
  68404. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  68405. * @param impostor A physics imposter
  68406. * @param origin the origin of the explosion
  68407. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  68408. */
  68409. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  68410. /**
  68411. * Triggers affecterd impostors callbacks
  68412. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  68413. */
  68414. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  68415. /**
  68416. * Disposes the sphere.
  68417. * @param force Specifies if the sphere should be disposed by force
  68418. */
  68419. dispose(force?: boolean): void;
  68420. /*** Helpers ***/
  68421. private _prepareSphere;
  68422. private _intersectsWithSphere;
  68423. }
  68424. /**
  68425. * Represents a gravitational field event
  68426. */
  68427. class PhysicsGravitationalFieldEvent {
  68428. private _physicsHelper;
  68429. private _scene;
  68430. private _origin;
  68431. private _options;
  68432. private _tickCallback;
  68433. private _sphere;
  68434. private _dataFetched;
  68435. /**
  68436. * Initializes the physics gravitational field event
  68437. * @param _physicsHelper A physics helper
  68438. * @param _scene BabylonJS scene
  68439. * @param _origin The origin position of the gravitational field event
  68440. * @param _options The options for the vortex event
  68441. */
  68442. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  68443. /**
  68444. * Returns the data related to the gravitational field event (sphere).
  68445. * @returns A gravitational field event
  68446. */
  68447. getData(): PhysicsGravitationalFieldEventData;
  68448. /**
  68449. * Enables the gravitational field.
  68450. */
  68451. enable(): void;
  68452. /**
  68453. * Disables the gravitational field.
  68454. */
  68455. disable(): void;
  68456. /**
  68457. * Disposes the sphere.
  68458. * @param force The force to dispose from the gravitational field event
  68459. */
  68460. dispose(force?: boolean): void;
  68461. private _tick;
  68462. }
  68463. /**
  68464. * Represents a physics updraft event
  68465. */
  68466. class PhysicsUpdraftEvent {
  68467. private _scene;
  68468. private _origin;
  68469. private _options;
  68470. private _physicsEngine;
  68471. private _originTop;
  68472. private _originDirection;
  68473. private _tickCallback;
  68474. private _cylinder;
  68475. private _cylinderPosition;
  68476. private _dataFetched;
  68477. /**
  68478. * Initializes the physics updraft event
  68479. * @param _scene BabylonJS scene
  68480. * @param _origin The origin position of the updraft
  68481. * @param _options The options for the updraft event
  68482. */
  68483. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  68484. /**
  68485. * Returns the data related to the updraft event (cylinder).
  68486. * @returns A physics updraft event
  68487. */
  68488. getData(): PhysicsUpdraftEventData;
  68489. /**
  68490. * Enables the updraft.
  68491. */
  68492. enable(): void;
  68493. /**
  68494. * Disables the updraft.
  68495. */
  68496. disable(): void;
  68497. /**
  68498. * Disposes the cylinder.
  68499. * @param force Specifies if the updraft should be disposed by force
  68500. */
  68501. dispose(force?: boolean): void;
  68502. private getImpostorHitData;
  68503. private _tick;
  68504. /*** Helpers ***/
  68505. private _prepareCylinder;
  68506. private _intersectsWithCylinder;
  68507. }
  68508. /**
  68509. * Represents a physics vortex event
  68510. */
  68511. class PhysicsVortexEvent {
  68512. private _scene;
  68513. private _origin;
  68514. private _options;
  68515. private _physicsEngine;
  68516. private _originTop;
  68517. private _tickCallback;
  68518. private _cylinder;
  68519. private _cylinderPosition;
  68520. private _dataFetched;
  68521. /**
  68522. * Initializes the physics vortex event
  68523. * @param _scene The BabylonJS scene
  68524. * @param _origin The origin position of the vortex
  68525. * @param _options The options for the vortex event
  68526. */
  68527. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  68528. /**
  68529. * Returns the data related to the vortex event (cylinder).
  68530. * @returns The physics vortex event data
  68531. */
  68532. getData(): PhysicsVortexEventData;
  68533. /**
  68534. * Enables the vortex.
  68535. */
  68536. enable(): void;
  68537. /**
  68538. * Disables the cortex.
  68539. */
  68540. disable(): void;
  68541. /**
  68542. * Disposes the sphere.
  68543. * @param force
  68544. */
  68545. dispose(force?: boolean): void;
  68546. private getImpostorHitData;
  68547. private _tick;
  68548. /*** Helpers ***/
  68549. private _prepareCylinder;
  68550. private _intersectsWithCylinder;
  68551. }
  68552. /**
  68553. * Options fot the radial explosion event
  68554. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68555. */
  68556. export class PhysicsRadialExplosionEventOptions {
  68557. /**
  68558. * The radius of the sphere for the radial explosion.
  68559. */
  68560. radius: number;
  68561. /**
  68562. * The strenth of the explosion.
  68563. */
  68564. strength: number;
  68565. /**
  68566. * The strenght of the force in correspondence to the distance of the affected object
  68567. */
  68568. falloff: PhysicsRadialImpulseFalloff;
  68569. /**
  68570. * Sphere options for the radial explosion.
  68571. */
  68572. sphere: {
  68573. segments: number;
  68574. diameter: number;
  68575. };
  68576. /**
  68577. * Sphere options for the radial explosion.
  68578. */
  68579. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  68580. }
  68581. /**
  68582. * Options fot the updraft event
  68583. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68584. */
  68585. export class PhysicsUpdraftEventOptions {
  68586. /**
  68587. * The radius of the cylinder for the vortex
  68588. */
  68589. radius: number;
  68590. /**
  68591. * The strenth of the updraft.
  68592. */
  68593. strength: number;
  68594. /**
  68595. * The height of the cylinder for the updraft.
  68596. */
  68597. height: number;
  68598. /**
  68599. * The mode for the the updraft.
  68600. */
  68601. updraftMode: PhysicsUpdraftMode;
  68602. }
  68603. /**
  68604. * Options fot the vortex event
  68605. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68606. */
  68607. export class PhysicsVortexEventOptions {
  68608. /**
  68609. * The radius of the cylinder for the vortex
  68610. */
  68611. radius: number;
  68612. /**
  68613. * The strenth of the vortex.
  68614. */
  68615. strength: number;
  68616. /**
  68617. * The height of the cylinder for the vortex.
  68618. */
  68619. height: number;
  68620. /**
  68621. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  68622. */
  68623. centripetalForceThreshold: number;
  68624. /**
  68625. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  68626. */
  68627. centripetalForceMultiplier: number;
  68628. /**
  68629. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  68630. */
  68631. centrifugalForceMultiplier: number;
  68632. /**
  68633. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  68634. */
  68635. updraftForceMultiplier: number;
  68636. }
  68637. /**
  68638. * The strenght of the force in correspondence to the distance of the affected object
  68639. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68640. */
  68641. export enum PhysicsRadialImpulseFalloff {
  68642. /** Defines that impulse is constant in strength across it's whole radius */
  68643. Constant = 0,
  68644. /** Defines that impulse gets weaker if it's further from the origin */
  68645. Linear = 1
  68646. }
  68647. /**
  68648. * The strength of the force in correspondence to the distance of the affected object
  68649. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68650. */
  68651. export enum PhysicsUpdraftMode {
  68652. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  68653. Center = 0,
  68654. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  68655. Perpendicular = 1
  68656. }
  68657. /**
  68658. * Interface for a physics hit data
  68659. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68660. */
  68661. export interface PhysicsHitData {
  68662. /**
  68663. * The force applied at the contact point
  68664. */
  68665. force: Vector3;
  68666. /**
  68667. * The contact point
  68668. */
  68669. contactPoint: Vector3;
  68670. /**
  68671. * The distance from the origin to the contact point
  68672. */
  68673. distanceFromOrigin: number;
  68674. }
  68675. /**
  68676. * Interface for radial explosion event data
  68677. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68678. */
  68679. export interface PhysicsRadialExplosionEventData {
  68680. /**
  68681. * A sphere used for the radial explosion event
  68682. */
  68683. sphere: Mesh;
  68684. }
  68685. /**
  68686. * Interface for gravitational field event data
  68687. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68688. */
  68689. export interface PhysicsGravitationalFieldEventData {
  68690. /**
  68691. * A sphere mesh used for the gravitational field event
  68692. */
  68693. sphere: Mesh;
  68694. }
  68695. /**
  68696. * Interface for updraft event data
  68697. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68698. */
  68699. export interface PhysicsUpdraftEventData {
  68700. /**
  68701. * A cylinder used for the updraft event
  68702. */
  68703. cylinder: Mesh;
  68704. }
  68705. /**
  68706. * Interface for vortex event data
  68707. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68708. */
  68709. export interface PhysicsVortexEventData {
  68710. /**
  68711. * A cylinder used for the vortex event
  68712. */
  68713. cylinder: Mesh;
  68714. }
  68715. /**
  68716. * Interface for an affected physics impostor
  68717. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68718. */
  68719. export interface PhysicsAffectedImpostorWithData {
  68720. /**
  68721. * The impostor affected by the effect
  68722. */
  68723. impostor: PhysicsImpostor;
  68724. /**
  68725. * The data about the hit/horce from the explosion
  68726. */
  68727. hitData: PhysicsHitData;
  68728. }
  68729. }
  68730. declare module BABYLON {
  68731. /** @hidden */
  68732. export var blackAndWhitePixelShader: {
  68733. name: string;
  68734. shader: string;
  68735. };
  68736. }
  68737. declare module BABYLON {
  68738. /**
  68739. * Post process used to render in black and white
  68740. */
  68741. export class BlackAndWhitePostProcess extends PostProcess {
  68742. /**
  68743. * Linear about to convert he result to black and white (default: 1)
  68744. */
  68745. degree: number;
  68746. /**
  68747. * Gets a string identifying the name of the class
  68748. * @returns "BlackAndWhitePostProcess" string
  68749. */
  68750. getClassName(): string;
  68751. /**
  68752. * Creates a black and white post process
  68753. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  68754. * @param name The name of the effect.
  68755. * @param options The required width/height ratio to downsize to before computing the render pass.
  68756. * @param camera The camera to apply the render pass to.
  68757. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68758. * @param engine The engine which the post process will be applied. (default: current engine)
  68759. * @param reusable If the post process can be reused on the same frame. (default: false)
  68760. */
  68761. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68762. /** @hidden */
  68763. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  68764. }
  68765. }
  68766. declare module BABYLON {
  68767. /**
  68768. * This represents a set of one or more post processes in Babylon.
  68769. * A post process can be used to apply a shader to a texture after it is rendered.
  68770. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68771. */
  68772. export class PostProcessRenderEffect {
  68773. private _postProcesses;
  68774. private _getPostProcesses;
  68775. private _singleInstance;
  68776. private _cameras;
  68777. private _indicesForCamera;
  68778. /**
  68779. * Name of the effect
  68780. * @hidden
  68781. */
  68782. _name: string;
  68783. /**
  68784. * Instantiates a post process render effect.
  68785. * A post process can be used to apply a shader to a texture after it is rendered.
  68786. * @param engine The engine the effect is tied to
  68787. * @param name The name of the effect
  68788. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  68789. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  68790. */
  68791. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  68792. /**
  68793. * Checks if all the post processes in the effect are supported.
  68794. */
  68795. get isSupported(): boolean;
  68796. /**
  68797. * Updates the current state of the effect
  68798. * @hidden
  68799. */
  68800. _update(): void;
  68801. /**
  68802. * Attaches the effect on cameras
  68803. * @param cameras The camera to attach to.
  68804. * @hidden
  68805. */
  68806. _attachCameras(cameras: Camera): void;
  68807. /**
  68808. * Attaches the effect on cameras
  68809. * @param cameras The camera to attach to.
  68810. * @hidden
  68811. */
  68812. _attachCameras(cameras: Camera[]): void;
  68813. /**
  68814. * Detaches the effect on cameras
  68815. * @param cameras The camera to detatch from.
  68816. * @hidden
  68817. */
  68818. _detachCameras(cameras: Camera): void;
  68819. /**
  68820. * Detatches the effect on cameras
  68821. * @param cameras The camera to detatch from.
  68822. * @hidden
  68823. */
  68824. _detachCameras(cameras: Camera[]): void;
  68825. /**
  68826. * Enables the effect on given cameras
  68827. * @param cameras The camera to enable.
  68828. * @hidden
  68829. */
  68830. _enable(cameras: Camera): void;
  68831. /**
  68832. * Enables the effect on given cameras
  68833. * @param cameras The camera to enable.
  68834. * @hidden
  68835. */
  68836. _enable(cameras: Nullable<Camera[]>): void;
  68837. /**
  68838. * Disables the effect on the given cameras
  68839. * @param cameras The camera to disable.
  68840. * @hidden
  68841. */
  68842. _disable(cameras: Camera): void;
  68843. /**
  68844. * Disables the effect on the given cameras
  68845. * @param cameras The camera to disable.
  68846. * @hidden
  68847. */
  68848. _disable(cameras: Nullable<Camera[]>): void;
  68849. /**
  68850. * Gets a list of the post processes contained in the effect.
  68851. * @param camera The camera to get the post processes on.
  68852. * @returns The list of the post processes in the effect.
  68853. */
  68854. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  68855. }
  68856. }
  68857. declare module BABYLON {
  68858. /** @hidden */
  68859. export var extractHighlightsPixelShader: {
  68860. name: string;
  68861. shader: string;
  68862. };
  68863. }
  68864. declare module BABYLON {
  68865. /**
  68866. * 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.
  68867. */
  68868. export class ExtractHighlightsPostProcess extends PostProcess {
  68869. /**
  68870. * The luminance threshold, pixels below this value will be set to black.
  68871. */
  68872. threshold: number;
  68873. /** @hidden */
  68874. _exposure: number;
  68875. /**
  68876. * Post process which has the input texture to be used when performing highlight extraction
  68877. * @hidden
  68878. */
  68879. _inputPostProcess: Nullable<PostProcess>;
  68880. /**
  68881. * Gets a string identifying the name of the class
  68882. * @returns "ExtractHighlightsPostProcess" string
  68883. */
  68884. getClassName(): string;
  68885. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68886. }
  68887. }
  68888. declare module BABYLON {
  68889. /** @hidden */
  68890. export var bloomMergePixelShader: {
  68891. name: string;
  68892. shader: string;
  68893. };
  68894. }
  68895. declare module BABYLON {
  68896. /**
  68897. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68898. */
  68899. export class BloomMergePostProcess extends PostProcess {
  68900. /** Weight of the bloom to be added to the original input. */
  68901. weight: number;
  68902. /**
  68903. * Gets a string identifying the name of the class
  68904. * @returns "BloomMergePostProcess" string
  68905. */
  68906. getClassName(): string;
  68907. /**
  68908. * Creates a new instance of @see BloomMergePostProcess
  68909. * @param name The name of the effect.
  68910. * @param originalFromInput Post process which's input will be used for the merge.
  68911. * @param blurred Blurred highlights post process which's output will be used.
  68912. * @param weight Weight of the bloom to be added to the original input.
  68913. * @param options The required width/height ratio to downsize to before computing the render pass.
  68914. * @param camera The camera to apply the render pass to.
  68915. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68916. * @param engine The engine which the post process will be applied. (default: current engine)
  68917. * @param reusable If the post process can be reused on the same frame. (default: false)
  68918. * @param textureType Type of textures used when performing the post process. (default: 0)
  68919. * @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)
  68920. */
  68921. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  68922. /** Weight of the bloom to be added to the original input. */
  68923. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68924. }
  68925. }
  68926. declare module BABYLON {
  68927. /**
  68928. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  68929. */
  68930. export class BloomEffect extends PostProcessRenderEffect {
  68931. private bloomScale;
  68932. /**
  68933. * @hidden Internal
  68934. */
  68935. _effects: Array<PostProcess>;
  68936. /**
  68937. * @hidden Internal
  68938. */
  68939. _downscale: ExtractHighlightsPostProcess;
  68940. private _blurX;
  68941. private _blurY;
  68942. private _merge;
  68943. /**
  68944. * The luminance threshold to find bright areas of the image to bloom.
  68945. */
  68946. get threshold(): number;
  68947. set threshold(value: number);
  68948. /**
  68949. * The strength of the bloom.
  68950. */
  68951. get weight(): number;
  68952. set weight(value: number);
  68953. /**
  68954. * Specifies the size of the bloom blur kernel, relative to the final output size
  68955. */
  68956. get kernel(): number;
  68957. set kernel(value: number);
  68958. /**
  68959. * Creates a new instance of @see BloomEffect
  68960. * @param scene The scene the effect belongs to.
  68961. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  68962. * @param bloomKernel The size of the kernel to be used when applying the blur.
  68963. * @param bloomWeight The the strength of bloom.
  68964. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68965. * @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)
  68966. */
  68967. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  68968. /**
  68969. * Disposes each of the internal effects for a given camera.
  68970. * @param camera The camera to dispose the effect on.
  68971. */
  68972. disposeEffects(camera: Camera): void;
  68973. /**
  68974. * @hidden Internal
  68975. */
  68976. _updateEffects(): void;
  68977. /**
  68978. * Internal
  68979. * @returns if all the contained post processes are ready.
  68980. * @hidden
  68981. */
  68982. _isReady(): boolean;
  68983. }
  68984. }
  68985. declare module BABYLON {
  68986. /** @hidden */
  68987. export var chromaticAberrationPixelShader: {
  68988. name: string;
  68989. shader: string;
  68990. };
  68991. }
  68992. declare module BABYLON {
  68993. /**
  68994. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  68995. */
  68996. export class ChromaticAberrationPostProcess extends PostProcess {
  68997. /**
  68998. * The amount of seperation of rgb channels (default: 30)
  68999. */
  69000. aberrationAmount: number;
  69001. /**
  69002. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  69003. */
  69004. radialIntensity: number;
  69005. /**
  69006. * 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))
  69007. */
  69008. direction: Vector2;
  69009. /**
  69010. * 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))
  69011. */
  69012. centerPosition: Vector2;
  69013. /** The width of the screen to apply the effect on */
  69014. screenWidth: number;
  69015. /** The height of the screen to apply the effect on */
  69016. screenHeight: number;
  69017. /**
  69018. * Gets a string identifying the name of the class
  69019. * @returns "ChromaticAberrationPostProcess" string
  69020. */
  69021. getClassName(): string;
  69022. /**
  69023. * Creates a new instance ChromaticAberrationPostProcess
  69024. * @param name The name of the effect.
  69025. * @param screenWidth The width of the screen to apply the effect on.
  69026. * @param screenHeight The height of the screen to apply the effect on.
  69027. * @param options The required width/height ratio to downsize to before computing the render pass.
  69028. * @param camera The camera to apply the render pass to.
  69029. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69030. * @param engine The engine which the post process will be applied. (default: current engine)
  69031. * @param reusable If the post process can be reused on the same frame. (default: false)
  69032. * @param textureType Type of textures used when performing the post process. (default: 0)
  69033. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  69034. */
  69035. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69036. /** @hidden */
  69037. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  69038. }
  69039. }
  69040. declare module BABYLON {
  69041. /** @hidden */
  69042. export var circleOfConfusionPixelShader: {
  69043. name: string;
  69044. shader: string;
  69045. };
  69046. }
  69047. declare module BABYLON {
  69048. /**
  69049. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  69050. */
  69051. export class CircleOfConfusionPostProcess extends PostProcess {
  69052. /**
  69053. * 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.
  69054. */
  69055. lensSize: number;
  69056. /**
  69057. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69058. */
  69059. fStop: number;
  69060. /**
  69061. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69062. */
  69063. focusDistance: number;
  69064. /**
  69065. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  69066. */
  69067. focalLength: number;
  69068. /**
  69069. * Gets a string identifying the name of the class
  69070. * @returns "CircleOfConfusionPostProcess" string
  69071. */
  69072. getClassName(): string;
  69073. private _depthTexture;
  69074. /**
  69075. * Creates a new instance CircleOfConfusionPostProcess
  69076. * @param name The name of the effect.
  69077. * @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.
  69078. * @param options The required width/height ratio to downsize to before computing the render pass.
  69079. * @param camera The camera to apply the render pass to.
  69080. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69081. * @param engine The engine which the post process will be applied. (default: current engine)
  69082. * @param reusable If the post process can be reused on the same frame. (default: false)
  69083. * @param textureType Type of textures used when performing the post process. (default: 0)
  69084. * @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)
  69085. */
  69086. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69087. /**
  69088. * 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.
  69089. */
  69090. set depthTexture(value: RenderTargetTexture);
  69091. }
  69092. }
  69093. declare module BABYLON {
  69094. /** @hidden */
  69095. export var colorCorrectionPixelShader: {
  69096. name: string;
  69097. shader: string;
  69098. };
  69099. }
  69100. declare module BABYLON {
  69101. /**
  69102. *
  69103. * This post-process allows the modification of rendered colors by using
  69104. * a 'look-up table' (LUT). This effect is also called Color Grading.
  69105. *
  69106. * The object needs to be provided an url to a texture containing the color
  69107. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  69108. * Use an image editing software to tweak the LUT to match your needs.
  69109. *
  69110. * For an example of a color LUT, see here:
  69111. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  69112. * For explanations on color grading, see here:
  69113. * @see http://udn.epicgames.com/Three/ColorGrading.html
  69114. *
  69115. */
  69116. export class ColorCorrectionPostProcess extends PostProcess {
  69117. private _colorTableTexture;
  69118. /**
  69119. * Gets the color table url used to create the LUT texture
  69120. */
  69121. colorTableUrl: string;
  69122. /**
  69123. * Gets a string identifying the name of the class
  69124. * @returns "ColorCorrectionPostProcess" string
  69125. */
  69126. getClassName(): string;
  69127. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69128. /** @hidden */
  69129. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  69130. }
  69131. }
  69132. declare module BABYLON {
  69133. /** @hidden */
  69134. export var convolutionPixelShader: {
  69135. name: string;
  69136. shader: string;
  69137. };
  69138. }
  69139. declare module BABYLON {
  69140. /**
  69141. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  69142. * input texture to perform effects such as edge detection or sharpening
  69143. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69144. */
  69145. export class ConvolutionPostProcess extends PostProcess {
  69146. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  69147. kernel: number[];
  69148. /**
  69149. * Gets a string identifying the name of the class
  69150. * @returns "ConvolutionPostProcess" string
  69151. */
  69152. getClassName(): string;
  69153. /**
  69154. * Creates a new instance ConvolutionPostProcess
  69155. * @param name The name of the effect.
  69156. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  69157. * @param options The required width/height ratio to downsize to before computing the render pass.
  69158. * @param camera The camera to apply the render pass to.
  69159. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69160. * @param engine The engine which the post process will be applied. (default: current engine)
  69161. * @param reusable If the post process can be reused on the same frame. (default: false)
  69162. * @param textureType Type of textures used when performing the post process. (default: 0)
  69163. */
  69164. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69165. /** @hidden */
  69166. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  69167. /**
  69168. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69169. */
  69170. static EdgeDetect0Kernel: number[];
  69171. /**
  69172. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69173. */
  69174. static EdgeDetect1Kernel: number[];
  69175. /**
  69176. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69177. */
  69178. static EdgeDetect2Kernel: number[];
  69179. /**
  69180. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69181. */
  69182. static SharpenKernel: number[];
  69183. /**
  69184. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69185. */
  69186. static EmbossKernel: number[];
  69187. /**
  69188. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69189. */
  69190. static GaussianKernel: number[];
  69191. }
  69192. }
  69193. declare module BABYLON {
  69194. /**
  69195. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  69196. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  69197. * based on samples that have a large difference in distance than the center pixel.
  69198. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  69199. */
  69200. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  69201. /**
  69202. * The direction the blur should be applied
  69203. */
  69204. direction: Vector2;
  69205. /**
  69206. * Gets a string identifying the name of the class
  69207. * @returns "DepthOfFieldBlurPostProcess" string
  69208. */
  69209. getClassName(): string;
  69210. /**
  69211. * Creates a new instance CircleOfConfusionPostProcess
  69212. * @param name The name of the effect.
  69213. * @param scene The scene the effect belongs to.
  69214. * @param direction The direction the blur should be applied.
  69215. * @param kernel The size of the kernel used to blur.
  69216. * @param options The required width/height ratio to downsize to before computing the render pass.
  69217. * @param camera The camera to apply the render pass to.
  69218. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  69219. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  69220. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69221. * @param engine The engine which the post process will be applied. (default: current engine)
  69222. * @param reusable If the post process can be reused on the same frame. (default: false)
  69223. * @param textureType Type of textures used when performing the post process. (default: 0)
  69224. * @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)
  69225. */
  69226. 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);
  69227. }
  69228. }
  69229. declare module BABYLON {
  69230. /** @hidden */
  69231. export var depthOfFieldMergePixelShader: {
  69232. name: string;
  69233. shader: string;
  69234. };
  69235. }
  69236. declare module BABYLON {
  69237. /**
  69238. * Options to be set when merging outputs from the default pipeline.
  69239. */
  69240. export class DepthOfFieldMergePostProcessOptions {
  69241. /**
  69242. * The original image to merge on top of
  69243. */
  69244. originalFromInput: PostProcess;
  69245. /**
  69246. * Parameters to perform the merge of the depth of field effect
  69247. */
  69248. depthOfField?: {
  69249. circleOfConfusion: PostProcess;
  69250. blurSteps: Array<PostProcess>;
  69251. };
  69252. /**
  69253. * Parameters to perform the merge of bloom effect
  69254. */
  69255. bloom?: {
  69256. blurred: PostProcess;
  69257. weight: number;
  69258. };
  69259. }
  69260. /**
  69261. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69262. */
  69263. export class DepthOfFieldMergePostProcess extends PostProcess {
  69264. private blurSteps;
  69265. /**
  69266. * Gets a string identifying the name of the class
  69267. * @returns "DepthOfFieldMergePostProcess" string
  69268. */
  69269. getClassName(): string;
  69270. /**
  69271. * Creates a new instance of DepthOfFieldMergePostProcess
  69272. * @param name The name of the effect.
  69273. * @param originalFromInput Post process which's input will be used for the merge.
  69274. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  69275. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  69276. * @param options The required width/height ratio to downsize to before computing the render pass.
  69277. * @param camera The camera to apply the render pass to.
  69278. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69279. * @param engine The engine which the post process will be applied. (default: current engine)
  69280. * @param reusable If the post process can be reused on the same frame. (default: false)
  69281. * @param textureType Type of textures used when performing the post process. (default: 0)
  69282. * @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)
  69283. */
  69284. 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);
  69285. /**
  69286. * Updates the effect with the current post process compile time values and recompiles the shader.
  69287. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69288. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69289. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69290. * @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
  69291. * @param onCompiled Called when the shader has been compiled.
  69292. * @param onError Called if there is an error when compiling a shader.
  69293. */
  69294. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69295. }
  69296. }
  69297. declare module BABYLON {
  69298. /**
  69299. * Specifies the level of max blur that should be applied when using the depth of field effect
  69300. */
  69301. export enum DepthOfFieldEffectBlurLevel {
  69302. /**
  69303. * Subtle blur
  69304. */
  69305. Low = 0,
  69306. /**
  69307. * Medium blur
  69308. */
  69309. Medium = 1,
  69310. /**
  69311. * Large blur
  69312. */
  69313. High = 2
  69314. }
  69315. /**
  69316. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  69317. */
  69318. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  69319. private _circleOfConfusion;
  69320. /**
  69321. * @hidden Internal, blurs from high to low
  69322. */
  69323. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  69324. private _depthOfFieldBlurY;
  69325. private _dofMerge;
  69326. /**
  69327. * @hidden Internal post processes in depth of field effect
  69328. */
  69329. _effects: Array<PostProcess>;
  69330. /**
  69331. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  69332. */
  69333. set focalLength(value: number);
  69334. get focalLength(): number;
  69335. /**
  69336. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69337. */
  69338. set fStop(value: number);
  69339. get fStop(): number;
  69340. /**
  69341. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69342. */
  69343. set focusDistance(value: number);
  69344. get focusDistance(): number;
  69345. /**
  69346. * 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.
  69347. */
  69348. set lensSize(value: number);
  69349. get lensSize(): number;
  69350. /**
  69351. * Creates a new instance DepthOfFieldEffect
  69352. * @param scene The scene the effect belongs to.
  69353. * @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.
  69354. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69355. * @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)
  69356. */
  69357. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  69358. /**
  69359. * Get the current class name of the current effet
  69360. * @returns "DepthOfFieldEffect"
  69361. */
  69362. getClassName(): string;
  69363. /**
  69364. * 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.
  69365. */
  69366. set depthTexture(value: RenderTargetTexture);
  69367. /**
  69368. * Disposes each of the internal effects for a given camera.
  69369. * @param camera The camera to dispose the effect on.
  69370. */
  69371. disposeEffects(camera: Camera): void;
  69372. /**
  69373. * @hidden Internal
  69374. */
  69375. _updateEffects(): void;
  69376. /**
  69377. * Internal
  69378. * @returns if all the contained post processes are ready.
  69379. * @hidden
  69380. */
  69381. _isReady(): boolean;
  69382. }
  69383. }
  69384. declare module BABYLON {
  69385. /** @hidden */
  69386. export var displayPassPixelShader: {
  69387. name: string;
  69388. shader: string;
  69389. };
  69390. }
  69391. declare module BABYLON {
  69392. /**
  69393. * DisplayPassPostProcess which produces an output the same as it's input
  69394. */
  69395. export class DisplayPassPostProcess extends PostProcess {
  69396. /**
  69397. * Gets a string identifying the name of the class
  69398. * @returns "DisplayPassPostProcess" string
  69399. */
  69400. getClassName(): string;
  69401. /**
  69402. * Creates the DisplayPassPostProcess
  69403. * @param name The name of the effect.
  69404. * @param options The required width/height ratio to downsize to before computing the render pass.
  69405. * @param camera The camera to apply the render pass to.
  69406. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69407. * @param engine The engine which the post process will be applied. (default: current engine)
  69408. * @param reusable If the post process can be reused on the same frame. (default: false)
  69409. */
  69410. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69411. /** @hidden */
  69412. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  69413. }
  69414. }
  69415. declare module BABYLON {
  69416. /** @hidden */
  69417. export var filterPixelShader: {
  69418. name: string;
  69419. shader: string;
  69420. };
  69421. }
  69422. declare module BABYLON {
  69423. /**
  69424. * Applies a kernel filter to the image
  69425. */
  69426. export class FilterPostProcess extends PostProcess {
  69427. /** The matrix to be applied to the image */
  69428. kernelMatrix: Matrix;
  69429. /**
  69430. * Gets a string identifying the name of the class
  69431. * @returns "FilterPostProcess" string
  69432. */
  69433. getClassName(): string;
  69434. /**
  69435. *
  69436. * @param name The name of the effect.
  69437. * @param kernelMatrix The matrix to be applied to the image
  69438. * @param options The required width/height ratio to downsize to before computing the render pass.
  69439. * @param camera The camera to apply the render pass to.
  69440. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69441. * @param engine The engine which the post process will be applied. (default: current engine)
  69442. * @param reusable If the post process can be reused on the same frame. (default: false)
  69443. */
  69444. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69445. /** @hidden */
  69446. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  69447. }
  69448. }
  69449. declare module BABYLON {
  69450. /** @hidden */
  69451. export var fxaaPixelShader: {
  69452. name: string;
  69453. shader: string;
  69454. };
  69455. }
  69456. declare module BABYLON {
  69457. /** @hidden */
  69458. export var fxaaVertexShader: {
  69459. name: string;
  69460. shader: string;
  69461. };
  69462. }
  69463. declare module BABYLON {
  69464. /**
  69465. * Fxaa post process
  69466. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  69467. */
  69468. export class FxaaPostProcess extends PostProcess {
  69469. /**
  69470. * Gets a string identifying the name of the class
  69471. * @returns "FxaaPostProcess" string
  69472. */
  69473. getClassName(): string;
  69474. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69475. private _getDefines;
  69476. /** @hidden */
  69477. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  69478. }
  69479. }
  69480. declare module BABYLON {
  69481. /** @hidden */
  69482. export var grainPixelShader: {
  69483. name: string;
  69484. shader: string;
  69485. };
  69486. }
  69487. declare module BABYLON {
  69488. /**
  69489. * The GrainPostProcess adds noise to the image at mid luminance levels
  69490. */
  69491. export class GrainPostProcess extends PostProcess {
  69492. /**
  69493. * The intensity of the grain added (default: 30)
  69494. */
  69495. intensity: number;
  69496. /**
  69497. * If the grain should be randomized on every frame
  69498. */
  69499. animated: boolean;
  69500. /**
  69501. * Gets a string identifying the name of the class
  69502. * @returns "GrainPostProcess" string
  69503. */
  69504. getClassName(): string;
  69505. /**
  69506. * Creates a new instance of @see GrainPostProcess
  69507. * @param name The name of the effect.
  69508. * @param options The required width/height ratio to downsize to before computing the render pass.
  69509. * @param camera The camera to apply the render pass to.
  69510. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69511. * @param engine The engine which the post process will be applied. (default: current engine)
  69512. * @param reusable If the post process can be reused on the same frame. (default: false)
  69513. * @param textureType Type of textures used when performing the post process. (default: 0)
  69514. * @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)
  69515. */
  69516. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69517. /** @hidden */
  69518. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  69519. }
  69520. }
  69521. declare module BABYLON {
  69522. /** @hidden */
  69523. export var highlightsPixelShader: {
  69524. name: string;
  69525. shader: string;
  69526. };
  69527. }
  69528. declare module BABYLON {
  69529. /**
  69530. * Extracts highlights from the image
  69531. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69532. */
  69533. export class HighlightsPostProcess extends PostProcess {
  69534. /**
  69535. * Gets a string identifying the name of the class
  69536. * @returns "HighlightsPostProcess" string
  69537. */
  69538. getClassName(): string;
  69539. /**
  69540. * Extracts highlights from the image
  69541. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69542. * @param name The name of the effect.
  69543. * @param options The required width/height ratio to downsize to before computing the render pass.
  69544. * @param camera The camera to apply the render pass to.
  69545. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69546. * @param engine The engine which the post process will be applied. (default: current engine)
  69547. * @param reusable If the post process can be reused on the same frame. (default: false)
  69548. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  69549. */
  69550. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69551. }
  69552. }
  69553. declare module BABYLON {
  69554. /** @hidden */
  69555. export var mrtFragmentDeclaration: {
  69556. name: string;
  69557. shader: string;
  69558. };
  69559. }
  69560. declare module BABYLON {
  69561. /** @hidden */
  69562. export var geometryPixelShader: {
  69563. name: string;
  69564. shader: string;
  69565. };
  69566. }
  69567. declare module BABYLON {
  69568. /** @hidden */
  69569. export var geometryVertexShader: {
  69570. name: string;
  69571. shader: string;
  69572. };
  69573. }
  69574. declare module BABYLON {
  69575. /** @hidden */
  69576. interface ISavedTransformationMatrix {
  69577. world: Matrix;
  69578. viewProjection: Matrix;
  69579. }
  69580. /**
  69581. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  69582. */
  69583. export class GeometryBufferRenderer {
  69584. /**
  69585. * Constant used to retrieve the position texture index in the G-Buffer textures array
  69586. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  69587. */
  69588. static readonly POSITION_TEXTURE_TYPE: number;
  69589. /**
  69590. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  69591. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  69592. */
  69593. static readonly VELOCITY_TEXTURE_TYPE: number;
  69594. /**
  69595. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  69596. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  69597. */
  69598. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  69599. /**
  69600. * Dictionary used to store the previous transformation matrices of each rendered mesh
  69601. * in order to compute objects velocities when enableVelocity is set to "true"
  69602. * @hidden
  69603. */
  69604. _previousTransformationMatrices: {
  69605. [index: number]: ISavedTransformationMatrix;
  69606. };
  69607. /**
  69608. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  69609. * in order to compute objects velocities when enableVelocity is set to "true"
  69610. * @hidden
  69611. */
  69612. _previousBonesTransformationMatrices: {
  69613. [index: number]: Float32Array;
  69614. };
  69615. /**
  69616. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  69617. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  69618. */
  69619. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  69620. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  69621. renderTransparentMeshes: boolean;
  69622. private _scene;
  69623. private _resizeObserver;
  69624. private _multiRenderTarget;
  69625. private _ratio;
  69626. private _enablePosition;
  69627. private _enableVelocity;
  69628. private _enableReflectivity;
  69629. private _positionIndex;
  69630. private _velocityIndex;
  69631. private _reflectivityIndex;
  69632. protected _effect: Effect;
  69633. protected _cachedDefines: string;
  69634. /**
  69635. * Set the render list (meshes to be rendered) used in the G buffer.
  69636. */
  69637. set renderList(meshes: Mesh[]);
  69638. /**
  69639. * Gets wether or not G buffer are supported by the running hardware.
  69640. * This requires draw buffer supports
  69641. */
  69642. get isSupported(): boolean;
  69643. /**
  69644. * Returns the index of the given texture type in the G-Buffer textures array
  69645. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  69646. * @returns the index of the given texture type in the G-Buffer textures array
  69647. */
  69648. getTextureIndex(textureType: number): number;
  69649. /**
  69650. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  69651. */
  69652. get enablePosition(): boolean;
  69653. /**
  69654. * Sets whether or not objects positions are enabled for the G buffer.
  69655. */
  69656. set enablePosition(enable: boolean);
  69657. /**
  69658. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  69659. */
  69660. get enableVelocity(): boolean;
  69661. /**
  69662. * Sets wether or not objects velocities are enabled for the G buffer.
  69663. */
  69664. set enableVelocity(enable: boolean);
  69665. /**
  69666. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  69667. */
  69668. get enableReflectivity(): boolean;
  69669. /**
  69670. * Sets wether or not objects roughness are enabled for the G buffer.
  69671. */
  69672. set enableReflectivity(enable: boolean);
  69673. /**
  69674. * Gets the scene associated with the buffer.
  69675. */
  69676. get scene(): Scene;
  69677. /**
  69678. * Gets the ratio used by the buffer during its creation.
  69679. * How big is the buffer related to the main canvas.
  69680. */
  69681. get ratio(): number;
  69682. /** @hidden */
  69683. static _SceneComponentInitialization: (scene: Scene) => void;
  69684. /**
  69685. * Creates a new G Buffer for the scene
  69686. * @param scene The scene the buffer belongs to
  69687. * @param ratio How big is the buffer related to the main canvas.
  69688. */
  69689. constructor(scene: Scene, ratio?: number);
  69690. /**
  69691. * Checks wether everything is ready to render a submesh to the G buffer.
  69692. * @param subMesh the submesh to check readiness for
  69693. * @param useInstances is the mesh drawn using instance or not
  69694. * @returns true if ready otherwise false
  69695. */
  69696. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69697. /**
  69698. * Gets the current underlying G Buffer.
  69699. * @returns the buffer
  69700. */
  69701. getGBuffer(): MultiRenderTarget;
  69702. /**
  69703. * Gets the number of samples used to render the buffer (anti aliasing).
  69704. */
  69705. get samples(): number;
  69706. /**
  69707. * Sets the number of samples used to render the buffer (anti aliasing).
  69708. */
  69709. set samples(value: number);
  69710. /**
  69711. * Disposes the renderer and frees up associated resources.
  69712. */
  69713. dispose(): void;
  69714. protected _createRenderTargets(): void;
  69715. private _copyBonesTransformationMatrices;
  69716. }
  69717. }
  69718. declare module BABYLON {
  69719. interface Scene {
  69720. /** @hidden (Backing field) */
  69721. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69722. /**
  69723. * Gets or Sets the current geometry buffer associated to the scene.
  69724. */
  69725. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69726. /**
  69727. * Enables a GeometryBufferRender and associates it with the scene
  69728. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  69729. * @returns the GeometryBufferRenderer
  69730. */
  69731. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  69732. /**
  69733. * Disables the GeometryBufferRender associated with the scene
  69734. */
  69735. disableGeometryBufferRenderer(): void;
  69736. }
  69737. /**
  69738. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  69739. * in several rendering techniques.
  69740. */
  69741. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  69742. /**
  69743. * The component name helpful to identify the component in the list of scene components.
  69744. */
  69745. readonly name: string;
  69746. /**
  69747. * The scene the component belongs to.
  69748. */
  69749. scene: Scene;
  69750. /**
  69751. * Creates a new instance of the component for the given scene
  69752. * @param scene Defines the scene to register the component in
  69753. */
  69754. constructor(scene: Scene);
  69755. /**
  69756. * Registers the component in a given scene
  69757. */
  69758. register(): void;
  69759. /**
  69760. * Rebuilds the elements related to this component in case of
  69761. * context lost for instance.
  69762. */
  69763. rebuild(): void;
  69764. /**
  69765. * Disposes the component and the associated ressources
  69766. */
  69767. dispose(): void;
  69768. private _gatherRenderTargets;
  69769. }
  69770. }
  69771. declare module BABYLON {
  69772. /** @hidden */
  69773. export var motionBlurPixelShader: {
  69774. name: string;
  69775. shader: string;
  69776. };
  69777. }
  69778. declare module BABYLON {
  69779. /**
  69780. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  69781. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  69782. * As an example, all you have to do is to create the post-process:
  69783. * var mb = new BABYLON.MotionBlurPostProcess(
  69784. * 'mb', // The name of the effect.
  69785. * scene, // The scene containing the objects to blur according to their velocity.
  69786. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  69787. * camera // The camera to apply the render pass to.
  69788. * );
  69789. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  69790. */
  69791. export class MotionBlurPostProcess extends PostProcess {
  69792. /**
  69793. * Defines how much the image is blurred by the movement. Default value is equal to 1
  69794. */
  69795. motionStrength: number;
  69796. /**
  69797. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  69798. */
  69799. get motionBlurSamples(): number;
  69800. /**
  69801. * Sets the number of iterations to be used for motion blur quality
  69802. */
  69803. set motionBlurSamples(samples: number);
  69804. private _motionBlurSamples;
  69805. private _geometryBufferRenderer;
  69806. /**
  69807. * Gets a string identifying the name of the class
  69808. * @returns "MotionBlurPostProcess" string
  69809. */
  69810. getClassName(): string;
  69811. /**
  69812. * Creates a new instance MotionBlurPostProcess
  69813. * @param name The name of the effect.
  69814. * @param scene The scene containing the objects to blur according to their velocity.
  69815. * @param options The required width/height ratio to downsize to before computing the render pass.
  69816. * @param camera The camera to apply the render pass to.
  69817. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69818. * @param engine The engine which the post process will be applied. (default: current engine)
  69819. * @param reusable If the post process can be reused on the same frame. (default: false)
  69820. * @param textureType Type of textures used when performing the post process. (default: 0)
  69821. * @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)
  69822. */
  69823. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69824. /**
  69825. * Excludes the given skinned mesh from computing bones velocities.
  69826. * 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.
  69827. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  69828. */
  69829. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69830. /**
  69831. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  69832. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  69833. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  69834. */
  69835. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69836. /**
  69837. * Disposes the post process.
  69838. * @param camera The camera to dispose the post process on.
  69839. */
  69840. dispose(camera?: Camera): void;
  69841. /** @hidden */
  69842. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  69843. }
  69844. }
  69845. declare module BABYLON {
  69846. /** @hidden */
  69847. export var refractionPixelShader: {
  69848. name: string;
  69849. shader: string;
  69850. };
  69851. }
  69852. declare module BABYLON {
  69853. /**
  69854. * Post process which applies a refractin texture
  69855. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69856. */
  69857. export class RefractionPostProcess extends PostProcess {
  69858. private _refTexture;
  69859. private _ownRefractionTexture;
  69860. /** the base color of the refraction (used to taint the rendering) */
  69861. color: Color3;
  69862. /** simulated refraction depth */
  69863. depth: number;
  69864. /** the coefficient of the base color (0 to remove base color tainting) */
  69865. colorLevel: number;
  69866. /** Gets the url used to load the refraction texture */
  69867. refractionTextureUrl: string;
  69868. /**
  69869. * Gets or sets the refraction texture
  69870. * Please note that you are responsible for disposing the texture if you set it manually
  69871. */
  69872. get refractionTexture(): Texture;
  69873. set refractionTexture(value: Texture);
  69874. /**
  69875. * Gets a string identifying the name of the class
  69876. * @returns "RefractionPostProcess" string
  69877. */
  69878. getClassName(): string;
  69879. /**
  69880. * Initializes the RefractionPostProcess
  69881. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69882. * @param name The name of the effect.
  69883. * @param refractionTextureUrl Url of the refraction texture to use
  69884. * @param color the base color of the refraction (used to taint the rendering)
  69885. * @param depth simulated refraction depth
  69886. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  69887. * @param camera The camera to apply the render pass to.
  69888. * @param options The required width/height ratio to downsize to before computing the render pass.
  69889. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69890. * @param engine The engine which the post process will be applied. (default: current engine)
  69891. * @param reusable If the post process can be reused on the same frame. (default: false)
  69892. */
  69893. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69894. /**
  69895. * Disposes of the post process
  69896. * @param camera Camera to dispose post process on
  69897. */
  69898. dispose(camera: Camera): void;
  69899. /** @hidden */
  69900. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  69901. }
  69902. }
  69903. declare module BABYLON {
  69904. /** @hidden */
  69905. export var sharpenPixelShader: {
  69906. name: string;
  69907. shader: string;
  69908. };
  69909. }
  69910. declare module BABYLON {
  69911. /**
  69912. * The SharpenPostProcess applies a sharpen kernel to every pixel
  69913. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69914. */
  69915. export class SharpenPostProcess extends PostProcess {
  69916. /**
  69917. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  69918. */
  69919. colorAmount: number;
  69920. /**
  69921. * How much sharpness should be applied (default: 0.3)
  69922. */
  69923. edgeAmount: number;
  69924. /**
  69925. * Gets a string identifying the name of the class
  69926. * @returns "SharpenPostProcess" string
  69927. */
  69928. getClassName(): string;
  69929. /**
  69930. * Creates a new instance ConvolutionPostProcess
  69931. * @param name The name of the effect.
  69932. * @param options The required width/height ratio to downsize to before computing the render pass.
  69933. * @param camera The camera to apply the render pass to.
  69934. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69935. * @param engine The engine which the post process will be applied. (default: current engine)
  69936. * @param reusable If the post process can be reused on the same frame. (default: false)
  69937. * @param textureType Type of textures used when performing the post process. (default: 0)
  69938. * @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)
  69939. */
  69940. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69941. /** @hidden */
  69942. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  69943. }
  69944. }
  69945. declare module BABYLON {
  69946. /**
  69947. * PostProcessRenderPipeline
  69948. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69949. */
  69950. export class PostProcessRenderPipeline {
  69951. private engine;
  69952. private _renderEffects;
  69953. private _renderEffectsForIsolatedPass;
  69954. /**
  69955. * List of inspectable custom properties (used by the Inspector)
  69956. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  69957. */
  69958. inspectableCustomProperties: IInspectable[];
  69959. /**
  69960. * @hidden
  69961. */
  69962. protected _cameras: Camera[];
  69963. /** @hidden */
  69964. _name: string;
  69965. /**
  69966. * Gets pipeline name
  69967. */
  69968. get name(): string;
  69969. /** Gets the list of attached cameras */
  69970. get cameras(): Camera[];
  69971. /**
  69972. * Initializes a PostProcessRenderPipeline
  69973. * @param engine engine to add the pipeline to
  69974. * @param name name of the pipeline
  69975. */
  69976. constructor(engine: Engine, name: string);
  69977. /**
  69978. * Gets the class name
  69979. * @returns "PostProcessRenderPipeline"
  69980. */
  69981. getClassName(): string;
  69982. /**
  69983. * If all the render effects in the pipeline are supported
  69984. */
  69985. get isSupported(): boolean;
  69986. /**
  69987. * Adds an effect to the pipeline
  69988. * @param renderEffect the effect to add
  69989. */
  69990. addEffect(renderEffect: PostProcessRenderEffect): void;
  69991. /** @hidden */
  69992. _rebuild(): void;
  69993. /** @hidden */
  69994. _enableEffect(renderEffectName: string, cameras: Camera): void;
  69995. /** @hidden */
  69996. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  69997. /** @hidden */
  69998. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69999. /** @hidden */
  70000. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70001. /** @hidden */
  70002. _attachCameras(cameras: Camera, unique: boolean): void;
  70003. /** @hidden */
  70004. _attachCameras(cameras: Camera[], unique: boolean): void;
  70005. /** @hidden */
  70006. _detachCameras(cameras: Camera): void;
  70007. /** @hidden */
  70008. _detachCameras(cameras: Nullable<Camera[]>): void;
  70009. /** @hidden */
  70010. _update(): void;
  70011. /** @hidden */
  70012. _reset(): void;
  70013. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  70014. /**
  70015. * Sets the required values to the prepass renderer.
  70016. * @param prePassRenderer defines the prepass renderer to setup.
  70017. * @returns true if the pre pass is needed.
  70018. */
  70019. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70020. /**
  70021. * Disposes of the pipeline
  70022. */
  70023. dispose(): void;
  70024. }
  70025. }
  70026. declare module BABYLON {
  70027. /**
  70028. * PostProcessRenderPipelineManager class
  70029. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70030. */
  70031. export class PostProcessRenderPipelineManager {
  70032. private _renderPipelines;
  70033. /**
  70034. * Initializes a PostProcessRenderPipelineManager
  70035. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70036. */
  70037. constructor();
  70038. /**
  70039. * Gets the list of supported render pipelines
  70040. */
  70041. get supportedPipelines(): PostProcessRenderPipeline[];
  70042. /**
  70043. * Adds a pipeline to the manager
  70044. * @param renderPipeline The pipeline to add
  70045. */
  70046. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  70047. /**
  70048. * Attaches a camera to the pipeline
  70049. * @param renderPipelineName The name of the pipeline to attach to
  70050. * @param cameras the camera to attach
  70051. * @param unique if the camera can be attached multiple times to the pipeline
  70052. */
  70053. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  70054. /**
  70055. * Detaches a camera from the pipeline
  70056. * @param renderPipelineName The name of the pipeline to detach from
  70057. * @param cameras the camera to detach
  70058. */
  70059. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  70060. /**
  70061. * Enables an effect by name on a pipeline
  70062. * @param renderPipelineName the name of the pipeline to enable the effect in
  70063. * @param renderEffectName the name of the effect to enable
  70064. * @param cameras the cameras that the effect should be enabled on
  70065. */
  70066. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70067. /**
  70068. * Disables an effect by name on a pipeline
  70069. * @param renderPipelineName the name of the pipeline to disable the effect in
  70070. * @param renderEffectName the name of the effect to disable
  70071. * @param cameras the cameras that the effect should be disabled on
  70072. */
  70073. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70074. /**
  70075. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  70076. */
  70077. update(): void;
  70078. /** @hidden */
  70079. _rebuild(): void;
  70080. /**
  70081. * Disposes of the manager and pipelines
  70082. */
  70083. dispose(): void;
  70084. }
  70085. }
  70086. declare module BABYLON {
  70087. interface Scene {
  70088. /** @hidden (Backing field) */
  70089. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70090. /**
  70091. * Gets the postprocess render pipeline manager
  70092. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70093. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70094. */
  70095. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70096. }
  70097. /**
  70098. * Defines the Render Pipeline scene component responsible to rendering pipelines
  70099. */
  70100. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  70101. /**
  70102. * The component name helpfull to identify the component in the list of scene components.
  70103. */
  70104. readonly name: string;
  70105. /**
  70106. * The scene the component belongs to.
  70107. */
  70108. scene: Scene;
  70109. /**
  70110. * Creates a new instance of the component for the given scene
  70111. * @param scene Defines the scene to register the component in
  70112. */
  70113. constructor(scene: Scene);
  70114. /**
  70115. * Registers the component in a given scene
  70116. */
  70117. register(): void;
  70118. /**
  70119. * Rebuilds the elements related to this component in case of
  70120. * context lost for instance.
  70121. */
  70122. rebuild(): void;
  70123. /**
  70124. * Disposes the component and the associated ressources
  70125. */
  70126. dispose(): void;
  70127. private _gatherRenderTargets;
  70128. }
  70129. }
  70130. declare module BABYLON {
  70131. /**
  70132. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  70133. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70134. */
  70135. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70136. private _scene;
  70137. private _camerasToBeAttached;
  70138. /**
  70139. * ID of the sharpen post process,
  70140. */
  70141. private readonly SharpenPostProcessId;
  70142. /**
  70143. * @ignore
  70144. * ID of the image processing post process;
  70145. */
  70146. readonly ImageProcessingPostProcessId: string;
  70147. /**
  70148. * @ignore
  70149. * ID of the Fast Approximate Anti-Aliasing post process;
  70150. */
  70151. readonly FxaaPostProcessId: string;
  70152. /**
  70153. * ID of the chromatic aberration post process,
  70154. */
  70155. private readonly ChromaticAberrationPostProcessId;
  70156. /**
  70157. * ID of the grain post process
  70158. */
  70159. private readonly GrainPostProcessId;
  70160. /**
  70161. * Sharpen post process which will apply a sharpen convolution to enhance edges
  70162. */
  70163. sharpen: SharpenPostProcess;
  70164. private _sharpenEffect;
  70165. private bloom;
  70166. /**
  70167. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  70168. */
  70169. depthOfField: DepthOfFieldEffect;
  70170. /**
  70171. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70172. */
  70173. fxaa: FxaaPostProcess;
  70174. /**
  70175. * Image post processing pass used to perform operations such as tone mapping or color grading.
  70176. */
  70177. imageProcessing: ImageProcessingPostProcess;
  70178. /**
  70179. * Chromatic aberration post process which will shift rgb colors in the image
  70180. */
  70181. chromaticAberration: ChromaticAberrationPostProcess;
  70182. private _chromaticAberrationEffect;
  70183. /**
  70184. * Grain post process which add noise to the image
  70185. */
  70186. grain: GrainPostProcess;
  70187. private _grainEffect;
  70188. /**
  70189. * Glow post process which adds a glow to emissive areas of the image
  70190. */
  70191. private _glowLayer;
  70192. /**
  70193. * Animations which can be used to tweak settings over a period of time
  70194. */
  70195. animations: Animation[];
  70196. private _imageProcessingConfigurationObserver;
  70197. private _sharpenEnabled;
  70198. private _bloomEnabled;
  70199. private _depthOfFieldEnabled;
  70200. private _depthOfFieldBlurLevel;
  70201. private _fxaaEnabled;
  70202. private _imageProcessingEnabled;
  70203. private _defaultPipelineTextureType;
  70204. private _bloomScale;
  70205. private _chromaticAberrationEnabled;
  70206. private _grainEnabled;
  70207. private _buildAllowed;
  70208. /**
  70209. * Gets active scene
  70210. */
  70211. get scene(): Scene;
  70212. /**
  70213. * Enable or disable the sharpen process from the pipeline
  70214. */
  70215. set sharpenEnabled(enabled: boolean);
  70216. get sharpenEnabled(): boolean;
  70217. private _resizeObserver;
  70218. private _hardwareScaleLevel;
  70219. private _bloomKernel;
  70220. /**
  70221. * Specifies the size of the bloom blur kernel, relative to the final output size
  70222. */
  70223. get bloomKernel(): number;
  70224. set bloomKernel(value: number);
  70225. /**
  70226. * Specifies the weight of the bloom in the final rendering
  70227. */
  70228. private _bloomWeight;
  70229. /**
  70230. * Specifies the luma threshold for the area that will be blurred by the bloom
  70231. */
  70232. private _bloomThreshold;
  70233. private _hdr;
  70234. /**
  70235. * The strength of the bloom.
  70236. */
  70237. set bloomWeight(value: number);
  70238. get bloomWeight(): number;
  70239. /**
  70240. * The strength of the bloom.
  70241. */
  70242. set bloomThreshold(value: number);
  70243. get bloomThreshold(): number;
  70244. /**
  70245. * The scale of the bloom, lower value will provide better performance.
  70246. */
  70247. set bloomScale(value: number);
  70248. get bloomScale(): number;
  70249. /**
  70250. * Enable or disable the bloom from the pipeline
  70251. */
  70252. set bloomEnabled(enabled: boolean);
  70253. get bloomEnabled(): boolean;
  70254. private _rebuildBloom;
  70255. /**
  70256. * If the depth of field is enabled.
  70257. */
  70258. get depthOfFieldEnabled(): boolean;
  70259. set depthOfFieldEnabled(enabled: boolean);
  70260. /**
  70261. * Blur level of the depth of field effect. (Higher blur will effect performance)
  70262. */
  70263. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  70264. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  70265. /**
  70266. * If the anti aliasing is enabled.
  70267. */
  70268. set fxaaEnabled(enabled: boolean);
  70269. get fxaaEnabled(): boolean;
  70270. private _samples;
  70271. /**
  70272. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70273. */
  70274. set samples(sampleCount: number);
  70275. get samples(): number;
  70276. /**
  70277. * If image processing is enabled.
  70278. */
  70279. set imageProcessingEnabled(enabled: boolean);
  70280. get imageProcessingEnabled(): boolean;
  70281. /**
  70282. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  70283. */
  70284. set glowLayerEnabled(enabled: boolean);
  70285. get glowLayerEnabled(): boolean;
  70286. /**
  70287. * Gets the glow layer (or null if not defined)
  70288. */
  70289. get glowLayer(): Nullable<GlowLayer>;
  70290. /**
  70291. * Enable or disable the chromaticAberration process from the pipeline
  70292. */
  70293. set chromaticAberrationEnabled(enabled: boolean);
  70294. get chromaticAberrationEnabled(): boolean;
  70295. /**
  70296. * Enable or disable the grain process from the pipeline
  70297. */
  70298. set grainEnabled(enabled: boolean);
  70299. get grainEnabled(): boolean;
  70300. /**
  70301. * @constructor
  70302. * @param name - The rendering pipeline name (default: "")
  70303. * @param hdr - If high dynamic range textures should be used (default: true)
  70304. * @param scene - The scene linked to this pipeline (default: the last created scene)
  70305. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  70306. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  70307. */
  70308. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  70309. /**
  70310. * Get the class name
  70311. * @returns "DefaultRenderingPipeline"
  70312. */
  70313. getClassName(): string;
  70314. /**
  70315. * Force the compilation of the entire pipeline.
  70316. */
  70317. prepare(): void;
  70318. private _hasCleared;
  70319. private _prevPostProcess;
  70320. private _prevPrevPostProcess;
  70321. private _setAutoClearAndTextureSharing;
  70322. private _depthOfFieldSceneObserver;
  70323. private _buildPipeline;
  70324. private _disposePostProcesses;
  70325. /**
  70326. * Adds a camera to the pipeline
  70327. * @param camera the camera to be added
  70328. */
  70329. addCamera(camera: Camera): void;
  70330. /**
  70331. * Removes a camera from the pipeline
  70332. * @param camera the camera to remove
  70333. */
  70334. removeCamera(camera: Camera): void;
  70335. /**
  70336. * Dispose of the pipeline and stop all post processes
  70337. */
  70338. dispose(): void;
  70339. /**
  70340. * Serialize the rendering pipeline (Used when exporting)
  70341. * @returns the serialized object
  70342. */
  70343. serialize(): any;
  70344. /**
  70345. * Parse the serialized pipeline
  70346. * @param source Source pipeline.
  70347. * @param scene The scene to load the pipeline to.
  70348. * @param rootUrl The URL of the serialized pipeline.
  70349. * @returns An instantiated pipeline from the serialized object.
  70350. */
  70351. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  70352. }
  70353. }
  70354. declare module BABYLON {
  70355. /** @hidden */
  70356. export var lensHighlightsPixelShader: {
  70357. name: string;
  70358. shader: string;
  70359. };
  70360. }
  70361. declare module BABYLON {
  70362. /** @hidden */
  70363. export var depthOfFieldPixelShader: {
  70364. name: string;
  70365. shader: string;
  70366. };
  70367. }
  70368. declare module BABYLON {
  70369. /**
  70370. * BABYLON.JS Chromatic Aberration GLSL Shader
  70371. * Author: Olivier Guyot
  70372. * Separates very slightly R, G and B colors on the edges of the screen
  70373. * Inspired by Francois Tarlier & Martins Upitis
  70374. */
  70375. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  70376. /**
  70377. * @ignore
  70378. * The chromatic aberration PostProcess id in the pipeline
  70379. */
  70380. LensChromaticAberrationEffect: string;
  70381. /**
  70382. * @ignore
  70383. * The highlights enhancing PostProcess id in the pipeline
  70384. */
  70385. HighlightsEnhancingEffect: string;
  70386. /**
  70387. * @ignore
  70388. * The depth-of-field PostProcess id in the pipeline
  70389. */
  70390. LensDepthOfFieldEffect: string;
  70391. private _scene;
  70392. private _depthTexture;
  70393. private _grainTexture;
  70394. private _chromaticAberrationPostProcess;
  70395. private _highlightsPostProcess;
  70396. private _depthOfFieldPostProcess;
  70397. private _edgeBlur;
  70398. private _grainAmount;
  70399. private _chromaticAberration;
  70400. private _distortion;
  70401. private _highlightsGain;
  70402. private _highlightsThreshold;
  70403. private _dofDistance;
  70404. private _dofAperture;
  70405. private _dofDarken;
  70406. private _dofPentagon;
  70407. private _blurNoise;
  70408. /**
  70409. * @constructor
  70410. *
  70411. * Effect parameters are as follow:
  70412. * {
  70413. * chromatic_aberration: number; // from 0 to x (1 for realism)
  70414. * edge_blur: number; // from 0 to x (1 for realism)
  70415. * distortion: number; // from 0 to x (1 for realism)
  70416. * grain_amount: number; // from 0 to 1
  70417. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  70418. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  70419. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  70420. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  70421. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  70422. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  70423. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  70424. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  70425. * }
  70426. * Note: if an effect parameter is unset, effect is disabled
  70427. *
  70428. * @param name The rendering pipeline name
  70429. * @param parameters - An object containing all parameters (see above)
  70430. * @param scene The scene linked to this pipeline
  70431. * @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)
  70432. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70433. */
  70434. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  70435. /**
  70436. * Get the class name
  70437. * @returns "LensRenderingPipeline"
  70438. */
  70439. getClassName(): string;
  70440. /**
  70441. * Gets associated scene
  70442. */
  70443. get scene(): Scene;
  70444. /**
  70445. * Gets or sets the edge blur
  70446. */
  70447. get edgeBlur(): number;
  70448. set edgeBlur(value: number);
  70449. /**
  70450. * Gets or sets the grain amount
  70451. */
  70452. get grainAmount(): number;
  70453. set grainAmount(value: number);
  70454. /**
  70455. * Gets or sets the chromatic aberration amount
  70456. */
  70457. get chromaticAberration(): number;
  70458. set chromaticAberration(value: number);
  70459. /**
  70460. * Gets or sets the depth of field aperture
  70461. */
  70462. get dofAperture(): number;
  70463. set dofAperture(value: number);
  70464. /**
  70465. * Gets or sets the edge distortion
  70466. */
  70467. get edgeDistortion(): number;
  70468. set edgeDistortion(value: number);
  70469. /**
  70470. * Gets or sets the depth of field distortion
  70471. */
  70472. get dofDistortion(): number;
  70473. set dofDistortion(value: number);
  70474. /**
  70475. * Gets or sets the darken out of focus amount
  70476. */
  70477. get darkenOutOfFocus(): number;
  70478. set darkenOutOfFocus(value: number);
  70479. /**
  70480. * Gets or sets a boolean indicating if blur noise is enabled
  70481. */
  70482. get blurNoise(): boolean;
  70483. set blurNoise(value: boolean);
  70484. /**
  70485. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  70486. */
  70487. get pentagonBokeh(): boolean;
  70488. set pentagonBokeh(value: boolean);
  70489. /**
  70490. * Gets or sets the highlight grain amount
  70491. */
  70492. get highlightsGain(): number;
  70493. set highlightsGain(value: number);
  70494. /**
  70495. * Gets or sets the highlight threshold
  70496. */
  70497. get highlightsThreshold(): number;
  70498. set highlightsThreshold(value: number);
  70499. /**
  70500. * Sets the amount of blur at the edges
  70501. * @param amount blur amount
  70502. */
  70503. setEdgeBlur(amount: number): void;
  70504. /**
  70505. * Sets edge blur to 0
  70506. */
  70507. disableEdgeBlur(): void;
  70508. /**
  70509. * Sets the amout of grain
  70510. * @param amount Amount of grain
  70511. */
  70512. setGrainAmount(amount: number): void;
  70513. /**
  70514. * Set grain amount to 0
  70515. */
  70516. disableGrain(): void;
  70517. /**
  70518. * Sets the chromatic aberration amount
  70519. * @param amount amount of chromatic aberration
  70520. */
  70521. setChromaticAberration(amount: number): void;
  70522. /**
  70523. * Sets chromatic aberration amount to 0
  70524. */
  70525. disableChromaticAberration(): void;
  70526. /**
  70527. * Sets the EdgeDistortion amount
  70528. * @param amount amount of EdgeDistortion
  70529. */
  70530. setEdgeDistortion(amount: number): void;
  70531. /**
  70532. * Sets edge distortion to 0
  70533. */
  70534. disableEdgeDistortion(): void;
  70535. /**
  70536. * Sets the FocusDistance amount
  70537. * @param amount amount of FocusDistance
  70538. */
  70539. setFocusDistance(amount: number): void;
  70540. /**
  70541. * Disables depth of field
  70542. */
  70543. disableDepthOfField(): void;
  70544. /**
  70545. * Sets the Aperture amount
  70546. * @param amount amount of Aperture
  70547. */
  70548. setAperture(amount: number): void;
  70549. /**
  70550. * Sets the DarkenOutOfFocus amount
  70551. * @param amount amount of DarkenOutOfFocus
  70552. */
  70553. setDarkenOutOfFocus(amount: number): void;
  70554. private _pentagonBokehIsEnabled;
  70555. /**
  70556. * Creates a pentagon bokeh effect
  70557. */
  70558. enablePentagonBokeh(): void;
  70559. /**
  70560. * Disables the pentagon bokeh effect
  70561. */
  70562. disablePentagonBokeh(): void;
  70563. /**
  70564. * Enables noise blur
  70565. */
  70566. enableNoiseBlur(): void;
  70567. /**
  70568. * Disables noise blur
  70569. */
  70570. disableNoiseBlur(): void;
  70571. /**
  70572. * Sets the HighlightsGain amount
  70573. * @param amount amount of HighlightsGain
  70574. */
  70575. setHighlightsGain(amount: number): void;
  70576. /**
  70577. * Sets the HighlightsThreshold amount
  70578. * @param amount amount of HighlightsThreshold
  70579. */
  70580. setHighlightsThreshold(amount: number): void;
  70581. /**
  70582. * Disables highlights
  70583. */
  70584. disableHighlights(): void;
  70585. /**
  70586. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  70587. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  70588. */
  70589. dispose(disableDepthRender?: boolean): void;
  70590. private _createChromaticAberrationPostProcess;
  70591. private _createHighlightsPostProcess;
  70592. private _createDepthOfFieldPostProcess;
  70593. private _createGrainTexture;
  70594. }
  70595. }
  70596. declare module BABYLON {
  70597. /** @hidden */
  70598. export var ssao2PixelShader: {
  70599. name: string;
  70600. shader: string;
  70601. };
  70602. }
  70603. declare module BABYLON {
  70604. /** @hidden */
  70605. export var ssaoCombinePixelShader: {
  70606. name: string;
  70607. shader: string;
  70608. };
  70609. }
  70610. declare module BABYLON {
  70611. /**
  70612. * Render pipeline to produce ssao effect
  70613. */
  70614. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  70615. /**
  70616. * @ignore
  70617. * The PassPostProcess id in the pipeline that contains the original scene color
  70618. */
  70619. SSAOOriginalSceneColorEffect: string;
  70620. /**
  70621. * @ignore
  70622. * The SSAO PostProcess id in the pipeline
  70623. */
  70624. SSAORenderEffect: string;
  70625. /**
  70626. * @ignore
  70627. * The horizontal blur PostProcess id in the pipeline
  70628. */
  70629. SSAOBlurHRenderEffect: string;
  70630. /**
  70631. * @ignore
  70632. * The vertical blur PostProcess id in the pipeline
  70633. */
  70634. SSAOBlurVRenderEffect: string;
  70635. /**
  70636. * @ignore
  70637. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70638. */
  70639. SSAOCombineRenderEffect: string;
  70640. /**
  70641. * The output strength of the SSAO post-process. Default value is 1.0.
  70642. */
  70643. totalStrength: number;
  70644. /**
  70645. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  70646. */
  70647. maxZ: number;
  70648. /**
  70649. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  70650. */
  70651. minZAspect: number;
  70652. private _samples;
  70653. /**
  70654. * Number of samples used for the SSAO calculations. Default value is 8
  70655. */
  70656. set samples(n: number);
  70657. get samples(): number;
  70658. private _textureSamples;
  70659. /**
  70660. * Number of samples to use for antialiasing
  70661. */
  70662. set textureSamples(n: number);
  70663. get textureSamples(): number;
  70664. /**
  70665. * Force rendering the geometry through geometry buffer
  70666. */
  70667. private _forceGeometryBuffer;
  70668. /**
  70669. * Ratio object used for SSAO ratio and blur ratio
  70670. */
  70671. private _ratio;
  70672. /**
  70673. * Dynamically generated sphere sampler.
  70674. */
  70675. private _sampleSphere;
  70676. /**
  70677. * Blur filter offsets
  70678. */
  70679. private _samplerOffsets;
  70680. private _expensiveBlur;
  70681. /**
  70682. * If bilateral blur should be used
  70683. */
  70684. set expensiveBlur(b: boolean);
  70685. get expensiveBlur(): boolean;
  70686. /**
  70687. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  70688. */
  70689. radius: number;
  70690. /**
  70691. * The base color of the SSAO post-process
  70692. * The final result is "base + ssao" between [0, 1]
  70693. */
  70694. base: number;
  70695. /**
  70696. * Support test.
  70697. */
  70698. static get IsSupported(): boolean;
  70699. private _scene;
  70700. private _randomTexture;
  70701. private _originalColorPostProcess;
  70702. private _ssaoPostProcess;
  70703. private _blurHPostProcess;
  70704. private _blurVPostProcess;
  70705. private _ssaoCombinePostProcess;
  70706. private _prePassRenderer;
  70707. /**
  70708. * Gets active scene
  70709. */
  70710. get scene(): Scene;
  70711. /**
  70712. * @constructor
  70713. * @param name The rendering pipeline name
  70714. * @param scene The scene linked to this pipeline
  70715. * @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 }
  70716. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70717. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  70718. */
  70719. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  70720. /**
  70721. * Get the class name
  70722. * @returns "SSAO2RenderingPipeline"
  70723. */
  70724. getClassName(): string;
  70725. /**
  70726. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70727. */
  70728. dispose(disableGeometryBufferRenderer?: boolean): void;
  70729. private _createBlurPostProcess;
  70730. /** @hidden */
  70731. _rebuild(): void;
  70732. private _bits;
  70733. private _radicalInverse_VdC;
  70734. private _hammersley;
  70735. private _hemisphereSample_uniform;
  70736. private _generateHemisphere;
  70737. private _getDefinesForSSAO;
  70738. private _createSSAOPostProcess;
  70739. private _createSSAOCombinePostProcess;
  70740. private _createRandomTexture;
  70741. /**
  70742. * Serialize the rendering pipeline (Used when exporting)
  70743. * @returns the serialized object
  70744. */
  70745. serialize(): any;
  70746. /**
  70747. * Parse the serialized pipeline
  70748. * @param source Source pipeline.
  70749. * @param scene The scene to load the pipeline to.
  70750. * @param rootUrl The URL of the serialized pipeline.
  70751. * @returns An instantiated pipeline from the serialized object.
  70752. */
  70753. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  70754. /**
  70755. * Sets the required values to the prepass renderer.
  70756. * @param prePassRenderer defines the prepass renderer to setup
  70757. * @returns true if the pre pass is needed.
  70758. */
  70759. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70760. }
  70761. }
  70762. declare module BABYLON {
  70763. /** @hidden */
  70764. export var ssaoPixelShader: {
  70765. name: string;
  70766. shader: string;
  70767. };
  70768. }
  70769. declare module BABYLON {
  70770. /**
  70771. * Render pipeline to produce ssao effect
  70772. */
  70773. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  70774. /**
  70775. * @ignore
  70776. * The PassPostProcess id in the pipeline that contains the original scene color
  70777. */
  70778. SSAOOriginalSceneColorEffect: string;
  70779. /**
  70780. * @ignore
  70781. * The SSAO PostProcess id in the pipeline
  70782. */
  70783. SSAORenderEffect: string;
  70784. /**
  70785. * @ignore
  70786. * The horizontal blur PostProcess id in the pipeline
  70787. */
  70788. SSAOBlurHRenderEffect: string;
  70789. /**
  70790. * @ignore
  70791. * The vertical blur PostProcess id in the pipeline
  70792. */
  70793. SSAOBlurVRenderEffect: string;
  70794. /**
  70795. * @ignore
  70796. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70797. */
  70798. SSAOCombineRenderEffect: string;
  70799. /**
  70800. * The output strength of the SSAO post-process. Default value is 1.0.
  70801. */
  70802. totalStrength: number;
  70803. /**
  70804. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  70805. */
  70806. radius: number;
  70807. /**
  70808. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  70809. * Must not be equal to fallOff and superior to fallOff.
  70810. * Default value is 0.0075
  70811. */
  70812. area: number;
  70813. /**
  70814. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  70815. * Must not be equal to area and inferior to area.
  70816. * Default value is 0.000001
  70817. */
  70818. fallOff: number;
  70819. /**
  70820. * The base color of the SSAO post-process
  70821. * The final result is "base + ssao" between [0, 1]
  70822. */
  70823. base: number;
  70824. private _scene;
  70825. private _depthTexture;
  70826. private _randomTexture;
  70827. private _originalColorPostProcess;
  70828. private _ssaoPostProcess;
  70829. private _blurHPostProcess;
  70830. private _blurVPostProcess;
  70831. private _ssaoCombinePostProcess;
  70832. private _firstUpdate;
  70833. /**
  70834. * Gets active scene
  70835. */
  70836. get scene(): Scene;
  70837. /**
  70838. * @constructor
  70839. * @param name - The rendering pipeline name
  70840. * @param scene - The scene linked to this pipeline
  70841. * @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 }
  70842. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  70843. */
  70844. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  70845. /**
  70846. * Get the class name
  70847. * @returns "SSAORenderingPipeline"
  70848. */
  70849. getClassName(): string;
  70850. /**
  70851. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70852. */
  70853. dispose(disableDepthRender?: boolean): void;
  70854. private _createBlurPostProcess;
  70855. /** @hidden */
  70856. _rebuild(): void;
  70857. private _createSSAOPostProcess;
  70858. private _createSSAOCombinePostProcess;
  70859. private _createRandomTexture;
  70860. }
  70861. }
  70862. declare module BABYLON {
  70863. /** @hidden */
  70864. export var screenSpaceReflectionPixelShader: {
  70865. name: string;
  70866. shader: string;
  70867. };
  70868. }
  70869. declare module BABYLON {
  70870. /**
  70871. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  70872. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  70873. */
  70874. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  70875. /**
  70876. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  70877. */
  70878. threshold: number;
  70879. /**
  70880. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  70881. */
  70882. strength: number;
  70883. /**
  70884. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  70885. */
  70886. reflectionSpecularFalloffExponent: number;
  70887. /**
  70888. * 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]
  70889. */
  70890. step: number;
  70891. /**
  70892. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  70893. */
  70894. roughnessFactor: number;
  70895. private _geometryBufferRenderer;
  70896. private _enableSmoothReflections;
  70897. private _reflectionSamples;
  70898. private _smoothSteps;
  70899. /**
  70900. * Gets a string identifying the name of the class
  70901. * @returns "ScreenSpaceReflectionPostProcess" string
  70902. */
  70903. getClassName(): string;
  70904. /**
  70905. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  70906. * @param name The name of the effect.
  70907. * @param scene The scene containing the objects to calculate reflections.
  70908. * @param options The required width/height ratio to downsize to before computing the render pass.
  70909. * @param camera The camera to apply the render pass to.
  70910. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70911. * @param engine The engine which the post process will be applied. (default: current engine)
  70912. * @param reusable If the post process can be reused on the same frame. (default: false)
  70913. * @param textureType Type of textures used when performing the post process. (default: 0)
  70914. * @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)
  70915. */
  70916. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70917. /**
  70918. * Gets wether or not smoothing reflections is enabled.
  70919. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70920. */
  70921. get enableSmoothReflections(): boolean;
  70922. /**
  70923. * Sets wether or not smoothing reflections is enabled.
  70924. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70925. */
  70926. set enableSmoothReflections(enabled: boolean);
  70927. /**
  70928. * Gets the number of samples taken while computing reflections. More samples count is high,
  70929. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70930. */
  70931. get reflectionSamples(): number;
  70932. /**
  70933. * Sets the number of samples taken while computing reflections. More samples count is high,
  70934. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70935. */
  70936. set reflectionSamples(samples: number);
  70937. /**
  70938. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  70939. * more the post-process will require GPU power and can generate a drop in FPS.
  70940. * Default value (5.0) work pretty well in all cases but can be adjusted.
  70941. */
  70942. get smoothSteps(): number;
  70943. set smoothSteps(steps: number);
  70944. private _updateEffectDefines;
  70945. /** @hidden */
  70946. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  70947. }
  70948. }
  70949. declare module BABYLON {
  70950. /** @hidden */
  70951. export var standardPixelShader: {
  70952. name: string;
  70953. shader: string;
  70954. };
  70955. }
  70956. declare module BABYLON {
  70957. /**
  70958. * Standard rendering pipeline
  70959. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70960. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  70961. */
  70962. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70963. /**
  70964. * Public members
  70965. */
  70966. /**
  70967. * Post-process which contains the original scene color before the pipeline applies all the effects
  70968. */
  70969. originalPostProcess: Nullable<PostProcess>;
  70970. /**
  70971. * Post-process used to down scale an image x4
  70972. */
  70973. downSampleX4PostProcess: Nullable<PostProcess>;
  70974. /**
  70975. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  70976. */
  70977. brightPassPostProcess: Nullable<PostProcess>;
  70978. /**
  70979. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  70980. */
  70981. blurHPostProcesses: PostProcess[];
  70982. /**
  70983. * Post-process array storing all the vertical blur post-processes used by the pipeline
  70984. */
  70985. blurVPostProcesses: PostProcess[];
  70986. /**
  70987. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  70988. */
  70989. textureAdderPostProcess: Nullable<PostProcess>;
  70990. /**
  70991. * Post-process used to create volumetric lighting effect
  70992. */
  70993. volumetricLightPostProcess: Nullable<PostProcess>;
  70994. /**
  70995. * Post-process used to smooth the previous volumetric light post-process on the X axis
  70996. */
  70997. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  70998. /**
  70999. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  71000. */
  71001. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  71002. /**
  71003. * Post-process used to merge the volumetric light effect and the real scene color
  71004. */
  71005. volumetricLightMergePostProces: Nullable<PostProcess>;
  71006. /**
  71007. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  71008. */
  71009. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  71010. /**
  71011. * Base post-process used to calculate the average luminance of the final image for HDR
  71012. */
  71013. luminancePostProcess: Nullable<PostProcess>;
  71014. /**
  71015. * Post-processes used to create down sample post-processes in order to get
  71016. * the average luminance of the final image for HDR
  71017. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  71018. */
  71019. luminanceDownSamplePostProcesses: PostProcess[];
  71020. /**
  71021. * Post-process used to create a HDR effect (light adaptation)
  71022. */
  71023. hdrPostProcess: Nullable<PostProcess>;
  71024. /**
  71025. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  71026. */
  71027. textureAdderFinalPostProcess: Nullable<PostProcess>;
  71028. /**
  71029. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  71030. */
  71031. lensFlareFinalPostProcess: Nullable<PostProcess>;
  71032. /**
  71033. * Post-process used to merge the final HDR post-process and the real scene color
  71034. */
  71035. hdrFinalPostProcess: Nullable<PostProcess>;
  71036. /**
  71037. * Post-process used to create a lens flare effect
  71038. */
  71039. lensFlarePostProcess: Nullable<PostProcess>;
  71040. /**
  71041. * Post-process that merges the result of the lens flare post-process and the real scene color
  71042. */
  71043. lensFlareComposePostProcess: Nullable<PostProcess>;
  71044. /**
  71045. * Post-process used to create a motion blur effect
  71046. */
  71047. motionBlurPostProcess: Nullable<PostProcess>;
  71048. /**
  71049. * Post-process used to create a depth of field effect
  71050. */
  71051. depthOfFieldPostProcess: Nullable<PostProcess>;
  71052. /**
  71053. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71054. */
  71055. fxaaPostProcess: Nullable<FxaaPostProcess>;
  71056. /**
  71057. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  71058. */
  71059. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  71060. /**
  71061. * Represents the brightness threshold in order to configure the illuminated surfaces
  71062. */
  71063. brightThreshold: number;
  71064. /**
  71065. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  71066. */
  71067. blurWidth: number;
  71068. /**
  71069. * Sets if the blur for highlighted surfaces must be only horizontal
  71070. */
  71071. horizontalBlur: boolean;
  71072. /**
  71073. * Gets the overall exposure used by the pipeline
  71074. */
  71075. get exposure(): number;
  71076. /**
  71077. * Sets the overall exposure used by the pipeline
  71078. */
  71079. set exposure(value: number);
  71080. /**
  71081. * Texture used typically to simulate "dirty" on camera lens
  71082. */
  71083. lensTexture: Nullable<Texture>;
  71084. /**
  71085. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  71086. */
  71087. volumetricLightCoefficient: number;
  71088. /**
  71089. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  71090. */
  71091. volumetricLightPower: number;
  71092. /**
  71093. * Used the set the blur intensity to smooth the volumetric lights
  71094. */
  71095. volumetricLightBlurScale: number;
  71096. /**
  71097. * Light (spot or directional) used to generate the volumetric lights rays
  71098. * The source light must have a shadow generate so the pipeline can get its
  71099. * depth map
  71100. */
  71101. sourceLight: Nullable<SpotLight | DirectionalLight>;
  71102. /**
  71103. * For eye adaptation, represents the minimum luminance the eye can see
  71104. */
  71105. hdrMinimumLuminance: number;
  71106. /**
  71107. * For eye adaptation, represents the decrease luminance speed
  71108. */
  71109. hdrDecreaseRate: number;
  71110. /**
  71111. * For eye adaptation, represents the increase luminance speed
  71112. */
  71113. hdrIncreaseRate: number;
  71114. /**
  71115. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71116. */
  71117. get hdrAutoExposure(): boolean;
  71118. /**
  71119. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71120. */
  71121. set hdrAutoExposure(value: boolean);
  71122. /**
  71123. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  71124. */
  71125. lensColorTexture: Nullable<Texture>;
  71126. /**
  71127. * The overall strengh for the lens flare effect
  71128. */
  71129. lensFlareStrength: number;
  71130. /**
  71131. * Dispersion coefficient for lens flare ghosts
  71132. */
  71133. lensFlareGhostDispersal: number;
  71134. /**
  71135. * Main lens flare halo width
  71136. */
  71137. lensFlareHaloWidth: number;
  71138. /**
  71139. * Based on the lens distortion effect, defines how much the lens flare result
  71140. * is distorted
  71141. */
  71142. lensFlareDistortionStrength: number;
  71143. /**
  71144. * Configures the blur intensity used for for lens flare (halo)
  71145. */
  71146. lensFlareBlurWidth: number;
  71147. /**
  71148. * Lens star texture must be used to simulate rays on the flares and is available
  71149. * in the documentation
  71150. */
  71151. lensStarTexture: Nullable<Texture>;
  71152. /**
  71153. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  71154. * flare effect by taking account of the dirt texture
  71155. */
  71156. lensFlareDirtTexture: Nullable<Texture>;
  71157. /**
  71158. * Represents the focal length for the depth of field effect
  71159. */
  71160. depthOfFieldDistance: number;
  71161. /**
  71162. * Represents the blur intensity for the blurred part of the depth of field effect
  71163. */
  71164. depthOfFieldBlurWidth: number;
  71165. /**
  71166. * Gets how much the image is blurred by the movement while using the motion blur post-process
  71167. */
  71168. get motionStrength(): number;
  71169. /**
  71170. * Sets how much the image is blurred by the movement while using the motion blur post-process
  71171. */
  71172. set motionStrength(strength: number);
  71173. /**
  71174. * Gets wether or not the motion blur post-process is object based or screen based.
  71175. */
  71176. get objectBasedMotionBlur(): boolean;
  71177. /**
  71178. * Sets wether or not the motion blur post-process should be object based or screen based
  71179. */
  71180. set objectBasedMotionBlur(value: boolean);
  71181. /**
  71182. * List of animations for the pipeline (IAnimatable implementation)
  71183. */
  71184. animations: Animation[];
  71185. /**
  71186. * Private members
  71187. */
  71188. private _scene;
  71189. private _currentDepthOfFieldSource;
  71190. private _basePostProcess;
  71191. private _fixedExposure;
  71192. private _currentExposure;
  71193. private _hdrAutoExposure;
  71194. private _hdrCurrentLuminance;
  71195. private _motionStrength;
  71196. private _isObjectBasedMotionBlur;
  71197. private _floatTextureType;
  71198. private _camerasToBeAttached;
  71199. private _ratio;
  71200. private _bloomEnabled;
  71201. private _depthOfFieldEnabled;
  71202. private _vlsEnabled;
  71203. private _lensFlareEnabled;
  71204. private _hdrEnabled;
  71205. private _motionBlurEnabled;
  71206. private _fxaaEnabled;
  71207. private _screenSpaceReflectionsEnabled;
  71208. private _motionBlurSamples;
  71209. private _volumetricLightStepsCount;
  71210. private _samples;
  71211. /**
  71212. * @ignore
  71213. * Specifies if the bloom pipeline is enabled
  71214. */
  71215. get BloomEnabled(): boolean;
  71216. set BloomEnabled(enabled: boolean);
  71217. /**
  71218. * @ignore
  71219. * Specifies if the depth of field pipeline is enabed
  71220. */
  71221. get DepthOfFieldEnabled(): boolean;
  71222. set DepthOfFieldEnabled(enabled: boolean);
  71223. /**
  71224. * @ignore
  71225. * Specifies if the lens flare pipeline is enabed
  71226. */
  71227. get LensFlareEnabled(): boolean;
  71228. set LensFlareEnabled(enabled: boolean);
  71229. /**
  71230. * @ignore
  71231. * Specifies if the HDR pipeline is enabled
  71232. */
  71233. get HDREnabled(): boolean;
  71234. set HDREnabled(enabled: boolean);
  71235. /**
  71236. * @ignore
  71237. * Specifies if the volumetric lights scattering effect is enabled
  71238. */
  71239. get VLSEnabled(): boolean;
  71240. set VLSEnabled(enabled: boolean);
  71241. /**
  71242. * @ignore
  71243. * Specifies if the motion blur effect is enabled
  71244. */
  71245. get MotionBlurEnabled(): boolean;
  71246. set MotionBlurEnabled(enabled: boolean);
  71247. /**
  71248. * Specifies if anti-aliasing is enabled
  71249. */
  71250. get fxaaEnabled(): boolean;
  71251. set fxaaEnabled(enabled: boolean);
  71252. /**
  71253. * Specifies if screen space reflections are enabled.
  71254. */
  71255. get screenSpaceReflectionsEnabled(): boolean;
  71256. set screenSpaceReflectionsEnabled(enabled: boolean);
  71257. /**
  71258. * Specifies the number of steps used to calculate the volumetric lights
  71259. * Typically in interval [50, 200]
  71260. */
  71261. get volumetricLightStepsCount(): number;
  71262. set volumetricLightStepsCount(count: number);
  71263. /**
  71264. * Specifies the number of samples used for the motion blur effect
  71265. * Typically in interval [16, 64]
  71266. */
  71267. get motionBlurSamples(): number;
  71268. set motionBlurSamples(samples: number);
  71269. /**
  71270. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71271. */
  71272. get samples(): number;
  71273. set samples(sampleCount: number);
  71274. /**
  71275. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71276. * @constructor
  71277. * @param name The rendering pipeline name
  71278. * @param scene The scene linked to this pipeline
  71279. * @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)
  71280. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  71281. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71282. */
  71283. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  71284. private _buildPipeline;
  71285. private _createDownSampleX4PostProcess;
  71286. private _createBrightPassPostProcess;
  71287. private _createBlurPostProcesses;
  71288. private _createTextureAdderPostProcess;
  71289. private _createVolumetricLightPostProcess;
  71290. private _createLuminancePostProcesses;
  71291. private _createHdrPostProcess;
  71292. private _createLensFlarePostProcess;
  71293. private _createDepthOfFieldPostProcess;
  71294. private _createMotionBlurPostProcess;
  71295. private _getDepthTexture;
  71296. private _disposePostProcesses;
  71297. /**
  71298. * Dispose of the pipeline and stop all post processes
  71299. */
  71300. dispose(): void;
  71301. /**
  71302. * Serialize the rendering pipeline (Used when exporting)
  71303. * @returns the serialized object
  71304. */
  71305. serialize(): any;
  71306. /**
  71307. * Parse the serialized pipeline
  71308. * @param source Source pipeline.
  71309. * @param scene The scene to load the pipeline to.
  71310. * @param rootUrl The URL of the serialized pipeline.
  71311. * @returns An instantiated pipeline from the serialized object.
  71312. */
  71313. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  71314. /**
  71315. * Luminance steps
  71316. */
  71317. static LuminanceSteps: number;
  71318. }
  71319. }
  71320. declare module BABYLON {
  71321. /** @hidden */
  71322. export var stereoscopicInterlacePixelShader: {
  71323. name: string;
  71324. shader: string;
  71325. };
  71326. }
  71327. declare module BABYLON {
  71328. /**
  71329. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  71330. */
  71331. export class StereoscopicInterlacePostProcessI extends PostProcess {
  71332. private _stepSize;
  71333. private _passedProcess;
  71334. /**
  71335. * Gets a string identifying the name of the class
  71336. * @returns "StereoscopicInterlacePostProcessI" string
  71337. */
  71338. getClassName(): string;
  71339. /**
  71340. * Initializes a StereoscopicInterlacePostProcessI
  71341. * @param name The name of the effect.
  71342. * @param rigCameras The rig cameras to be appled to the post process
  71343. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  71344. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  71345. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71346. * @param engine The engine which the post process will be applied. (default: current engine)
  71347. * @param reusable If the post process can be reused on the same frame. (default: false)
  71348. */
  71349. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71350. }
  71351. /**
  71352. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  71353. */
  71354. export class StereoscopicInterlacePostProcess extends PostProcess {
  71355. private _stepSize;
  71356. private _passedProcess;
  71357. /**
  71358. * Gets a string identifying the name of the class
  71359. * @returns "StereoscopicInterlacePostProcess" string
  71360. */
  71361. getClassName(): string;
  71362. /**
  71363. * Initializes a StereoscopicInterlacePostProcess
  71364. * @param name The name of the effect.
  71365. * @param rigCameras The rig cameras to be appled to the post process
  71366. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  71367. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71368. * @param engine The engine which the post process will be applied. (default: current engine)
  71369. * @param reusable If the post process can be reused on the same frame. (default: false)
  71370. */
  71371. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71372. }
  71373. }
  71374. declare module BABYLON {
  71375. /** @hidden */
  71376. export var tonemapPixelShader: {
  71377. name: string;
  71378. shader: string;
  71379. };
  71380. }
  71381. declare module BABYLON {
  71382. /** Defines operator used for tonemapping */
  71383. export enum TonemappingOperator {
  71384. /** Hable */
  71385. Hable = 0,
  71386. /** Reinhard */
  71387. Reinhard = 1,
  71388. /** HejiDawson */
  71389. HejiDawson = 2,
  71390. /** Photographic */
  71391. Photographic = 3
  71392. }
  71393. /**
  71394. * Defines a post process to apply tone mapping
  71395. */
  71396. export class TonemapPostProcess extends PostProcess {
  71397. private _operator;
  71398. /** Defines the required exposure adjustement */
  71399. exposureAdjustment: number;
  71400. /**
  71401. * Gets a string identifying the name of the class
  71402. * @returns "TonemapPostProcess" string
  71403. */
  71404. getClassName(): string;
  71405. /**
  71406. * Creates a new TonemapPostProcess
  71407. * @param name defines the name of the postprocess
  71408. * @param _operator defines the operator to use
  71409. * @param exposureAdjustment defines the required exposure adjustement
  71410. * @param camera defines the camera to use (can be null)
  71411. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  71412. * @param engine defines the hosting engine (can be ignore if camera is set)
  71413. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71414. */
  71415. constructor(name: string, _operator: TonemappingOperator,
  71416. /** Defines the required exposure adjustement */
  71417. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  71418. }
  71419. }
  71420. declare module BABYLON {
  71421. /** @hidden */
  71422. export var volumetricLightScatteringPixelShader: {
  71423. name: string;
  71424. shader: string;
  71425. };
  71426. }
  71427. declare module BABYLON {
  71428. /** @hidden */
  71429. export var volumetricLightScatteringPassVertexShader: {
  71430. name: string;
  71431. shader: string;
  71432. };
  71433. }
  71434. declare module BABYLON {
  71435. /** @hidden */
  71436. export var volumetricLightScatteringPassPixelShader: {
  71437. name: string;
  71438. shader: string;
  71439. };
  71440. }
  71441. declare module BABYLON {
  71442. /**
  71443. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  71444. */
  71445. export class VolumetricLightScatteringPostProcess extends PostProcess {
  71446. private _volumetricLightScatteringPass;
  71447. private _volumetricLightScatteringRTT;
  71448. private _viewPort;
  71449. private _screenCoordinates;
  71450. private _cachedDefines;
  71451. /**
  71452. * If not undefined, the mesh position is computed from the attached node position
  71453. */
  71454. attachedNode: {
  71455. position: Vector3;
  71456. };
  71457. /**
  71458. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  71459. */
  71460. customMeshPosition: Vector3;
  71461. /**
  71462. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  71463. */
  71464. useCustomMeshPosition: boolean;
  71465. /**
  71466. * If the post-process should inverse the light scattering direction
  71467. */
  71468. invert: boolean;
  71469. /**
  71470. * The internal mesh used by the post-process
  71471. */
  71472. mesh: Mesh;
  71473. /**
  71474. * @hidden
  71475. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  71476. */
  71477. get useDiffuseColor(): boolean;
  71478. set useDiffuseColor(useDiffuseColor: boolean);
  71479. /**
  71480. * Array containing the excluded meshes not rendered in the internal pass
  71481. */
  71482. excludedMeshes: AbstractMesh[];
  71483. /**
  71484. * Controls the overall intensity of the post-process
  71485. */
  71486. exposure: number;
  71487. /**
  71488. * Dissipates each sample's contribution in range [0, 1]
  71489. */
  71490. decay: number;
  71491. /**
  71492. * Controls the overall intensity of each sample
  71493. */
  71494. weight: number;
  71495. /**
  71496. * Controls the density of each sample
  71497. */
  71498. density: number;
  71499. /**
  71500. * @constructor
  71501. * @param name The post-process name
  71502. * @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)
  71503. * @param camera The camera that the post-process will be attached to
  71504. * @param mesh The mesh used to create the light scattering
  71505. * @param samples The post-process quality, default 100
  71506. * @param samplingModeThe post-process filtering mode
  71507. * @param engine The babylon engine
  71508. * @param reusable If the post-process is reusable
  71509. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  71510. */
  71511. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  71512. /**
  71513. * Returns the string "VolumetricLightScatteringPostProcess"
  71514. * @returns "VolumetricLightScatteringPostProcess"
  71515. */
  71516. getClassName(): string;
  71517. private _isReady;
  71518. /**
  71519. * Sets the new light position for light scattering effect
  71520. * @param position The new custom light position
  71521. */
  71522. setCustomMeshPosition(position: Vector3): void;
  71523. /**
  71524. * Returns the light position for light scattering effect
  71525. * @return Vector3 The custom light position
  71526. */
  71527. getCustomMeshPosition(): Vector3;
  71528. /**
  71529. * Disposes the internal assets and detaches the post-process from the camera
  71530. */
  71531. dispose(camera: Camera): void;
  71532. /**
  71533. * Returns the render target texture used by the post-process
  71534. * @return the render target texture used by the post-process
  71535. */
  71536. getPass(): RenderTargetTexture;
  71537. private _meshExcluded;
  71538. private _createPass;
  71539. private _updateMeshScreenCoordinates;
  71540. /**
  71541. * Creates a default mesh for the Volumeric Light Scattering post-process
  71542. * @param name The mesh name
  71543. * @param scene The scene where to create the mesh
  71544. * @return the default mesh
  71545. */
  71546. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  71547. }
  71548. }
  71549. declare module BABYLON {
  71550. /** @hidden */
  71551. export var screenSpaceCurvaturePixelShader: {
  71552. name: string;
  71553. shader: string;
  71554. };
  71555. }
  71556. declare module BABYLON {
  71557. /**
  71558. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  71559. */
  71560. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  71561. /**
  71562. * Defines how much ridge the curvature effect displays.
  71563. */
  71564. ridge: number;
  71565. /**
  71566. * Defines how much valley the curvature effect displays.
  71567. */
  71568. valley: number;
  71569. private _geometryBufferRenderer;
  71570. /**
  71571. * Gets a string identifying the name of the class
  71572. * @returns "ScreenSpaceCurvaturePostProcess" string
  71573. */
  71574. getClassName(): string;
  71575. /**
  71576. * Creates a new instance ScreenSpaceCurvaturePostProcess
  71577. * @param name The name of the effect.
  71578. * @param scene The scene containing the objects to blur according to their velocity.
  71579. * @param options The required width/height ratio to downsize to before computing the render pass.
  71580. * @param camera The camera to apply the render pass to.
  71581. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71582. * @param engine The engine which the post process will be applied. (default: current engine)
  71583. * @param reusable If the post process can be reused on the same frame. (default: false)
  71584. * @param textureType Type of textures used when performing the post process. (default: 0)
  71585. * @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)
  71586. */
  71587. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71588. /**
  71589. * Support test.
  71590. */
  71591. static get IsSupported(): boolean;
  71592. /** @hidden */
  71593. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  71594. }
  71595. }
  71596. declare module BABYLON {
  71597. interface Scene {
  71598. /** @hidden (Backing field) */
  71599. _boundingBoxRenderer: BoundingBoxRenderer;
  71600. /** @hidden (Backing field) */
  71601. _forceShowBoundingBoxes: boolean;
  71602. /**
  71603. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  71604. */
  71605. forceShowBoundingBoxes: boolean;
  71606. /**
  71607. * Gets the bounding box renderer associated with the scene
  71608. * @returns a BoundingBoxRenderer
  71609. */
  71610. getBoundingBoxRenderer(): BoundingBoxRenderer;
  71611. }
  71612. interface AbstractMesh {
  71613. /** @hidden (Backing field) */
  71614. _showBoundingBox: boolean;
  71615. /**
  71616. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  71617. */
  71618. showBoundingBox: boolean;
  71619. }
  71620. /**
  71621. * Component responsible of rendering the bounding box of the meshes in a scene.
  71622. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  71623. */
  71624. export class BoundingBoxRenderer implements ISceneComponent {
  71625. /**
  71626. * The component name helpfull to identify the component in the list of scene components.
  71627. */
  71628. readonly name: string;
  71629. /**
  71630. * The scene the component belongs to.
  71631. */
  71632. scene: Scene;
  71633. /**
  71634. * Color of the bounding box lines placed in front of an object
  71635. */
  71636. frontColor: Color3;
  71637. /**
  71638. * Color of the bounding box lines placed behind an object
  71639. */
  71640. backColor: Color3;
  71641. /**
  71642. * Defines if the renderer should show the back lines or not
  71643. */
  71644. showBackLines: boolean;
  71645. /**
  71646. * Observable raised before rendering a bounding box
  71647. */
  71648. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  71649. /**
  71650. * Observable raised after rendering a bounding box
  71651. */
  71652. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  71653. /**
  71654. * @hidden
  71655. */
  71656. renderList: SmartArray<BoundingBox>;
  71657. private _colorShader;
  71658. private _vertexBuffers;
  71659. private _indexBuffer;
  71660. private _fillIndexBuffer;
  71661. private _fillIndexData;
  71662. /**
  71663. * Instantiates a new bounding box renderer in a scene.
  71664. * @param scene the scene the renderer renders in
  71665. */
  71666. constructor(scene: Scene);
  71667. /**
  71668. * Registers the component in a given scene
  71669. */
  71670. register(): void;
  71671. private _evaluateSubMesh;
  71672. private _activeMesh;
  71673. private _prepareRessources;
  71674. private _createIndexBuffer;
  71675. /**
  71676. * Rebuilds the elements related to this component in case of
  71677. * context lost for instance.
  71678. */
  71679. rebuild(): void;
  71680. /**
  71681. * @hidden
  71682. */
  71683. reset(): void;
  71684. /**
  71685. * Render the bounding boxes of a specific rendering group
  71686. * @param renderingGroupId defines the rendering group to render
  71687. */
  71688. render(renderingGroupId: number): void;
  71689. /**
  71690. * In case of occlusion queries, we can render the occlusion bounding box through this method
  71691. * @param mesh Define the mesh to render the occlusion bounding box for
  71692. */
  71693. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  71694. /**
  71695. * Dispose and release the resources attached to this renderer.
  71696. */
  71697. dispose(): void;
  71698. }
  71699. }
  71700. declare module BABYLON {
  71701. interface Scene {
  71702. /** @hidden (Backing field) */
  71703. _depthRenderer: {
  71704. [id: string]: DepthRenderer;
  71705. };
  71706. /**
  71707. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  71708. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  71709. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  71710. * @returns the created depth renderer
  71711. */
  71712. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  71713. /**
  71714. * Disables a depth renderer for a given camera
  71715. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  71716. */
  71717. disableDepthRenderer(camera?: Nullable<Camera>): void;
  71718. }
  71719. /**
  71720. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  71721. * in several rendering techniques.
  71722. */
  71723. export class DepthRendererSceneComponent implements ISceneComponent {
  71724. /**
  71725. * The component name helpfull to identify the component in the list of scene components.
  71726. */
  71727. readonly name: string;
  71728. /**
  71729. * The scene the component belongs to.
  71730. */
  71731. scene: Scene;
  71732. /**
  71733. * Creates a new instance of the component for the given scene
  71734. * @param scene Defines the scene to register the component in
  71735. */
  71736. constructor(scene: Scene);
  71737. /**
  71738. * Registers the component in a given scene
  71739. */
  71740. register(): void;
  71741. /**
  71742. * Rebuilds the elements related to this component in case of
  71743. * context lost for instance.
  71744. */
  71745. rebuild(): void;
  71746. /**
  71747. * Disposes the component and the associated ressources
  71748. */
  71749. dispose(): void;
  71750. private _gatherRenderTargets;
  71751. private _gatherActiveCameraRenderTargets;
  71752. }
  71753. }
  71754. declare module BABYLON {
  71755. interface AbstractScene {
  71756. /** @hidden (Backing field) */
  71757. _prePassRenderer: Nullable<PrePassRenderer>;
  71758. /**
  71759. * Gets or Sets the current prepass renderer associated to the scene.
  71760. */
  71761. prePassRenderer: Nullable<PrePassRenderer>;
  71762. /**
  71763. * Enables the prepass and associates it with the scene
  71764. * @returns the PrePassRenderer
  71765. */
  71766. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  71767. /**
  71768. * Disables the prepass associated with the scene
  71769. */
  71770. disablePrePassRenderer(): void;
  71771. }
  71772. /**
  71773. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71774. * in several rendering techniques.
  71775. */
  71776. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  71777. /**
  71778. * The component name helpful to identify the component in the list of scene components.
  71779. */
  71780. readonly name: string;
  71781. /**
  71782. * The scene the component belongs to.
  71783. */
  71784. scene: Scene;
  71785. /**
  71786. * Creates a new instance of the component for the given scene
  71787. * @param scene Defines the scene to register the component in
  71788. */
  71789. constructor(scene: Scene);
  71790. /**
  71791. * Registers the component in a given scene
  71792. */
  71793. register(): void;
  71794. private _beforeCameraDraw;
  71795. private _afterCameraDraw;
  71796. private _beforeClearStage;
  71797. /**
  71798. * Serializes the component data to the specified json object
  71799. * @param serializationObject The object to serialize to
  71800. */
  71801. serialize(serializationObject: any): void;
  71802. /**
  71803. * Adds all the elements from the container to the scene
  71804. * @param container the container holding the elements
  71805. */
  71806. addFromContainer(container: AbstractScene): void;
  71807. /**
  71808. * Removes all the elements in the container from the scene
  71809. * @param container contains the elements to remove
  71810. * @param dispose if the removed element should be disposed (default: false)
  71811. */
  71812. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  71813. /**
  71814. * Rebuilds the elements related to this component in case of
  71815. * context lost for instance.
  71816. */
  71817. rebuild(): void;
  71818. /**
  71819. * Disposes the component and the associated ressources
  71820. */
  71821. dispose(): void;
  71822. }
  71823. }
  71824. declare module BABYLON {
  71825. /** @hidden */
  71826. export var outlinePixelShader: {
  71827. name: string;
  71828. shader: string;
  71829. };
  71830. }
  71831. declare module BABYLON {
  71832. /** @hidden */
  71833. export var outlineVertexShader: {
  71834. name: string;
  71835. shader: string;
  71836. };
  71837. }
  71838. declare module BABYLON {
  71839. interface Scene {
  71840. /** @hidden */
  71841. _outlineRenderer: OutlineRenderer;
  71842. /**
  71843. * Gets the outline renderer associated with the scene
  71844. * @returns a OutlineRenderer
  71845. */
  71846. getOutlineRenderer(): OutlineRenderer;
  71847. }
  71848. interface AbstractMesh {
  71849. /** @hidden (Backing field) */
  71850. _renderOutline: boolean;
  71851. /**
  71852. * Gets or sets a boolean indicating if the outline must be rendered as well
  71853. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  71854. */
  71855. renderOutline: boolean;
  71856. /** @hidden (Backing field) */
  71857. _renderOverlay: boolean;
  71858. /**
  71859. * Gets or sets a boolean indicating if the overlay must be rendered as well
  71860. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  71861. */
  71862. renderOverlay: boolean;
  71863. }
  71864. /**
  71865. * This class is responsible to draw bothe outline/overlay of meshes.
  71866. * It should not be used directly but through the available method on mesh.
  71867. */
  71868. export class OutlineRenderer implements ISceneComponent {
  71869. /**
  71870. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  71871. */
  71872. private static _StencilReference;
  71873. /**
  71874. * The name of the component. Each component must have a unique name.
  71875. */
  71876. name: string;
  71877. /**
  71878. * The scene the component belongs to.
  71879. */
  71880. scene: Scene;
  71881. /**
  71882. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  71883. */
  71884. zOffset: number;
  71885. private _engine;
  71886. private _effect;
  71887. private _cachedDefines;
  71888. private _savedDepthWrite;
  71889. /**
  71890. * Instantiates a new outline renderer. (There could be only one per scene).
  71891. * @param scene Defines the scene it belongs to
  71892. */
  71893. constructor(scene: Scene);
  71894. /**
  71895. * Register the component to one instance of a scene.
  71896. */
  71897. register(): 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. * Renders the outline in the canvas.
  71909. * @param subMesh Defines the sumesh to render
  71910. * @param batch Defines the batch of meshes in case of instances
  71911. * @param useOverlay Defines if the rendering is for the overlay or the outline
  71912. */
  71913. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  71914. /**
  71915. * Returns whether or not the outline renderer is ready for a given submesh.
  71916. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  71917. * @param subMesh Defines the submesh to check readyness for
  71918. * @param useInstances Defines wheter wee are trying to render instances or not
  71919. * @returns true if ready otherwise false
  71920. */
  71921. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  71922. private _beforeRenderingMesh;
  71923. private _afterRenderingMesh;
  71924. }
  71925. }
  71926. declare module BABYLON {
  71927. /**
  71928. * Defines the basic options interface of a Sprite Frame Source Size.
  71929. */
  71930. export interface ISpriteJSONSpriteSourceSize {
  71931. /**
  71932. * number of the original width of the Frame
  71933. */
  71934. w: number;
  71935. /**
  71936. * number of the original height of the Frame
  71937. */
  71938. h: number;
  71939. }
  71940. /**
  71941. * Defines the basic options interface of a Sprite Frame Data.
  71942. */
  71943. export interface ISpriteJSONSpriteFrameData {
  71944. /**
  71945. * number of the x offset of the Frame
  71946. */
  71947. x: number;
  71948. /**
  71949. * number of the y offset of the Frame
  71950. */
  71951. y: number;
  71952. /**
  71953. * number of the width of the Frame
  71954. */
  71955. w: number;
  71956. /**
  71957. * number of the height of the Frame
  71958. */
  71959. h: number;
  71960. }
  71961. /**
  71962. * Defines the basic options interface of a JSON Sprite.
  71963. */
  71964. export interface ISpriteJSONSprite {
  71965. /**
  71966. * string name of the Frame
  71967. */
  71968. filename: string;
  71969. /**
  71970. * ISpriteJSONSpriteFrame basic object of the frame data
  71971. */
  71972. frame: ISpriteJSONSpriteFrameData;
  71973. /**
  71974. * boolean to flag is the frame was rotated.
  71975. */
  71976. rotated: boolean;
  71977. /**
  71978. * boolean to flag is the frame was trimmed.
  71979. */
  71980. trimmed: boolean;
  71981. /**
  71982. * ISpriteJSONSpriteFrame basic object of the source data
  71983. */
  71984. spriteSourceSize: ISpriteJSONSpriteFrameData;
  71985. /**
  71986. * ISpriteJSONSpriteFrame basic object of the source data
  71987. */
  71988. sourceSize: ISpriteJSONSpriteSourceSize;
  71989. }
  71990. /**
  71991. * Defines the basic options interface of a JSON atlas.
  71992. */
  71993. export interface ISpriteJSONAtlas {
  71994. /**
  71995. * Array of objects that contain the frame data.
  71996. */
  71997. frames: Array<ISpriteJSONSprite>;
  71998. /**
  71999. * object basic object containing the sprite meta data.
  72000. */
  72001. meta?: object;
  72002. }
  72003. }
  72004. declare module BABYLON {
  72005. /** @hidden */
  72006. export var spriteMapPixelShader: {
  72007. name: string;
  72008. shader: string;
  72009. };
  72010. }
  72011. declare module BABYLON {
  72012. /** @hidden */
  72013. export var spriteMapVertexShader: {
  72014. name: string;
  72015. shader: string;
  72016. };
  72017. }
  72018. declare module BABYLON {
  72019. /**
  72020. * Defines the basic options interface of a SpriteMap
  72021. */
  72022. export interface ISpriteMapOptions {
  72023. /**
  72024. * Vector2 of the number of cells in the grid.
  72025. */
  72026. stageSize?: Vector2;
  72027. /**
  72028. * Vector2 of the size of the output plane in World Units.
  72029. */
  72030. outputSize?: Vector2;
  72031. /**
  72032. * Vector3 of the position of the output plane in World Units.
  72033. */
  72034. outputPosition?: Vector3;
  72035. /**
  72036. * Vector3 of the rotation of the output plane.
  72037. */
  72038. outputRotation?: Vector3;
  72039. /**
  72040. * number of layers that the system will reserve in resources.
  72041. */
  72042. layerCount?: number;
  72043. /**
  72044. * number of max animation frames a single cell will reserve in resources.
  72045. */
  72046. maxAnimationFrames?: number;
  72047. /**
  72048. * number cell index of the base tile when the system compiles.
  72049. */
  72050. baseTile?: number;
  72051. /**
  72052. * boolean flip the sprite after its been repositioned by the framing data.
  72053. */
  72054. flipU?: boolean;
  72055. /**
  72056. * Vector3 scalar of the global RGB values of the SpriteMap.
  72057. */
  72058. colorMultiply?: Vector3;
  72059. }
  72060. /**
  72061. * Defines the IDisposable interface in order to be cleanable from resources.
  72062. */
  72063. export interface ISpriteMap extends IDisposable {
  72064. /**
  72065. * String name of the SpriteMap.
  72066. */
  72067. name: string;
  72068. /**
  72069. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  72070. */
  72071. atlasJSON: ISpriteJSONAtlas;
  72072. /**
  72073. * Texture of the SpriteMap.
  72074. */
  72075. spriteSheet: Texture;
  72076. /**
  72077. * The parameters to initialize the SpriteMap with.
  72078. */
  72079. options: ISpriteMapOptions;
  72080. }
  72081. /**
  72082. * Class used to manage a grid restricted sprite deployment on an Output plane.
  72083. */
  72084. export class SpriteMap implements ISpriteMap {
  72085. /** The Name of the spriteMap */
  72086. name: string;
  72087. /** The JSON file with the frame and meta data */
  72088. atlasJSON: ISpriteJSONAtlas;
  72089. /** The systems Sprite Sheet Texture */
  72090. spriteSheet: Texture;
  72091. /** Arguments passed with the Constructor */
  72092. options: ISpriteMapOptions;
  72093. /** Public Sprite Storage array, parsed from atlasJSON */
  72094. sprites: Array<ISpriteJSONSprite>;
  72095. /** Returns the Number of Sprites in the System */
  72096. get spriteCount(): number;
  72097. /** Returns the Position of Output Plane*/
  72098. get position(): Vector3;
  72099. /** Returns the Position of Output Plane*/
  72100. set position(v: Vector3);
  72101. /** Returns the Rotation of Output Plane*/
  72102. get rotation(): Vector3;
  72103. /** Returns the Rotation of Output Plane*/
  72104. set rotation(v: Vector3);
  72105. /** Sets the AnimationMap*/
  72106. get animationMap(): RawTexture;
  72107. /** Sets the AnimationMap*/
  72108. set animationMap(v: RawTexture);
  72109. /** Scene that the SpriteMap was created in */
  72110. private _scene;
  72111. /** Texture Buffer of Float32 that holds tile frame data*/
  72112. private _frameMap;
  72113. /** Texture Buffers of Float32 that holds tileMap data*/
  72114. private _tileMaps;
  72115. /** Texture Buffer of Float32 that holds Animation Data*/
  72116. private _animationMap;
  72117. /** Custom ShaderMaterial Central to the System*/
  72118. private _material;
  72119. /** Custom ShaderMaterial Central to the System*/
  72120. private _output;
  72121. /** Systems Time Ticker*/
  72122. private _time;
  72123. /**
  72124. * Creates a new SpriteMap
  72125. * @param name defines the SpriteMaps Name
  72126. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  72127. * @param spriteSheet is the Texture that the Sprites are on.
  72128. * @param options a basic deployment configuration
  72129. * @param scene The Scene that the map is deployed on
  72130. */
  72131. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  72132. /**
  72133. * Returns tileID location
  72134. * @returns Vector2 the cell position ID
  72135. */
  72136. getTileID(): Vector2;
  72137. /**
  72138. * Gets the UV location of the mouse over the SpriteMap.
  72139. * @returns Vector2 the UV position of the mouse interaction
  72140. */
  72141. getMousePosition(): Vector2;
  72142. /**
  72143. * Creates the "frame" texture Buffer
  72144. * -------------------------------------
  72145. * Structure of frames
  72146. * "filename": "Falling-Water-2.png",
  72147. * "frame": {"x":69,"y":103,"w":24,"h":32},
  72148. * "rotated": true,
  72149. * "trimmed": true,
  72150. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  72151. * "sourceSize": {"w":32,"h":32}
  72152. * @returns RawTexture of the frameMap
  72153. */
  72154. private _createFrameBuffer;
  72155. /**
  72156. * Creates the tileMap texture Buffer
  72157. * @param buffer normally and array of numbers, or a false to generate from scratch
  72158. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  72159. * @returns RawTexture of the tileMap
  72160. */
  72161. private _createTileBuffer;
  72162. /**
  72163. * Modifies the data of the tileMaps
  72164. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  72165. * @param pos is the iVector2 Coordinates of the Tile
  72166. * @param tile The SpriteIndex of the new Tile
  72167. */
  72168. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  72169. /**
  72170. * Creates the animationMap texture Buffer
  72171. * @param buffer normally and array of numbers, or a false to generate from scratch
  72172. * @returns RawTexture of the animationMap
  72173. */
  72174. private _createTileAnimationBuffer;
  72175. /**
  72176. * Modifies the data of the animationMap
  72177. * @param cellID is the Index of the Sprite
  72178. * @param _frame is the target Animation frame
  72179. * @param toCell is the Target Index of the next frame of the animation
  72180. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  72181. * @param speed is a global scalar of the time variable on the map.
  72182. */
  72183. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  72184. /**
  72185. * Exports the .tilemaps file
  72186. */
  72187. saveTileMaps(): void;
  72188. /**
  72189. * Imports the .tilemaps file
  72190. * @param url of the .tilemaps file
  72191. */
  72192. loadTileMaps(url: string): void;
  72193. /**
  72194. * Release associated resources
  72195. */
  72196. dispose(): void;
  72197. }
  72198. }
  72199. declare module BABYLON {
  72200. /**
  72201. * Class used to manage multiple sprites of different sizes on the same spritesheet
  72202. * @see https://doc.babylonjs.com/babylon101/sprites
  72203. */
  72204. export class SpritePackedManager extends SpriteManager {
  72205. /** defines the packed manager's name */
  72206. name: string;
  72207. /**
  72208. * Creates a new sprite manager from a packed sprite sheet
  72209. * @param name defines the manager's name
  72210. * @param imgUrl defines the sprite sheet url
  72211. * @param capacity defines the maximum allowed number of sprites
  72212. * @param scene defines the hosting scene
  72213. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  72214. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  72215. * @param samplingMode defines the smapling mode to use with spritesheet
  72216. * @param fromPacked set to true; do not alter
  72217. */
  72218. constructor(
  72219. /** defines the packed manager's name */
  72220. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  72221. }
  72222. }
  72223. declare module BABYLON {
  72224. /**
  72225. * Defines the list of states available for a task inside a AssetsManager
  72226. */
  72227. export enum AssetTaskState {
  72228. /**
  72229. * Initialization
  72230. */
  72231. INIT = 0,
  72232. /**
  72233. * Running
  72234. */
  72235. RUNNING = 1,
  72236. /**
  72237. * Done
  72238. */
  72239. DONE = 2,
  72240. /**
  72241. * Error
  72242. */
  72243. ERROR = 3
  72244. }
  72245. /**
  72246. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  72247. */
  72248. export abstract class AbstractAssetTask {
  72249. /**
  72250. * Task name
  72251. */ name: string;
  72252. /**
  72253. * Callback called when the task is successful
  72254. */
  72255. onSuccess: (task: any) => void;
  72256. /**
  72257. * Callback called when the task is not successful
  72258. */
  72259. onError: (task: any, message?: string, exception?: any) => void;
  72260. /**
  72261. * Creates a new AssetsManager
  72262. * @param name defines the name of the task
  72263. */
  72264. constructor(
  72265. /**
  72266. * Task name
  72267. */ name: string);
  72268. private _isCompleted;
  72269. private _taskState;
  72270. private _errorObject;
  72271. /**
  72272. * Get if the task is completed
  72273. */
  72274. get isCompleted(): boolean;
  72275. /**
  72276. * Gets the current state of the task
  72277. */
  72278. get taskState(): AssetTaskState;
  72279. /**
  72280. * Gets the current error object (if task is in error)
  72281. */
  72282. get errorObject(): {
  72283. message?: string;
  72284. exception?: any;
  72285. };
  72286. /**
  72287. * Internal only
  72288. * @hidden
  72289. */
  72290. _setErrorObject(message?: string, exception?: any): void;
  72291. /**
  72292. * Execute the current task
  72293. * @param scene defines the scene where you want your assets to be loaded
  72294. * @param onSuccess is a callback called when the task is successfully executed
  72295. * @param onError is a callback called if an error occurs
  72296. */
  72297. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72298. /**
  72299. * Execute the current task
  72300. * @param scene defines the scene where you want your assets to be loaded
  72301. * @param onSuccess is a callback called when the task is successfully executed
  72302. * @param onError is a callback called if an error occurs
  72303. */
  72304. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72305. /**
  72306. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  72307. * This can be used with failed tasks that have the reason for failure fixed.
  72308. */
  72309. reset(): void;
  72310. private onErrorCallback;
  72311. private onDoneCallback;
  72312. }
  72313. /**
  72314. * Define the interface used by progress events raised during assets loading
  72315. */
  72316. export interface IAssetsProgressEvent {
  72317. /**
  72318. * Defines the number of remaining tasks to process
  72319. */
  72320. remainingCount: number;
  72321. /**
  72322. * Defines the total number of tasks
  72323. */
  72324. totalCount: number;
  72325. /**
  72326. * Defines the task that was just processed
  72327. */
  72328. task: AbstractAssetTask;
  72329. }
  72330. /**
  72331. * Class used to share progress information about assets loading
  72332. */
  72333. export class AssetsProgressEvent implements IAssetsProgressEvent {
  72334. /**
  72335. * Defines the number of remaining tasks to process
  72336. */
  72337. remainingCount: number;
  72338. /**
  72339. * Defines the total number of tasks
  72340. */
  72341. totalCount: number;
  72342. /**
  72343. * Defines the task that was just processed
  72344. */
  72345. task: AbstractAssetTask;
  72346. /**
  72347. * Creates a AssetsProgressEvent
  72348. * @param remainingCount defines the number of remaining tasks to process
  72349. * @param totalCount defines the total number of tasks
  72350. * @param task defines the task that was just processed
  72351. */
  72352. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  72353. }
  72354. /**
  72355. * Define a task used by AssetsManager to load assets into a container
  72356. */
  72357. export class ContainerAssetTask extends AbstractAssetTask {
  72358. /**
  72359. * Defines the name of the task
  72360. */
  72361. name: string;
  72362. /**
  72363. * Defines the list of mesh's names you want to load
  72364. */
  72365. meshesNames: any;
  72366. /**
  72367. * Defines the root url to use as a base to load your meshes and associated resources
  72368. */
  72369. rootUrl: string;
  72370. /**
  72371. * Defines the filename or File of the scene to load from
  72372. */
  72373. sceneFilename: string | File;
  72374. /**
  72375. * Get the loaded asset container
  72376. */
  72377. loadedContainer: AssetContainer;
  72378. /**
  72379. * Gets the list of loaded meshes
  72380. */
  72381. loadedMeshes: Array<AbstractMesh>;
  72382. /**
  72383. * Gets the list of loaded particle systems
  72384. */
  72385. loadedParticleSystems: Array<IParticleSystem>;
  72386. /**
  72387. * Gets the list of loaded skeletons
  72388. */
  72389. loadedSkeletons: Array<Skeleton>;
  72390. /**
  72391. * Gets the list of loaded animation groups
  72392. */
  72393. loadedAnimationGroups: Array<AnimationGroup>;
  72394. /**
  72395. * Callback called when the task is successful
  72396. */
  72397. onSuccess: (task: ContainerAssetTask) => void;
  72398. /**
  72399. * Callback called when the task is successful
  72400. */
  72401. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  72402. /**
  72403. * Creates a new ContainerAssetTask
  72404. * @param name defines the name of the task
  72405. * @param meshesNames defines the list of mesh's names you want to load
  72406. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  72407. * @param sceneFilename defines the filename or File of the scene to load from
  72408. */
  72409. constructor(
  72410. /**
  72411. * Defines the name of the task
  72412. */
  72413. name: string,
  72414. /**
  72415. * Defines the list of mesh's names you want to load
  72416. */
  72417. meshesNames: any,
  72418. /**
  72419. * Defines the root url to use as a base to load your meshes and associated resources
  72420. */
  72421. rootUrl: string,
  72422. /**
  72423. * Defines the filename or File of the scene to load from
  72424. */
  72425. sceneFilename: string | File);
  72426. /**
  72427. * Execute the current task
  72428. * @param scene defines the scene where you want your assets to be loaded
  72429. * @param onSuccess is a callback called when the task is successfully executed
  72430. * @param onError is a callback called if an error occurs
  72431. */
  72432. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72433. }
  72434. /**
  72435. * Define a task used by AssetsManager to load meshes
  72436. */
  72437. export class MeshAssetTask extends AbstractAssetTask {
  72438. /**
  72439. * Defines the name of the task
  72440. */
  72441. name: string;
  72442. /**
  72443. * Defines the list of mesh's names you want to load
  72444. */
  72445. meshesNames: any;
  72446. /**
  72447. * Defines the root url to use as a base to load your meshes and associated resources
  72448. */
  72449. rootUrl: string;
  72450. /**
  72451. * Defines the filename or File of the scene to load from
  72452. */
  72453. sceneFilename: string | File;
  72454. /**
  72455. * Gets the list of loaded meshes
  72456. */
  72457. loadedMeshes: Array<AbstractMesh>;
  72458. /**
  72459. * Gets the list of loaded particle systems
  72460. */
  72461. loadedParticleSystems: Array<IParticleSystem>;
  72462. /**
  72463. * Gets the list of loaded skeletons
  72464. */
  72465. loadedSkeletons: Array<Skeleton>;
  72466. /**
  72467. * Gets the list of loaded animation groups
  72468. */
  72469. loadedAnimationGroups: Array<AnimationGroup>;
  72470. /**
  72471. * Callback called when the task is successful
  72472. */
  72473. onSuccess: (task: MeshAssetTask) => void;
  72474. /**
  72475. * Callback called when the task is successful
  72476. */
  72477. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  72478. /**
  72479. * Creates a new MeshAssetTask
  72480. * @param name defines the name of the task
  72481. * @param meshesNames defines the list of mesh's names you want to load
  72482. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  72483. * @param sceneFilename defines the filename or File of the scene to load from
  72484. */
  72485. constructor(
  72486. /**
  72487. * Defines the name of the task
  72488. */
  72489. name: string,
  72490. /**
  72491. * Defines the list of mesh's names you want to load
  72492. */
  72493. meshesNames: any,
  72494. /**
  72495. * Defines the root url to use as a base to load your meshes and associated resources
  72496. */
  72497. rootUrl: string,
  72498. /**
  72499. * Defines the filename or File of the scene to load from
  72500. */
  72501. sceneFilename: string | File);
  72502. /**
  72503. * Execute the current task
  72504. * @param scene defines the scene where you want your assets to be loaded
  72505. * @param onSuccess is a callback called when the task is successfully executed
  72506. * @param onError is a callback called if an error occurs
  72507. */
  72508. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72509. }
  72510. /**
  72511. * Define a task used by AssetsManager to load text content
  72512. */
  72513. export class TextFileAssetTask extends AbstractAssetTask {
  72514. /**
  72515. * Defines the name of the task
  72516. */
  72517. name: string;
  72518. /**
  72519. * Defines the location of the file to load
  72520. */
  72521. url: string;
  72522. /**
  72523. * Gets the loaded text string
  72524. */
  72525. text: string;
  72526. /**
  72527. * Callback called when the task is successful
  72528. */
  72529. onSuccess: (task: TextFileAssetTask) => void;
  72530. /**
  72531. * Callback called when the task is successful
  72532. */
  72533. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  72534. /**
  72535. * Creates a new TextFileAssetTask object
  72536. * @param name defines the name of the task
  72537. * @param url defines the location of the file to load
  72538. */
  72539. constructor(
  72540. /**
  72541. * Defines the name of the task
  72542. */
  72543. name: string,
  72544. /**
  72545. * Defines the location of the file to load
  72546. */
  72547. url: string);
  72548. /**
  72549. * Execute the current task
  72550. * @param scene defines the scene where you want your assets to be loaded
  72551. * @param onSuccess is a callback called when the task is successfully executed
  72552. * @param onError is a callback called if an error occurs
  72553. */
  72554. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72555. }
  72556. /**
  72557. * Define a task used by AssetsManager to load binary data
  72558. */
  72559. export class BinaryFileAssetTask extends AbstractAssetTask {
  72560. /**
  72561. * Defines the name of the task
  72562. */
  72563. name: string;
  72564. /**
  72565. * Defines the location of the file to load
  72566. */
  72567. url: string;
  72568. /**
  72569. * Gets the lodaded data (as an array buffer)
  72570. */
  72571. data: ArrayBuffer;
  72572. /**
  72573. * Callback called when the task is successful
  72574. */
  72575. onSuccess: (task: BinaryFileAssetTask) => void;
  72576. /**
  72577. * Callback called when the task is successful
  72578. */
  72579. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  72580. /**
  72581. * Creates a new BinaryFileAssetTask object
  72582. * @param name defines the name of the new task
  72583. * @param url defines the location of the file to load
  72584. */
  72585. constructor(
  72586. /**
  72587. * Defines the name of the task
  72588. */
  72589. name: string,
  72590. /**
  72591. * Defines the location of the file to load
  72592. */
  72593. url: string);
  72594. /**
  72595. * Execute the current task
  72596. * @param scene defines the scene where you want your assets to be loaded
  72597. * @param onSuccess is a callback called when the task is successfully executed
  72598. * @param onError is a callback called if an error occurs
  72599. */
  72600. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72601. }
  72602. /**
  72603. * Define a task used by AssetsManager to load images
  72604. */
  72605. export class ImageAssetTask extends AbstractAssetTask {
  72606. /**
  72607. * Defines the name of the task
  72608. */
  72609. name: string;
  72610. /**
  72611. * Defines the location of the image to load
  72612. */
  72613. url: string;
  72614. /**
  72615. * Gets the loaded images
  72616. */
  72617. image: HTMLImageElement;
  72618. /**
  72619. * Callback called when the task is successful
  72620. */
  72621. onSuccess: (task: ImageAssetTask) => void;
  72622. /**
  72623. * Callback called when the task is successful
  72624. */
  72625. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  72626. /**
  72627. * Creates a new ImageAssetTask
  72628. * @param name defines the name of the task
  72629. * @param url defines the location of the image to load
  72630. */
  72631. constructor(
  72632. /**
  72633. * Defines the name of the task
  72634. */
  72635. name: string,
  72636. /**
  72637. * Defines the location of the image to load
  72638. */
  72639. url: string);
  72640. /**
  72641. * Execute the current task
  72642. * @param scene defines the scene where you want your assets to be loaded
  72643. * @param onSuccess is a callback called when the task is successfully executed
  72644. * @param onError is a callback called if an error occurs
  72645. */
  72646. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72647. }
  72648. /**
  72649. * Defines the interface used by texture loading tasks
  72650. */
  72651. export interface ITextureAssetTask<TEX extends BaseTexture> {
  72652. /**
  72653. * Gets the loaded texture
  72654. */
  72655. texture: TEX;
  72656. }
  72657. /**
  72658. * Define a task used by AssetsManager to load 2D textures
  72659. */
  72660. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  72661. /**
  72662. * Defines the name of the task
  72663. */
  72664. name: string;
  72665. /**
  72666. * Defines the location of the file to load
  72667. */
  72668. url: string;
  72669. /**
  72670. * Defines if mipmap should not be generated (default is false)
  72671. */
  72672. noMipmap?: boolean | undefined;
  72673. /**
  72674. * Defines if texture must be inverted on Y axis (default is true)
  72675. */
  72676. invertY: boolean;
  72677. /**
  72678. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72679. */
  72680. samplingMode: number;
  72681. /**
  72682. * Gets the loaded texture
  72683. */
  72684. texture: Texture;
  72685. /**
  72686. * Callback called when the task is successful
  72687. */
  72688. onSuccess: (task: TextureAssetTask) => void;
  72689. /**
  72690. * Callback called when the task is successful
  72691. */
  72692. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  72693. /**
  72694. * Creates a new TextureAssetTask object
  72695. * @param name defines the name of the task
  72696. * @param url defines the location of the file to load
  72697. * @param noMipmap defines if mipmap should not be generated (default is false)
  72698. * @param invertY defines if texture must be inverted on Y axis (default is true)
  72699. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72700. */
  72701. constructor(
  72702. /**
  72703. * Defines the name of the task
  72704. */
  72705. name: string,
  72706. /**
  72707. * Defines the location of the file to load
  72708. */
  72709. url: string,
  72710. /**
  72711. * Defines if mipmap should not be generated (default is false)
  72712. */
  72713. noMipmap?: boolean | undefined,
  72714. /**
  72715. * Defines if texture must be inverted on Y axis (default is true)
  72716. */
  72717. invertY?: boolean,
  72718. /**
  72719. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72720. */
  72721. samplingMode?: number);
  72722. /**
  72723. * Execute the current task
  72724. * @param scene defines the scene where you want your assets to be loaded
  72725. * @param onSuccess is a callback called when the task is successfully executed
  72726. * @param onError is a callback called if an error occurs
  72727. */
  72728. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72729. }
  72730. /**
  72731. * Define a task used by AssetsManager to load cube textures
  72732. */
  72733. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  72734. /**
  72735. * Defines the name of the task
  72736. */
  72737. name: string;
  72738. /**
  72739. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72740. */
  72741. url: string;
  72742. /**
  72743. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72744. */
  72745. extensions?: string[] | undefined;
  72746. /**
  72747. * Defines if mipmaps should not be generated (default is false)
  72748. */
  72749. noMipmap?: boolean | undefined;
  72750. /**
  72751. * Defines the explicit list of files (undefined by default)
  72752. */
  72753. files?: string[] | undefined;
  72754. /**
  72755. * Gets the loaded texture
  72756. */
  72757. texture: CubeTexture;
  72758. /**
  72759. * Callback called when the task is successful
  72760. */
  72761. onSuccess: (task: CubeTextureAssetTask) => void;
  72762. /**
  72763. * Callback called when the task is successful
  72764. */
  72765. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  72766. /**
  72767. * Creates a new CubeTextureAssetTask
  72768. * @param name defines the name of the task
  72769. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72770. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72771. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72772. * @param files defines the explicit list of files (undefined by default)
  72773. */
  72774. constructor(
  72775. /**
  72776. * Defines the name of the task
  72777. */
  72778. name: string,
  72779. /**
  72780. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72781. */
  72782. url: string,
  72783. /**
  72784. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72785. */
  72786. extensions?: string[] | undefined,
  72787. /**
  72788. * Defines if mipmaps should not be generated (default is false)
  72789. */
  72790. noMipmap?: boolean | undefined,
  72791. /**
  72792. * Defines the explicit list of files (undefined by default)
  72793. */
  72794. files?: string[] | undefined);
  72795. /**
  72796. * Execute the current task
  72797. * @param scene defines the scene where you want your assets to be loaded
  72798. * @param onSuccess is a callback called when the task is successfully executed
  72799. * @param onError is a callback called if an error occurs
  72800. */
  72801. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72802. }
  72803. /**
  72804. * Define a task used by AssetsManager to load HDR cube textures
  72805. */
  72806. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  72807. /**
  72808. * Defines the name of the task
  72809. */
  72810. name: string;
  72811. /**
  72812. * Defines the location of the file to load
  72813. */
  72814. url: string;
  72815. /**
  72816. * Defines the desired size (the more it increases the longer the generation will be)
  72817. */
  72818. size: number;
  72819. /**
  72820. * Defines if mipmaps should not be generated (default is false)
  72821. */
  72822. noMipmap: boolean;
  72823. /**
  72824. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72825. */
  72826. generateHarmonics: boolean;
  72827. /**
  72828. * 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)
  72829. */
  72830. gammaSpace: boolean;
  72831. /**
  72832. * Internal Use Only
  72833. */
  72834. reserved: boolean;
  72835. /**
  72836. * Gets the loaded texture
  72837. */
  72838. texture: HDRCubeTexture;
  72839. /**
  72840. * Callback called when the task is successful
  72841. */
  72842. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  72843. /**
  72844. * Callback called when the task is successful
  72845. */
  72846. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  72847. /**
  72848. * Creates a new HDRCubeTextureAssetTask object
  72849. * @param name defines the name of the task
  72850. * @param url defines the location of the file to load
  72851. * @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.
  72852. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72853. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72854. * @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)
  72855. * @param reserved Internal use only
  72856. */
  72857. constructor(
  72858. /**
  72859. * Defines the name of the task
  72860. */
  72861. name: string,
  72862. /**
  72863. * Defines the location of the file to load
  72864. */
  72865. url: string,
  72866. /**
  72867. * Defines the desired size (the more it increases the longer the generation will be)
  72868. */
  72869. size: number,
  72870. /**
  72871. * Defines if mipmaps should not be generated (default is false)
  72872. */
  72873. noMipmap?: boolean,
  72874. /**
  72875. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72876. */
  72877. generateHarmonics?: boolean,
  72878. /**
  72879. * 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)
  72880. */
  72881. gammaSpace?: boolean,
  72882. /**
  72883. * Internal Use Only
  72884. */
  72885. reserved?: boolean);
  72886. /**
  72887. * Execute the current task
  72888. * @param scene defines the scene where you want your assets to be loaded
  72889. * @param onSuccess is a callback called when the task is successfully executed
  72890. * @param onError is a callback called if an error occurs
  72891. */
  72892. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72893. }
  72894. /**
  72895. * Define a task used by AssetsManager to load Equirectangular cube textures
  72896. */
  72897. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  72898. /**
  72899. * Defines the name of the task
  72900. */
  72901. name: string;
  72902. /**
  72903. * Defines the location of the file to load
  72904. */
  72905. url: string;
  72906. /**
  72907. * Defines the desired size (the more it increases the longer the generation will be)
  72908. */
  72909. size: number;
  72910. /**
  72911. * Defines if mipmaps should not be generated (default is false)
  72912. */
  72913. noMipmap: boolean;
  72914. /**
  72915. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72916. * but the standard material would require them in Gamma space) (default is true)
  72917. */
  72918. gammaSpace: boolean;
  72919. /**
  72920. * Gets the loaded texture
  72921. */
  72922. texture: EquiRectangularCubeTexture;
  72923. /**
  72924. * Callback called when the task is successful
  72925. */
  72926. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  72927. /**
  72928. * Callback called when the task is successful
  72929. */
  72930. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  72931. /**
  72932. * Creates a new EquiRectangularCubeTextureAssetTask object
  72933. * @param name defines the name of the task
  72934. * @param url defines the location of the file to load
  72935. * @param size defines the desired size (the more it increases the longer the generation will be)
  72936. * 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 gammaSpace specifies if the texture will be used in gamma or linear space
  72939. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  72940. * (default is true)
  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 if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72961. * but the standard material would require them in Gamma space) (default is true)
  72962. */
  72963. gammaSpace?: boolean);
  72964. /**
  72965. * Execute the current task
  72966. * @param scene defines the scene where you want your assets to be loaded
  72967. * @param onSuccess is a callback called when the task is successfully executed
  72968. * @param onError is a callback called if an error occurs
  72969. */
  72970. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72971. }
  72972. /**
  72973. * This class can be used to easily import assets into a scene
  72974. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  72975. */
  72976. export class AssetsManager {
  72977. private _scene;
  72978. private _isLoading;
  72979. protected _tasks: AbstractAssetTask[];
  72980. protected _waitingTasksCount: number;
  72981. protected _totalTasksCount: number;
  72982. /**
  72983. * Callback called when all tasks are processed
  72984. */
  72985. onFinish: (tasks: AbstractAssetTask[]) => void;
  72986. /**
  72987. * Callback called when a task is successful
  72988. */
  72989. onTaskSuccess: (task: AbstractAssetTask) => void;
  72990. /**
  72991. * Callback called when a task had an error
  72992. */
  72993. onTaskError: (task: AbstractAssetTask) => void;
  72994. /**
  72995. * Callback called when a task is done (whatever the result is)
  72996. */
  72997. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  72998. /**
  72999. * Observable called when all tasks are processed
  73000. */
  73001. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  73002. /**
  73003. * Observable called when a task had an error
  73004. */
  73005. onTaskErrorObservable: Observable<AbstractAssetTask>;
  73006. /**
  73007. * Observable called when all tasks were executed
  73008. */
  73009. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  73010. /**
  73011. * Observable called when a task is done (whatever the result is)
  73012. */
  73013. onProgressObservable: Observable<IAssetsProgressEvent>;
  73014. /**
  73015. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  73016. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  73017. */
  73018. useDefaultLoadingScreen: boolean;
  73019. /**
  73020. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  73021. * when all assets have been downloaded.
  73022. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  73023. */
  73024. autoHideLoadingUI: boolean;
  73025. /**
  73026. * Creates a new AssetsManager
  73027. * @param scene defines the scene to work on
  73028. */
  73029. constructor(scene: Scene);
  73030. /**
  73031. * Add a ContainerAssetTask to the list of active tasks
  73032. * @param taskName defines the name of the new task
  73033. * @param meshesNames defines the name of meshes to load
  73034. * @param rootUrl defines the root url to use to locate files
  73035. * @param sceneFilename defines the filename of the scene file
  73036. * @returns a new ContainerAssetTask object
  73037. */
  73038. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  73039. /**
  73040. * Add a MeshAssetTask to the list of active tasks
  73041. * @param taskName defines the name of the new task
  73042. * @param meshesNames defines the name of meshes to load
  73043. * @param rootUrl defines the root url to use to locate files
  73044. * @param sceneFilename defines the filename of the scene file
  73045. * @returns a new MeshAssetTask object
  73046. */
  73047. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  73048. /**
  73049. * Add a TextFileAssetTask to the list of active tasks
  73050. * @param taskName defines the name of the new task
  73051. * @param url defines the url of the file to load
  73052. * @returns a new TextFileAssetTask object
  73053. */
  73054. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  73055. /**
  73056. * Add a BinaryFileAssetTask to the list of active tasks
  73057. * @param taskName defines the name of the new task
  73058. * @param url defines the url of the file to load
  73059. * @returns a new BinaryFileAssetTask object
  73060. */
  73061. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  73062. /**
  73063. * Add a ImageAssetTask to the list of active tasks
  73064. * @param taskName defines the name of the new task
  73065. * @param url defines the url of the file to load
  73066. * @returns a new ImageAssetTask object
  73067. */
  73068. addImageTask(taskName: string, url: string): ImageAssetTask;
  73069. /**
  73070. * Add a TextureAssetTask to the list of active tasks
  73071. * @param taskName defines the name of the new task
  73072. * @param url defines the url of the file to load
  73073. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73074. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  73075. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  73076. * @returns a new TextureAssetTask object
  73077. */
  73078. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  73079. /**
  73080. * Add a CubeTextureAssetTask to the list of active tasks
  73081. * @param taskName defines the name of the new task
  73082. * @param url defines the url of the file to load
  73083. * @param extensions defines the extension to use to load the cube map (can be null)
  73084. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73085. * @param files defines the list of files to load (can be null)
  73086. * @returns a new CubeTextureAssetTask object
  73087. */
  73088. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  73089. /**
  73090. *
  73091. * Add a HDRCubeTextureAssetTask to the list of active tasks
  73092. * @param taskName defines the name of the new task
  73093. * @param url defines the url of the file to load
  73094. * @param size defines the size you want for the cubemap (can be null)
  73095. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73096. * @param generateHarmonics defines if you want to automatically generate (true by default)
  73097. * @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)
  73098. * @param reserved Internal use only
  73099. * @returns a new HDRCubeTextureAssetTask object
  73100. */
  73101. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  73102. /**
  73103. *
  73104. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  73105. * @param taskName defines the name of the new task
  73106. * @param url defines the url of the file to load
  73107. * @param size defines the size you want for the cubemap (can be null)
  73108. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73109. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  73110. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  73111. * @returns a new EquiRectangularCubeTextureAssetTask object
  73112. */
  73113. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  73114. /**
  73115. * Remove a task from the assets manager.
  73116. * @param task the task to remove
  73117. */
  73118. removeTask(task: AbstractAssetTask): void;
  73119. private _decreaseWaitingTasksCount;
  73120. private _runTask;
  73121. /**
  73122. * Reset the AssetsManager and remove all tasks
  73123. * @return the current instance of the AssetsManager
  73124. */
  73125. reset(): AssetsManager;
  73126. /**
  73127. * Start the loading process
  73128. * @return the current instance of the AssetsManager
  73129. */
  73130. load(): AssetsManager;
  73131. /**
  73132. * Start the loading process as an async operation
  73133. * @return a promise returning the list of failed tasks
  73134. */
  73135. loadAsync(): Promise<void>;
  73136. }
  73137. }
  73138. declare module BABYLON {
  73139. /**
  73140. * Wrapper class for promise with external resolve and reject.
  73141. */
  73142. export class Deferred<T> {
  73143. /**
  73144. * The promise associated with this deferred object.
  73145. */
  73146. readonly promise: Promise<T>;
  73147. private _resolve;
  73148. private _reject;
  73149. /**
  73150. * The resolve method of the promise associated with this deferred object.
  73151. */
  73152. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  73153. /**
  73154. * The reject method of the promise associated with this deferred object.
  73155. */
  73156. get reject(): (reason?: any) => void;
  73157. /**
  73158. * Constructor for this deferred object.
  73159. */
  73160. constructor();
  73161. }
  73162. }
  73163. declare module BABYLON {
  73164. /**
  73165. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  73166. */
  73167. export class MeshExploder {
  73168. private _centerMesh;
  73169. private _meshes;
  73170. private _meshesOrigins;
  73171. private _toCenterVectors;
  73172. private _scaledDirection;
  73173. private _newPosition;
  73174. private _centerPosition;
  73175. /**
  73176. * Explodes meshes from a center mesh.
  73177. * @param meshes The meshes to explode.
  73178. * @param centerMesh The mesh to be center of explosion.
  73179. */
  73180. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  73181. private _setCenterMesh;
  73182. /**
  73183. * Get class name
  73184. * @returns "MeshExploder"
  73185. */
  73186. getClassName(): string;
  73187. /**
  73188. * "Exploded meshes"
  73189. * @returns Array of meshes with the centerMesh at index 0.
  73190. */
  73191. getMeshes(): Array<Mesh>;
  73192. /**
  73193. * Explodes meshes giving a specific direction
  73194. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  73195. */
  73196. explode(direction?: number): void;
  73197. }
  73198. }
  73199. declare module BABYLON {
  73200. /**
  73201. * Class used to help managing file picking and drag'n'drop
  73202. */
  73203. export class FilesInput {
  73204. /**
  73205. * List of files ready to be loaded
  73206. */
  73207. static get FilesToLoad(): {
  73208. [key: string]: File;
  73209. };
  73210. /**
  73211. * Callback called when a file is processed
  73212. */
  73213. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  73214. private _engine;
  73215. private _currentScene;
  73216. private _sceneLoadedCallback;
  73217. private _progressCallback;
  73218. private _additionalRenderLoopLogicCallback;
  73219. private _textureLoadingCallback;
  73220. private _startingProcessingFilesCallback;
  73221. private _onReloadCallback;
  73222. private _errorCallback;
  73223. private _elementToMonitor;
  73224. private _sceneFileToLoad;
  73225. private _filesToLoad;
  73226. /**
  73227. * Creates a new FilesInput
  73228. * @param engine defines the rendering engine
  73229. * @param scene defines the hosting scene
  73230. * @param sceneLoadedCallback callback called when scene is loaded
  73231. * @param progressCallback callback called to track progress
  73232. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  73233. * @param textureLoadingCallback callback called when a texture is loading
  73234. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  73235. * @param onReloadCallback callback called when a reload is requested
  73236. * @param errorCallback callback call if an error occurs
  73237. */
  73238. 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>);
  73239. private _dragEnterHandler;
  73240. private _dragOverHandler;
  73241. private _dropHandler;
  73242. /**
  73243. * Calls this function to listen to drag'n'drop events on a specific DOM element
  73244. * @param elementToMonitor defines the DOM element to track
  73245. */
  73246. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  73247. /** Gets the current list of files to load */
  73248. get filesToLoad(): File[];
  73249. /**
  73250. * Release all associated resources
  73251. */
  73252. dispose(): void;
  73253. private renderFunction;
  73254. private drag;
  73255. private drop;
  73256. private _traverseFolder;
  73257. private _processFiles;
  73258. /**
  73259. * Load files from a drop event
  73260. * @param event defines the drop event to use as source
  73261. */
  73262. loadFiles(event: any): void;
  73263. private _processReload;
  73264. /**
  73265. * Reload the current scene from the loaded files
  73266. */
  73267. reload(): void;
  73268. }
  73269. }
  73270. declare module BABYLON {
  73271. /**
  73272. * Defines the root class used to create scene optimization to use with SceneOptimizer
  73273. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73274. */
  73275. export class SceneOptimization {
  73276. /**
  73277. * Defines the priority of this optimization (0 by default which means first in the list)
  73278. */
  73279. priority: number;
  73280. /**
  73281. * Gets a string describing the action executed by the current optimization
  73282. * @returns description string
  73283. */
  73284. getDescription(): string;
  73285. /**
  73286. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73287. * @param scene defines the current scene where to apply this optimization
  73288. * @param optimizer defines the current optimizer
  73289. * @returns true if everything that can be done was applied
  73290. */
  73291. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73292. /**
  73293. * Creates the SceneOptimization object
  73294. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73295. * @param desc defines the description associated with the optimization
  73296. */
  73297. constructor(
  73298. /**
  73299. * Defines the priority of this optimization (0 by default which means first in the list)
  73300. */
  73301. priority?: number);
  73302. }
  73303. /**
  73304. * Defines an optimization used to reduce the size of render target textures
  73305. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73306. */
  73307. export class TextureOptimization extends SceneOptimization {
  73308. /**
  73309. * Defines the priority of this optimization (0 by default which means first in the list)
  73310. */
  73311. priority: number;
  73312. /**
  73313. * 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
  73314. */
  73315. maximumSize: number;
  73316. /**
  73317. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73318. */
  73319. step: number;
  73320. /**
  73321. * Gets a string describing the action executed by the current optimization
  73322. * @returns description string
  73323. */
  73324. getDescription(): string;
  73325. /**
  73326. * Creates the TextureOptimization object
  73327. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73328. * @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
  73329. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73330. */
  73331. constructor(
  73332. /**
  73333. * Defines the priority of this optimization (0 by default which means first in the list)
  73334. */
  73335. priority?: number,
  73336. /**
  73337. * 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
  73338. */
  73339. maximumSize?: number,
  73340. /**
  73341. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73342. */
  73343. step?: number);
  73344. /**
  73345. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73346. * @param scene defines the current scene where to apply this optimization
  73347. * @param optimizer defines the current optimizer
  73348. * @returns true if everything that can be done was applied
  73349. */
  73350. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73351. }
  73352. /**
  73353. * Defines an optimization used to increase or decrease the rendering resolution
  73354. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73355. */
  73356. export class HardwareScalingOptimization extends SceneOptimization {
  73357. /**
  73358. * Defines the priority of this optimization (0 by default which means first in the list)
  73359. */
  73360. priority: number;
  73361. /**
  73362. * Defines the maximum scale to use (2 by default)
  73363. */
  73364. maximumScale: number;
  73365. /**
  73366. * Defines the step to use between two passes (0.5 by default)
  73367. */
  73368. step: number;
  73369. private _currentScale;
  73370. private _directionOffset;
  73371. /**
  73372. * Gets a string describing the action executed by the current optimization
  73373. * @return description string
  73374. */
  73375. getDescription(): string;
  73376. /**
  73377. * Creates the HardwareScalingOptimization object
  73378. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73379. * @param maximumScale defines the maximum scale to use (2 by default)
  73380. * @param step defines the step to use between two passes (0.5 by default)
  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. * Defines the maximum scale to use (2 by default)
  73389. */
  73390. maximumScale?: number,
  73391. /**
  73392. * Defines the step to use between two passes (0.5 by default)
  73393. */
  73394. step?: number);
  73395. /**
  73396. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73397. * @param scene defines the current scene where to apply this optimization
  73398. * @param optimizer defines the current optimizer
  73399. * @returns true if everything that can be done was applied
  73400. */
  73401. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73402. }
  73403. /**
  73404. * Defines an optimization used to remove shadows
  73405. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73406. */
  73407. export class ShadowsOptimization extends SceneOptimization {
  73408. /**
  73409. * Gets a string describing the action executed by the current optimization
  73410. * @return description string
  73411. */
  73412. getDescription(): string;
  73413. /**
  73414. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73415. * @param scene defines the current scene where to apply this optimization
  73416. * @param optimizer defines the current optimizer
  73417. * @returns true if everything that can be done was applied
  73418. */
  73419. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73420. }
  73421. /**
  73422. * Defines an optimization used to turn post-processes off
  73423. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73424. */
  73425. export class PostProcessesOptimization extends SceneOptimization {
  73426. /**
  73427. * Gets a string describing the action executed by the current optimization
  73428. * @return description string
  73429. */
  73430. getDescription(): string;
  73431. /**
  73432. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73433. * @param scene defines the current scene where to apply this optimization
  73434. * @param optimizer defines the current optimizer
  73435. * @returns true if everything that can be done was applied
  73436. */
  73437. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73438. }
  73439. /**
  73440. * Defines an optimization used to turn lens flares off
  73441. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73442. */
  73443. export class LensFlaresOptimization extends SceneOptimization {
  73444. /**
  73445. * Gets a string describing the action executed by the current optimization
  73446. * @return description string
  73447. */
  73448. getDescription(): string;
  73449. /**
  73450. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73451. * @param scene defines the current scene where to apply this optimization
  73452. * @param optimizer defines the current optimizer
  73453. * @returns true if everything that can be done was applied
  73454. */
  73455. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73456. }
  73457. /**
  73458. * Defines an optimization based on user defined callback.
  73459. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73460. */
  73461. export class CustomOptimization extends SceneOptimization {
  73462. /**
  73463. * Callback called to apply the custom optimization.
  73464. */
  73465. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  73466. /**
  73467. * Callback called to get custom description
  73468. */
  73469. onGetDescription: () => string;
  73470. /**
  73471. * Gets a string describing the action executed by the current optimization
  73472. * @returns description string
  73473. */
  73474. getDescription(): string;
  73475. /**
  73476. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73477. * @param scene defines the current scene where to apply this optimization
  73478. * @param optimizer defines the current optimizer
  73479. * @returns true if everything that can be done was applied
  73480. */
  73481. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73482. }
  73483. /**
  73484. * Defines an optimization used to turn particles off
  73485. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73486. */
  73487. export class ParticlesOptimization extends SceneOptimization {
  73488. /**
  73489. * Gets a string describing the action executed by the current optimization
  73490. * @return description string
  73491. */
  73492. getDescription(): string;
  73493. /**
  73494. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73495. * @param scene defines the current scene where to apply this optimization
  73496. * @param optimizer defines the current optimizer
  73497. * @returns true if everything that can be done was applied
  73498. */
  73499. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73500. }
  73501. /**
  73502. * Defines an optimization used to turn render targets off
  73503. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73504. */
  73505. export class RenderTargetsOptimization extends SceneOptimization {
  73506. /**
  73507. * Gets a string describing the action executed by the current optimization
  73508. * @return description string
  73509. */
  73510. getDescription(): string;
  73511. /**
  73512. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73513. * @param scene defines the current scene where to apply this optimization
  73514. * @param optimizer defines the current optimizer
  73515. * @returns true if everything that can be done was applied
  73516. */
  73517. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73518. }
  73519. /**
  73520. * Defines an optimization used to merge meshes with compatible materials
  73521. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73522. */
  73523. export class MergeMeshesOptimization extends SceneOptimization {
  73524. private static _UpdateSelectionTree;
  73525. /**
  73526. * Gets or sets a boolean which defines if optimization octree has to be updated
  73527. */
  73528. static get UpdateSelectionTree(): boolean;
  73529. /**
  73530. * Gets or sets a boolean which defines if optimization octree has to be updated
  73531. */
  73532. static set UpdateSelectionTree(value: boolean);
  73533. /**
  73534. * Gets a string describing the action executed by the current optimization
  73535. * @return description string
  73536. */
  73537. getDescription(): string;
  73538. private _canBeMerged;
  73539. /**
  73540. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73541. * @param scene defines the current scene where to apply this optimization
  73542. * @param optimizer defines the current optimizer
  73543. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  73544. * @returns true if everything that can be done was applied
  73545. */
  73546. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  73547. }
  73548. /**
  73549. * Defines a list of options used by SceneOptimizer
  73550. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73551. */
  73552. export class SceneOptimizerOptions {
  73553. /**
  73554. * Defines the target frame rate to reach (60 by default)
  73555. */
  73556. targetFrameRate: number;
  73557. /**
  73558. * Defines the interval between two checkes (2000ms by default)
  73559. */
  73560. trackerDuration: number;
  73561. /**
  73562. * Gets the list of optimizations to apply
  73563. */
  73564. optimizations: SceneOptimization[];
  73565. /**
  73566. * Creates a new list of options used by SceneOptimizer
  73567. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  73568. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  73569. */
  73570. constructor(
  73571. /**
  73572. * Defines the target frame rate to reach (60 by default)
  73573. */
  73574. targetFrameRate?: number,
  73575. /**
  73576. * Defines the interval between two checkes (2000ms by default)
  73577. */
  73578. trackerDuration?: number);
  73579. /**
  73580. * Add a new optimization
  73581. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  73582. * @returns the current SceneOptimizerOptions
  73583. */
  73584. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  73585. /**
  73586. * Add a new custom optimization
  73587. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  73588. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  73589. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73590. * @returns the current SceneOptimizerOptions
  73591. */
  73592. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  73593. /**
  73594. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  73595. * @param targetFrameRate defines the target frame rate (60 by default)
  73596. * @returns a SceneOptimizerOptions object
  73597. */
  73598. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73599. /**
  73600. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  73601. * @param targetFrameRate defines the target frame rate (60 by default)
  73602. * @returns a SceneOptimizerOptions object
  73603. */
  73604. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73605. /**
  73606. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  73607. * @param targetFrameRate defines the target frame rate (60 by default)
  73608. * @returns a SceneOptimizerOptions object
  73609. */
  73610. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73611. }
  73612. /**
  73613. * Class used to run optimizations in order to reach a target frame rate
  73614. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73615. */
  73616. export class SceneOptimizer implements IDisposable {
  73617. private _isRunning;
  73618. private _options;
  73619. private _scene;
  73620. private _currentPriorityLevel;
  73621. private _targetFrameRate;
  73622. private _trackerDuration;
  73623. private _currentFrameRate;
  73624. private _sceneDisposeObserver;
  73625. private _improvementMode;
  73626. /**
  73627. * Defines an observable called when the optimizer reaches the target frame rate
  73628. */
  73629. onSuccessObservable: Observable<SceneOptimizer>;
  73630. /**
  73631. * Defines an observable called when the optimizer enables an optimization
  73632. */
  73633. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  73634. /**
  73635. * Defines an observable called when the optimizer is not able to reach the target frame rate
  73636. */
  73637. onFailureObservable: Observable<SceneOptimizer>;
  73638. /**
  73639. * Gets a boolean indicating if the optimizer is in improvement mode
  73640. */
  73641. get isInImprovementMode(): boolean;
  73642. /**
  73643. * Gets the current priority level (0 at start)
  73644. */
  73645. get currentPriorityLevel(): number;
  73646. /**
  73647. * Gets the current frame rate checked by the SceneOptimizer
  73648. */
  73649. get currentFrameRate(): number;
  73650. /**
  73651. * Gets or sets the current target frame rate (60 by default)
  73652. */
  73653. get targetFrameRate(): number;
  73654. /**
  73655. * Gets or sets the current target frame rate (60 by default)
  73656. */
  73657. set targetFrameRate(value: number);
  73658. /**
  73659. * Gets or sets the current interval between two checks (every 2000ms by default)
  73660. */
  73661. get trackerDuration(): number;
  73662. /**
  73663. * Gets or sets the current interval between two checks (every 2000ms by default)
  73664. */
  73665. set trackerDuration(value: number);
  73666. /**
  73667. * Gets the list of active optimizations
  73668. */
  73669. get optimizations(): SceneOptimization[];
  73670. /**
  73671. * Creates a new SceneOptimizer
  73672. * @param scene defines the scene to work on
  73673. * @param options defines the options to use with the SceneOptimizer
  73674. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  73675. * @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)
  73676. */
  73677. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  73678. /**
  73679. * Stops the current optimizer
  73680. */
  73681. stop(): void;
  73682. /**
  73683. * Reset the optimizer to initial step (current priority level = 0)
  73684. */
  73685. reset(): void;
  73686. /**
  73687. * Start the optimizer. By default it will try to reach a specific framerate
  73688. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  73689. */
  73690. start(): void;
  73691. private _checkCurrentState;
  73692. /**
  73693. * Release all resources
  73694. */
  73695. dispose(): void;
  73696. /**
  73697. * Helper function to create a SceneOptimizer with one single line of code
  73698. * @param scene defines the scene to work on
  73699. * @param options defines the options to use with the SceneOptimizer
  73700. * @param onSuccess defines a callback to call on success
  73701. * @param onFailure defines a callback to call on failure
  73702. * @returns the new SceneOptimizer object
  73703. */
  73704. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  73705. }
  73706. }
  73707. declare module BABYLON {
  73708. /**
  73709. * Class used to serialize a scene into a string
  73710. */
  73711. export class SceneSerializer {
  73712. /**
  73713. * Clear cache used by a previous serialization
  73714. */
  73715. static ClearCache(): void;
  73716. /**
  73717. * Serialize a scene into a JSON compatible object
  73718. * @param scene defines the scene to serialize
  73719. * @returns a JSON compatible object
  73720. */
  73721. static Serialize(scene: Scene): any;
  73722. /**
  73723. * Serialize a mesh into a JSON compatible object
  73724. * @param toSerialize defines the mesh to serialize
  73725. * @param withParents defines if parents must be serialized as well
  73726. * @param withChildren defines if children must be serialized as well
  73727. * @returns a JSON compatible object
  73728. */
  73729. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  73730. }
  73731. }
  73732. declare module BABYLON {
  73733. /**
  73734. * Class used to host texture specific utilities
  73735. */
  73736. export class TextureTools {
  73737. /**
  73738. * Uses the GPU to create a copy texture rescaled at a given size
  73739. * @param texture Texture to copy from
  73740. * @param width defines the desired width
  73741. * @param height defines the desired height
  73742. * @param useBilinearMode defines if bilinear mode has to be used
  73743. * @return the generated texture
  73744. */
  73745. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  73746. }
  73747. }
  73748. declare module BABYLON {
  73749. /**
  73750. * This represents the different options available for the video capture.
  73751. */
  73752. export interface VideoRecorderOptions {
  73753. /** Defines the mime type of the video. */
  73754. mimeType: string;
  73755. /** Defines the FPS the video should be recorded at. */
  73756. fps: number;
  73757. /** Defines the chunk size for the recording data. */
  73758. recordChunckSize: number;
  73759. /** The audio tracks to attach to the recording. */
  73760. audioTracks?: MediaStreamTrack[];
  73761. }
  73762. /**
  73763. * This can help with recording videos from BabylonJS.
  73764. * This is based on the available WebRTC functionalities of the browser.
  73765. *
  73766. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  73767. */
  73768. export class VideoRecorder {
  73769. private static readonly _defaultOptions;
  73770. /**
  73771. * Returns whether or not the VideoRecorder is available in your browser.
  73772. * @param engine Defines the Babylon Engine.
  73773. * @returns true if supported otherwise false.
  73774. */
  73775. static IsSupported(engine: Engine): boolean;
  73776. private readonly _options;
  73777. private _canvas;
  73778. private _mediaRecorder;
  73779. private _recordedChunks;
  73780. private _fileName;
  73781. private _resolve;
  73782. private _reject;
  73783. /**
  73784. * True when a recording is already in progress.
  73785. */
  73786. get isRecording(): boolean;
  73787. /**
  73788. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  73789. * @param engine Defines the BabylonJS Engine you wish to record.
  73790. * @param options Defines options that can be used to customize the capture.
  73791. */
  73792. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  73793. /**
  73794. * Stops the current recording before the default capture timeout passed in the startRecording function.
  73795. */
  73796. stopRecording(): void;
  73797. /**
  73798. * Starts recording the canvas for a max duration specified in parameters.
  73799. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  73800. * If null no automatic download will start and you can rely on the promise to get the data back.
  73801. * @param maxDuration Defines the maximum recording time in seconds.
  73802. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  73803. * @return A promise callback at the end of the recording with the video data in Blob.
  73804. */
  73805. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  73806. /**
  73807. * Releases internal resources used during the recording.
  73808. */
  73809. dispose(): void;
  73810. private _handleDataAvailable;
  73811. private _handleError;
  73812. private _handleStop;
  73813. }
  73814. }
  73815. declare module BABYLON {
  73816. /**
  73817. * Class containing a set of static utilities functions for screenshots
  73818. */
  73819. export class ScreenshotTools {
  73820. /**
  73821. * Captures a screenshot of the current rendering
  73822. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73823. * @param engine defines the rendering engine
  73824. * @param camera defines the source camera
  73825. * @param size This parameter can be set to a single number or to an object with the
  73826. * following (optional) properties: precision, width, height. If a single number is passed,
  73827. * it will be used for both width and height. If an object is passed, the screenshot size
  73828. * will be derived from the parameters. The precision property is a multiplier allowing
  73829. * rendering at a higher or lower resolution
  73830. * @param successCallback defines the callback receives a single parameter which contains the
  73831. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73832. * src parameter of an <img> to display it
  73833. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73834. * Check your browser for supported MIME types
  73835. */
  73836. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  73837. /**
  73838. * Captures a screenshot of the current rendering
  73839. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73840. * @param engine defines the rendering engine
  73841. * @param camera defines the source camera
  73842. * @param size This parameter can be set to a single number or to an object with the
  73843. * following (optional) properties: precision, width, height. If a single number is passed,
  73844. * it will be used for both width and height. If an object is passed, the screenshot size
  73845. * will be derived from the parameters. The precision property is a multiplier allowing
  73846. * rendering at a higher or lower resolution
  73847. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73848. * Check your browser for supported MIME types
  73849. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73850. * to the src parameter of an <img> to display it
  73851. */
  73852. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  73853. /**
  73854. * Generates an image screenshot from the specified camera.
  73855. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73856. * @param engine The engine to use for rendering
  73857. * @param camera The camera to use for rendering
  73858. * @param size This parameter can be set to a single number or to an object with the
  73859. * following (optional) properties: precision, width, height. If a single number is passed,
  73860. * it will be used for both width and height. If an object is passed, the screenshot size
  73861. * will be derived from the parameters. The precision property is a multiplier allowing
  73862. * rendering at a higher or lower resolution
  73863. * @param successCallback The callback receives a single parameter which contains the
  73864. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73865. * src parameter of an <img> to display it
  73866. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73867. * Check your browser for supported MIME types
  73868. * @param samples Texture samples (default: 1)
  73869. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73870. * @param fileName A name for for the downloaded file.
  73871. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73872. */
  73873. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  73874. /**
  73875. * Generates an image screenshot from the specified camera.
  73876. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73877. * @param engine The engine to use for rendering
  73878. * @param camera The camera to use for rendering
  73879. * @param size This parameter can be set to a single number or to an object with the
  73880. * following (optional) properties: precision, width, height. If a single number is passed,
  73881. * it will be used for both width and height. If an object is passed, the screenshot size
  73882. * will be derived from the parameters. The precision property is a multiplier allowing
  73883. * rendering at a higher or lower resolution
  73884. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73885. * Check your browser for supported MIME types
  73886. * @param samples Texture samples (default: 1)
  73887. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73888. * @param fileName A name for for the downloaded file.
  73889. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73890. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73891. * to the src parameter of an <img> to display it
  73892. */
  73893. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  73894. /**
  73895. * Gets height and width for screenshot size
  73896. * @private
  73897. */
  73898. private static _getScreenshotSize;
  73899. }
  73900. }
  73901. declare module BABYLON {
  73902. /**
  73903. * Interface for a data buffer
  73904. */
  73905. export interface IDataBuffer {
  73906. /**
  73907. * Reads bytes from the data buffer.
  73908. * @param byteOffset The byte offset to read
  73909. * @param byteLength The byte length to read
  73910. * @returns A promise that resolves when the bytes are read
  73911. */
  73912. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  73913. /**
  73914. * The byte length of the buffer.
  73915. */
  73916. readonly byteLength: number;
  73917. }
  73918. /**
  73919. * Utility class for reading from a data buffer
  73920. */
  73921. export class DataReader {
  73922. /**
  73923. * The data buffer associated with this data reader.
  73924. */
  73925. readonly buffer: IDataBuffer;
  73926. /**
  73927. * The current byte offset from the beginning of the data buffer.
  73928. */
  73929. byteOffset: number;
  73930. private _dataView;
  73931. private _dataByteOffset;
  73932. /**
  73933. * Constructor
  73934. * @param buffer The buffer to read
  73935. */
  73936. constructor(buffer: IDataBuffer);
  73937. /**
  73938. * Loads the given byte length.
  73939. * @param byteLength The byte length to load
  73940. * @returns A promise that resolves when the load is complete
  73941. */
  73942. loadAsync(byteLength: number): Promise<void>;
  73943. /**
  73944. * Read a unsigned 32-bit integer from the currently loaded data range.
  73945. * @returns The 32-bit integer read
  73946. */
  73947. readUint32(): number;
  73948. /**
  73949. * Read a byte array from the currently loaded data range.
  73950. * @param byteLength The byte length to read
  73951. * @returns The byte array read
  73952. */
  73953. readUint8Array(byteLength: number): Uint8Array;
  73954. /**
  73955. * Read a string from the currently loaded data range.
  73956. * @param byteLength The byte length to read
  73957. * @returns The string read
  73958. */
  73959. readString(byteLength: number): string;
  73960. /**
  73961. * Skips the given byte length the currently loaded data range.
  73962. * @param byteLength The byte length to skip
  73963. */
  73964. skipBytes(byteLength: number): void;
  73965. }
  73966. }
  73967. declare module BABYLON {
  73968. /**
  73969. * Class for storing data to local storage if available or in-memory storage otherwise
  73970. */
  73971. export class DataStorage {
  73972. private static _Storage;
  73973. private static _GetStorage;
  73974. /**
  73975. * Reads a string from the data storage
  73976. * @param key The key to read
  73977. * @param defaultValue The value if the key doesn't exist
  73978. * @returns The string value
  73979. */
  73980. static ReadString(key: string, defaultValue: string): string;
  73981. /**
  73982. * Writes a string to the data storage
  73983. * @param key The key to write
  73984. * @param value The value to write
  73985. */
  73986. static WriteString(key: string, value: string): void;
  73987. /**
  73988. * Reads a boolean from the data storage
  73989. * @param key The key to read
  73990. * @param defaultValue The value if the key doesn't exist
  73991. * @returns The boolean value
  73992. */
  73993. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  73994. /**
  73995. * Writes a boolean to the data storage
  73996. * @param key The key to write
  73997. * @param value The value to write
  73998. */
  73999. static WriteBoolean(key: string, value: boolean): void;
  74000. /**
  74001. * Reads a number from the data storage
  74002. * @param key The key to read
  74003. * @param defaultValue The value if the key doesn't exist
  74004. * @returns The number value
  74005. */
  74006. static ReadNumber(key: string, defaultValue: number): number;
  74007. /**
  74008. * Writes a number to the data storage
  74009. * @param key The key to write
  74010. * @param value The value to write
  74011. */
  74012. static WriteNumber(key: string, value: number): void;
  74013. }
  74014. }
  74015. declare module BABYLON {
  74016. /**
  74017. * Class used to record delta files between 2 scene states
  74018. */
  74019. export class SceneRecorder {
  74020. private _trackedScene;
  74021. private _savedJSON;
  74022. /**
  74023. * Track a given scene. This means the current scene state will be considered the original state
  74024. * @param scene defines the scene to track
  74025. */
  74026. track(scene: Scene): void;
  74027. /**
  74028. * Get the delta between current state and original state
  74029. * @returns a string containing the delta
  74030. */
  74031. getDelta(): any;
  74032. private _compareArray;
  74033. private _compareObjects;
  74034. private _compareCollections;
  74035. private static GetShadowGeneratorById;
  74036. /**
  74037. * Apply a given delta to a given scene
  74038. * @param deltaJSON defines the JSON containing the delta
  74039. * @param scene defines the scene to apply the delta to
  74040. */
  74041. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  74042. private static _ApplyPropertiesToEntity;
  74043. private static _ApplyDeltaForEntity;
  74044. }
  74045. }
  74046. declare module BABYLON {
  74047. /**
  74048. * An interface for all Hit test features
  74049. */
  74050. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  74051. /**
  74052. * Triggered when new babylon (transformed) hit test results are available
  74053. */
  74054. onHitTestResultObservable: Observable<T[]>;
  74055. }
  74056. /**
  74057. * Options used for hit testing
  74058. */
  74059. export interface IWebXRLegacyHitTestOptions {
  74060. /**
  74061. * Only test when user interacted with the scene. Default - hit test every frame
  74062. */
  74063. testOnPointerDownOnly?: boolean;
  74064. /**
  74065. * The node to use to transform the local results to world coordinates
  74066. */
  74067. worldParentNode?: TransformNode;
  74068. }
  74069. /**
  74070. * Interface defining the babylon result of raycasting/hit-test
  74071. */
  74072. export interface IWebXRLegacyHitResult {
  74073. /**
  74074. * Transformation matrix that can be applied to a node that will put it in the hit point location
  74075. */
  74076. transformationMatrix: Matrix;
  74077. /**
  74078. * The native hit test result
  74079. */
  74080. xrHitResult: XRHitResult | XRHitTestResult;
  74081. }
  74082. /**
  74083. * The currently-working hit-test module.
  74084. * Hit test (or Ray-casting) is used to interact with the real world.
  74085. * For further information read here - https://github.com/immersive-web/hit-test
  74086. */
  74087. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  74088. /**
  74089. * options to use when constructing this feature
  74090. */
  74091. readonly options: IWebXRLegacyHitTestOptions;
  74092. private _direction;
  74093. private _mat;
  74094. private _onSelectEnabled;
  74095. private _origin;
  74096. /**
  74097. * The module's name
  74098. */
  74099. static readonly Name: string;
  74100. /**
  74101. * The (Babylon) version of this module.
  74102. * This is an integer representing the implementation version.
  74103. * This number does not correspond to the WebXR specs version
  74104. */
  74105. static readonly Version: number;
  74106. /**
  74107. * Populated with the last native XR Hit Results
  74108. */
  74109. lastNativeXRHitResults: XRHitResult[];
  74110. /**
  74111. * Triggered when new babylon (transformed) hit test results are available
  74112. */
  74113. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  74114. /**
  74115. * Creates a new instance of the (legacy version) hit test feature
  74116. * @param _xrSessionManager an instance of WebXRSessionManager
  74117. * @param options options to use when constructing this feature
  74118. */
  74119. constructor(_xrSessionManager: WebXRSessionManager,
  74120. /**
  74121. * options to use when constructing this feature
  74122. */
  74123. options?: IWebXRLegacyHitTestOptions);
  74124. /**
  74125. * execute a hit test with an XR Ray
  74126. *
  74127. * @param xrSession a native xrSession that will execute this hit test
  74128. * @param xrRay the ray (position and direction) to use for ray-casting
  74129. * @param referenceSpace native XR reference space to use for the hit-test
  74130. * @param filter filter function that will filter the results
  74131. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74132. */
  74133. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  74134. /**
  74135. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  74136. * @param event the (select) event to use to select with
  74137. * @param referenceSpace the reference space to use for this hit test
  74138. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74139. */
  74140. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74141. /**
  74142. * attach this feature
  74143. * Will usually be called by the features manager
  74144. *
  74145. * @returns true if successful.
  74146. */
  74147. attach(): boolean;
  74148. /**
  74149. * detach this feature.
  74150. * Will usually be called by the features manager
  74151. *
  74152. * @returns true if successful.
  74153. */
  74154. detach(): boolean;
  74155. /**
  74156. * Dispose this feature and all of the resources attached
  74157. */
  74158. dispose(): void;
  74159. protected _onXRFrame(frame: XRFrame): void;
  74160. private _onHitTestResults;
  74161. private _onSelect;
  74162. }
  74163. }
  74164. declare module BABYLON {
  74165. /**
  74166. * Options used for hit testing (version 2)
  74167. */
  74168. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  74169. /**
  74170. * Do not create a permanent hit test. Will usually be used when only
  74171. * transient inputs are needed.
  74172. */
  74173. disablePermanentHitTest?: boolean;
  74174. /**
  74175. * Enable transient (for example touch-based) hit test inspections
  74176. */
  74177. enableTransientHitTest?: boolean;
  74178. /**
  74179. * Offset ray for the permanent hit test
  74180. */
  74181. offsetRay?: Vector3;
  74182. /**
  74183. * Offset ray for the transient hit test
  74184. */
  74185. transientOffsetRay?: Vector3;
  74186. /**
  74187. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  74188. */
  74189. useReferenceSpace?: boolean;
  74190. /**
  74191. * Override the default entity type(s) of the hit-test result
  74192. */
  74193. entityTypes?: XRHitTestTrackableType[];
  74194. }
  74195. /**
  74196. * Interface defining the babylon result of hit-test
  74197. */
  74198. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  74199. /**
  74200. * The input source that generated this hit test (if transient)
  74201. */
  74202. inputSource?: XRInputSource;
  74203. /**
  74204. * Is this a transient hit test
  74205. */
  74206. isTransient?: boolean;
  74207. /**
  74208. * Position of the hit test result
  74209. */
  74210. position: Vector3;
  74211. /**
  74212. * Rotation of the hit test result
  74213. */
  74214. rotationQuaternion: Quaternion;
  74215. /**
  74216. * The native hit test result
  74217. */
  74218. xrHitResult: XRHitTestResult;
  74219. }
  74220. /**
  74221. * The currently-working hit-test module.
  74222. * Hit test (or Ray-casting) is used to interact with the real world.
  74223. * For further information read here - https://github.com/immersive-web/hit-test
  74224. *
  74225. * Tested on chrome (mobile) 80.
  74226. */
  74227. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  74228. /**
  74229. * options to use when constructing this feature
  74230. */
  74231. readonly options: IWebXRHitTestOptions;
  74232. private _tmpMat;
  74233. private _tmpPos;
  74234. private _tmpQuat;
  74235. private _transientXrHitTestSource;
  74236. private _xrHitTestSource;
  74237. private initHitTestSource;
  74238. /**
  74239. * The module's name
  74240. */
  74241. static readonly Name: string;
  74242. /**
  74243. * The (Babylon) version of this module.
  74244. * This is an integer representing the implementation version.
  74245. * This number does not correspond to the WebXR specs version
  74246. */
  74247. static readonly Version: number;
  74248. /**
  74249. * When set to true, each hit test will have its own position/rotation objects
  74250. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  74251. * the developers will clone them or copy them as they see fit.
  74252. */
  74253. autoCloneTransformation: boolean;
  74254. /**
  74255. * Triggered when new babylon (transformed) hit test results are available
  74256. */
  74257. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  74258. /**
  74259. * Use this to temporarily pause hit test checks.
  74260. */
  74261. paused: boolean;
  74262. /**
  74263. * Creates a new instance of the hit test feature
  74264. * @param _xrSessionManager an instance of WebXRSessionManager
  74265. * @param options options to use when constructing this feature
  74266. */
  74267. constructor(_xrSessionManager: WebXRSessionManager,
  74268. /**
  74269. * options to use when constructing this feature
  74270. */
  74271. options?: IWebXRHitTestOptions);
  74272. /**
  74273. * attach this feature
  74274. * Will usually be called by the features manager
  74275. *
  74276. * @returns true if successful.
  74277. */
  74278. attach(): boolean;
  74279. /**
  74280. * detach this feature.
  74281. * Will usually be called by the features manager
  74282. *
  74283. * @returns true if successful.
  74284. */
  74285. detach(): boolean;
  74286. /**
  74287. * Dispose this feature and all of the resources attached
  74288. */
  74289. dispose(): void;
  74290. protected _onXRFrame(frame: XRFrame): void;
  74291. private _processWebXRHitTestResult;
  74292. }
  74293. }
  74294. declare module BABYLON {
  74295. /**
  74296. * Configuration options of the anchor system
  74297. */
  74298. export interface IWebXRAnchorSystemOptions {
  74299. /**
  74300. * a node that will be used to convert local to world coordinates
  74301. */
  74302. worldParentNode?: TransformNode;
  74303. /**
  74304. * If set to true a reference of the created anchors will be kept until the next session starts
  74305. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  74306. */
  74307. doNotRemoveAnchorsOnSessionEnded?: boolean;
  74308. }
  74309. /**
  74310. * A babylon container for an XR Anchor
  74311. */
  74312. export interface IWebXRAnchor {
  74313. /**
  74314. * A babylon-assigned ID for this anchor
  74315. */
  74316. id: number;
  74317. /**
  74318. * Transformation matrix to apply to an object attached to this anchor
  74319. */
  74320. transformationMatrix: Matrix;
  74321. /**
  74322. * The native anchor object
  74323. */
  74324. xrAnchor: XRAnchor;
  74325. /**
  74326. * if defined, this object will be constantly updated by the anchor's position and rotation
  74327. */
  74328. attachedNode?: TransformNode;
  74329. }
  74330. /**
  74331. * An implementation of the anchor system for WebXR.
  74332. * For further information see https://github.com/immersive-web/anchors/
  74333. */
  74334. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  74335. private _options;
  74336. private _lastFrameDetected;
  74337. private _trackedAnchors;
  74338. private _referenceSpaceForFrameAnchors;
  74339. private _futureAnchors;
  74340. /**
  74341. * The module's name
  74342. */
  74343. static readonly Name: string;
  74344. /**
  74345. * The (Babylon) version of this module.
  74346. * This is an integer representing the implementation version.
  74347. * This number does not correspond to the WebXR specs version
  74348. */
  74349. static readonly Version: number;
  74350. /**
  74351. * Observers registered here will be executed when a new anchor was added to the session
  74352. */
  74353. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  74354. /**
  74355. * Observers registered here will be executed when an anchor was removed from the session
  74356. */
  74357. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  74358. /**
  74359. * Observers registered here will be executed when an existing anchor updates
  74360. * This can execute N times every frame
  74361. */
  74362. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  74363. /**
  74364. * Set the reference space to use for anchor creation, when not using a hit test.
  74365. * Will default to the session's reference space if not defined
  74366. */
  74367. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  74368. /**
  74369. * constructs a new anchor system
  74370. * @param _xrSessionManager an instance of WebXRSessionManager
  74371. * @param _options configuration object for this feature
  74372. */
  74373. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  74374. private _tmpVector;
  74375. private _tmpQuaternion;
  74376. private _populateTmpTransformation;
  74377. /**
  74378. * Create a new anchor point using a hit test result at a specific point in the scene
  74379. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  74380. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  74381. *
  74382. * @param hitTestResult The hit test result to use for this anchor creation
  74383. * @param position an optional position offset for this anchor
  74384. * @param rotationQuaternion an optional rotation offset for this anchor
  74385. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  74386. */
  74387. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  74388. /**
  74389. * Add a new anchor at a specific position and rotation
  74390. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  74391. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  74392. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  74393. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  74394. *
  74395. * @param position the position in which to add an anchor
  74396. * @param rotationQuaternion an optional rotation for the anchor transformation
  74397. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  74398. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  74399. */
  74400. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  74401. /**
  74402. * detach this feature.
  74403. * Will usually be called by the features manager
  74404. *
  74405. * @returns true if successful.
  74406. */
  74407. detach(): boolean;
  74408. /**
  74409. * Dispose this feature and all of the resources attached
  74410. */
  74411. dispose(): void;
  74412. protected _onXRFrame(frame: XRFrame): void;
  74413. /**
  74414. * avoiding using Array.find for global support.
  74415. * @param xrAnchor the plane to find in the array
  74416. */
  74417. private _findIndexInAnchorArray;
  74418. private _updateAnchorWithXRFrame;
  74419. private _createAnchorAtTransformation;
  74420. }
  74421. }
  74422. declare module BABYLON {
  74423. /**
  74424. * Options used in the plane detector module
  74425. */
  74426. export interface IWebXRPlaneDetectorOptions {
  74427. /**
  74428. * The node to use to transform the local results to world coordinates
  74429. */
  74430. worldParentNode?: TransformNode;
  74431. /**
  74432. * If set to true a reference of the created planes will be kept until the next session starts
  74433. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  74434. */
  74435. doNotRemovePlanesOnSessionEnded?: boolean;
  74436. }
  74437. /**
  74438. * A babylon interface for a WebXR plane.
  74439. * A Plane is actually a polygon, built from N points in space
  74440. *
  74441. * Supported in chrome 79, not supported in canary 81 ATM
  74442. */
  74443. export interface IWebXRPlane {
  74444. /**
  74445. * a babylon-assigned ID for this polygon
  74446. */
  74447. id: number;
  74448. /**
  74449. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  74450. */
  74451. polygonDefinition: Array<Vector3>;
  74452. /**
  74453. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  74454. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  74455. */
  74456. transformationMatrix: Matrix;
  74457. /**
  74458. * the native xr-plane object
  74459. */
  74460. xrPlane: XRPlane;
  74461. }
  74462. /**
  74463. * The plane detector is used to detect planes in the real world when in AR
  74464. * For more information see https://github.com/immersive-web/real-world-geometry/
  74465. */
  74466. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  74467. private _options;
  74468. private _detectedPlanes;
  74469. private _enabled;
  74470. private _lastFrameDetected;
  74471. /**
  74472. * The module's name
  74473. */
  74474. static readonly Name: string;
  74475. /**
  74476. * The (Babylon) version of this module.
  74477. * This is an integer representing the implementation version.
  74478. * This number does not correspond to the WebXR specs version
  74479. */
  74480. static readonly Version: number;
  74481. /**
  74482. * Observers registered here will be executed when a new plane was added to the session
  74483. */
  74484. onPlaneAddedObservable: Observable<IWebXRPlane>;
  74485. /**
  74486. * Observers registered here will be executed when a plane is no longer detected in the session
  74487. */
  74488. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  74489. /**
  74490. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  74491. * This can execute N times every frame
  74492. */
  74493. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  74494. /**
  74495. * construct a new Plane Detector
  74496. * @param _xrSessionManager an instance of xr Session manager
  74497. * @param _options configuration to use when constructing this feature
  74498. */
  74499. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  74500. /**
  74501. * detach this feature.
  74502. * Will usually be called by the features manager
  74503. *
  74504. * @returns true if successful.
  74505. */
  74506. detach(): boolean;
  74507. /**
  74508. * Dispose this feature and all of the resources attached
  74509. */
  74510. dispose(): void;
  74511. protected _onXRFrame(frame: XRFrame): void;
  74512. private _init;
  74513. private _updatePlaneWithXRPlane;
  74514. /**
  74515. * avoiding using Array.find for global support.
  74516. * @param xrPlane the plane to find in the array
  74517. */
  74518. private findIndexInPlaneArray;
  74519. }
  74520. }
  74521. declare module BABYLON {
  74522. /**
  74523. * Options interface for the background remover plugin
  74524. */
  74525. export interface IWebXRBackgroundRemoverOptions {
  74526. /**
  74527. * Further background meshes to disable when entering AR
  74528. */
  74529. backgroundMeshes?: AbstractMesh[];
  74530. /**
  74531. * flags to configure the removal of the environment helper.
  74532. * If not set, the entire background will be removed. If set, flags should be set as well.
  74533. */
  74534. environmentHelperRemovalFlags?: {
  74535. /**
  74536. * Should the skybox be removed (default false)
  74537. */
  74538. skyBox?: boolean;
  74539. /**
  74540. * Should the ground be removed (default false)
  74541. */
  74542. ground?: boolean;
  74543. };
  74544. /**
  74545. * don't disable the environment helper
  74546. */
  74547. ignoreEnvironmentHelper?: boolean;
  74548. }
  74549. /**
  74550. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  74551. */
  74552. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  74553. /**
  74554. * read-only options to be used in this module
  74555. */
  74556. readonly options: IWebXRBackgroundRemoverOptions;
  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. * registered observers will be triggered when the background state changes
  74569. */
  74570. onBackgroundStateChangedObservable: Observable<boolean>;
  74571. /**
  74572. * constructs a new background remover module
  74573. * @param _xrSessionManager the session manager for this module
  74574. * @param options read-only options to be used in this module
  74575. */
  74576. constructor(_xrSessionManager: WebXRSessionManager,
  74577. /**
  74578. * read-only options to be used in this module
  74579. */
  74580. options?: IWebXRBackgroundRemoverOptions);
  74581. /**
  74582. * attach this feature
  74583. * Will usually be called by the features manager
  74584. *
  74585. * @returns true if successful.
  74586. */
  74587. attach(): boolean;
  74588. /**
  74589. * detach this feature.
  74590. * Will usually be called by the features manager
  74591. *
  74592. * @returns true if successful.
  74593. */
  74594. detach(): boolean;
  74595. /**
  74596. * Dispose this feature and all of the resources attached
  74597. */
  74598. dispose(): void;
  74599. protected _onXRFrame(_xrFrame: XRFrame): void;
  74600. private _setBackgroundState;
  74601. }
  74602. }
  74603. declare module BABYLON {
  74604. /**
  74605. * Options for the controller physics feature
  74606. */
  74607. export class IWebXRControllerPhysicsOptions {
  74608. /**
  74609. * Should the headset get its own impostor
  74610. */
  74611. enableHeadsetImpostor?: boolean;
  74612. /**
  74613. * Optional parameters for the headset impostor
  74614. */
  74615. headsetImpostorParams?: {
  74616. /**
  74617. * The type of impostor to create. Default is sphere
  74618. */
  74619. impostorType: number;
  74620. /**
  74621. * the size of the impostor. Defaults to 10cm
  74622. */
  74623. impostorSize?: number | {
  74624. width: number;
  74625. height: number;
  74626. depth: number;
  74627. };
  74628. /**
  74629. * Friction definitions
  74630. */
  74631. friction?: number;
  74632. /**
  74633. * Restitution
  74634. */
  74635. restitution?: number;
  74636. };
  74637. /**
  74638. * The physics properties of the future impostors
  74639. */
  74640. physicsProperties?: {
  74641. /**
  74642. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  74643. * Note that this requires a physics engine that supports mesh impostors!
  74644. */
  74645. useControllerMesh?: boolean;
  74646. /**
  74647. * The type of impostor to create. Default is sphere
  74648. */
  74649. impostorType?: number;
  74650. /**
  74651. * the size of the impostor. Defaults to 10cm
  74652. */
  74653. impostorSize?: number | {
  74654. width: number;
  74655. height: number;
  74656. depth: number;
  74657. };
  74658. /**
  74659. * Friction definitions
  74660. */
  74661. friction?: number;
  74662. /**
  74663. * Restitution
  74664. */
  74665. restitution?: number;
  74666. };
  74667. /**
  74668. * the xr input to use with this pointer selection
  74669. */
  74670. xrInput: WebXRInput;
  74671. }
  74672. /**
  74673. * Add physics impostor to your webxr controllers,
  74674. * including naive calculation of their linear and angular velocity
  74675. */
  74676. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  74677. private readonly _options;
  74678. private _attachController;
  74679. private _controllers;
  74680. private _debugMode;
  74681. private _delta;
  74682. private _headsetImpostor?;
  74683. private _headsetMesh?;
  74684. private _lastTimestamp;
  74685. private _tmpQuaternion;
  74686. private _tmpVector;
  74687. /**
  74688. * The module's name
  74689. */
  74690. static readonly Name: string;
  74691. /**
  74692. * The (Babylon) version of this module.
  74693. * This is an integer representing the implementation version.
  74694. * This number does not correspond to the webxr specs version
  74695. */
  74696. static readonly Version: number;
  74697. /**
  74698. * Construct a new Controller Physics Feature
  74699. * @param _xrSessionManager the corresponding xr session manager
  74700. * @param _options options to create this feature with
  74701. */
  74702. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  74703. /**
  74704. * @hidden
  74705. * enable debugging - will show console outputs and the impostor mesh
  74706. */
  74707. _enablePhysicsDebug(): void;
  74708. /**
  74709. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  74710. * @param xrController the controller to add
  74711. */
  74712. addController(xrController: WebXRInputSource): void;
  74713. /**
  74714. * attach this feature
  74715. * Will usually be called by the features manager
  74716. *
  74717. * @returns true if successful.
  74718. */
  74719. attach(): boolean;
  74720. /**
  74721. * detach this feature.
  74722. * Will usually be called by the features manager
  74723. *
  74724. * @returns true if successful.
  74725. */
  74726. detach(): boolean;
  74727. /**
  74728. * Get the headset impostor, if enabled
  74729. * @returns the impostor
  74730. */
  74731. getHeadsetImpostor(): PhysicsImpostor | undefined;
  74732. /**
  74733. * Get the physics impostor of a specific controller.
  74734. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  74735. * @param controller the controller or the controller id of which to get the impostor
  74736. * @returns the impostor or null
  74737. */
  74738. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  74739. /**
  74740. * Update the physics properties provided in the constructor
  74741. * @param newProperties the new properties object
  74742. */
  74743. setPhysicsProperties(newProperties: {
  74744. impostorType?: number;
  74745. impostorSize?: number | {
  74746. width: number;
  74747. height: number;
  74748. depth: number;
  74749. };
  74750. friction?: number;
  74751. restitution?: number;
  74752. }): void;
  74753. protected _onXRFrame(_xrFrame: any): void;
  74754. private _detachController;
  74755. }
  74756. }
  74757. declare module BABYLON {
  74758. /**
  74759. * The motion controller class for all microsoft mixed reality controllers
  74760. */
  74761. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  74762. protected readonly _mapping: {
  74763. defaultButton: {
  74764. valueNodeName: string;
  74765. unpressedNodeName: string;
  74766. pressedNodeName: string;
  74767. };
  74768. defaultAxis: {
  74769. valueNodeName: string;
  74770. minNodeName: string;
  74771. maxNodeName: string;
  74772. };
  74773. buttons: {
  74774. "xr-standard-trigger": {
  74775. rootNodeName: string;
  74776. componentProperty: string;
  74777. states: string[];
  74778. };
  74779. "xr-standard-squeeze": {
  74780. rootNodeName: string;
  74781. componentProperty: string;
  74782. states: string[];
  74783. };
  74784. "xr-standard-touchpad": {
  74785. rootNodeName: string;
  74786. labelAnchorNodeName: string;
  74787. touchPointNodeName: string;
  74788. };
  74789. "xr-standard-thumbstick": {
  74790. rootNodeName: string;
  74791. componentProperty: string;
  74792. states: string[];
  74793. };
  74794. };
  74795. axes: {
  74796. "xr-standard-touchpad": {
  74797. "x-axis": {
  74798. rootNodeName: string;
  74799. };
  74800. "y-axis": {
  74801. rootNodeName: string;
  74802. };
  74803. };
  74804. "xr-standard-thumbstick": {
  74805. "x-axis": {
  74806. rootNodeName: string;
  74807. };
  74808. "y-axis": {
  74809. rootNodeName: string;
  74810. };
  74811. };
  74812. };
  74813. };
  74814. /**
  74815. * The base url used to load the left and right controller models
  74816. */
  74817. static MODEL_BASE_URL: string;
  74818. /**
  74819. * The name of the left controller model file
  74820. */
  74821. static MODEL_LEFT_FILENAME: string;
  74822. /**
  74823. * The name of the right controller model file
  74824. */
  74825. static MODEL_RIGHT_FILENAME: string;
  74826. profileId: string;
  74827. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  74828. protected _getFilenameAndPath(): {
  74829. filename: string;
  74830. path: string;
  74831. };
  74832. protected _getModelLoadingConstraints(): boolean;
  74833. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74834. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74835. protected _updateModel(): void;
  74836. }
  74837. }
  74838. declare module BABYLON {
  74839. /**
  74840. * The motion controller class for oculus touch (quest, rift).
  74841. * This class supports legacy mapping as well the standard xr mapping
  74842. */
  74843. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  74844. private _forceLegacyControllers;
  74845. private _modelRootNode;
  74846. /**
  74847. * The base url used to load the left and right controller models
  74848. */
  74849. static MODEL_BASE_URL: string;
  74850. /**
  74851. * The name of the left controller model file
  74852. */
  74853. static MODEL_LEFT_FILENAME: string;
  74854. /**
  74855. * The name of the right controller model file
  74856. */
  74857. static MODEL_RIGHT_FILENAME: string;
  74858. /**
  74859. * Base Url for the Quest controller model.
  74860. */
  74861. static QUEST_MODEL_BASE_URL: string;
  74862. profileId: string;
  74863. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  74864. protected _getFilenameAndPath(): {
  74865. filename: string;
  74866. path: string;
  74867. };
  74868. protected _getModelLoadingConstraints(): boolean;
  74869. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74870. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74871. protected _updateModel(): void;
  74872. /**
  74873. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  74874. * between the touch and touch 2.
  74875. */
  74876. private _isQuest;
  74877. }
  74878. }
  74879. declare module BABYLON {
  74880. /**
  74881. * The motion controller class for the standard HTC-Vive controllers
  74882. */
  74883. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  74884. private _modelRootNode;
  74885. /**
  74886. * The base url used to load the left and right controller models
  74887. */
  74888. static MODEL_BASE_URL: string;
  74889. /**
  74890. * File name for the controller model.
  74891. */
  74892. static MODEL_FILENAME: string;
  74893. profileId: string;
  74894. /**
  74895. * Create a new Vive motion controller object
  74896. * @param scene the scene to use to create this controller
  74897. * @param gamepadObject the corresponding gamepad object
  74898. * @param handedness the handedness of the controller
  74899. */
  74900. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  74901. protected _getFilenameAndPath(): {
  74902. filename: string;
  74903. path: string;
  74904. };
  74905. protected _getModelLoadingConstraints(): boolean;
  74906. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74907. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74908. protected _updateModel(): void;
  74909. }
  74910. }
  74911. declare module BABYLON {
  74912. /**
  74913. * A cursor which tracks a point on a path
  74914. */
  74915. export class PathCursor {
  74916. private path;
  74917. /**
  74918. * Stores path cursor callbacks for when an onchange event is triggered
  74919. */
  74920. private _onchange;
  74921. /**
  74922. * The value of the path cursor
  74923. */
  74924. value: number;
  74925. /**
  74926. * The animation array of the path cursor
  74927. */
  74928. animations: Animation[];
  74929. /**
  74930. * Initializes the path cursor
  74931. * @param path The path to track
  74932. */
  74933. constructor(path: Path2);
  74934. /**
  74935. * Gets the cursor point on the path
  74936. * @returns A point on the path cursor at the cursor location
  74937. */
  74938. getPoint(): Vector3;
  74939. /**
  74940. * Moves the cursor ahead by the step amount
  74941. * @param step The amount to move the cursor forward
  74942. * @returns This path cursor
  74943. */
  74944. moveAhead(step?: number): PathCursor;
  74945. /**
  74946. * Moves the cursor behind by the step amount
  74947. * @param step The amount to move the cursor back
  74948. * @returns This path cursor
  74949. */
  74950. moveBack(step?: number): PathCursor;
  74951. /**
  74952. * Moves the cursor by the step amount
  74953. * If the step amount is greater than one, an exception is thrown
  74954. * @param step The amount to move the cursor
  74955. * @returns This path cursor
  74956. */
  74957. move(step: number): PathCursor;
  74958. /**
  74959. * Ensures that the value is limited between zero and one
  74960. * @returns This path cursor
  74961. */
  74962. private ensureLimits;
  74963. /**
  74964. * Runs onchange callbacks on change (used by the animation engine)
  74965. * @returns This path cursor
  74966. */
  74967. private raiseOnChange;
  74968. /**
  74969. * Executes a function on change
  74970. * @param f A path cursor onchange callback
  74971. * @returns This path cursor
  74972. */
  74973. onchange(f: (cursor: PathCursor) => void): PathCursor;
  74974. }
  74975. }
  74976. declare module BABYLON {
  74977. /** @hidden */
  74978. export var blurPixelShader: {
  74979. name: string;
  74980. shader: string;
  74981. };
  74982. }
  74983. declare module BABYLON {
  74984. /** @hidden */
  74985. export var pointCloudVertexDeclaration: {
  74986. name: string;
  74987. shader: string;
  74988. };
  74989. }
  74990. // Mixins
  74991. interface Window {
  74992. mozIndexedDB: IDBFactory;
  74993. webkitIndexedDB: IDBFactory;
  74994. msIndexedDB: IDBFactory;
  74995. webkitURL: typeof URL;
  74996. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  74997. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  74998. WebGLRenderingContext: WebGLRenderingContext;
  74999. MSGesture: MSGesture;
  75000. CANNON: any;
  75001. AudioContext: AudioContext;
  75002. webkitAudioContext: AudioContext;
  75003. PointerEvent: any;
  75004. Math: Math;
  75005. Uint8Array: Uint8ArrayConstructor;
  75006. Float32Array: Float32ArrayConstructor;
  75007. mozURL: typeof URL;
  75008. msURL: typeof URL;
  75009. VRFrameData: any; // WebVR, from specs 1.1
  75010. DracoDecoderModule: any;
  75011. setImmediate(handler: (...args: any[]) => void): number;
  75012. }
  75013. interface HTMLCanvasElement {
  75014. requestPointerLock(): void;
  75015. msRequestPointerLock?(): void;
  75016. mozRequestPointerLock?(): void;
  75017. webkitRequestPointerLock?(): void;
  75018. /** Track wether a record is in progress */
  75019. isRecording: boolean;
  75020. /** Capture Stream method defined by some browsers */
  75021. captureStream(fps?: number): MediaStream;
  75022. }
  75023. interface CanvasRenderingContext2D {
  75024. msImageSmoothingEnabled: boolean;
  75025. }
  75026. interface MouseEvent {
  75027. mozMovementX: number;
  75028. mozMovementY: number;
  75029. webkitMovementX: number;
  75030. webkitMovementY: number;
  75031. msMovementX: number;
  75032. msMovementY: number;
  75033. }
  75034. interface Navigator {
  75035. mozGetVRDevices: (any: any) => any;
  75036. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75037. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75038. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75039. webkitGetGamepads(): Gamepad[];
  75040. msGetGamepads(): Gamepad[];
  75041. webkitGamepads(): Gamepad[];
  75042. }
  75043. interface HTMLVideoElement {
  75044. mozSrcObject: any;
  75045. }
  75046. interface Math {
  75047. fround(x: number): number;
  75048. imul(a: number, b: number): number;
  75049. }
  75050. interface WebGLRenderingContext {
  75051. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  75052. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  75053. vertexAttribDivisor(index: number, divisor: number): void;
  75054. createVertexArray(): any;
  75055. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  75056. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  75057. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  75058. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  75059. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  75060. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  75061. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  75062. // Queries
  75063. createQuery(): WebGLQuery;
  75064. deleteQuery(query: WebGLQuery): void;
  75065. beginQuery(target: number, query: WebGLQuery): void;
  75066. endQuery(target: number): void;
  75067. getQueryParameter(query: WebGLQuery, pname: number): any;
  75068. getQuery(target: number, pname: number): any;
  75069. MAX_SAMPLES: number;
  75070. RGBA8: number;
  75071. READ_FRAMEBUFFER: number;
  75072. DRAW_FRAMEBUFFER: number;
  75073. UNIFORM_BUFFER: number;
  75074. HALF_FLOAT_OES: number;
  75075. RGBA16F: number;
  75076. RGBA32F: number;
  75077. R32F: number;
  75078. RG32F: number;
  75079. RGB32F: number;
  75080. R16F: number;
  75081. RG16F: number;
  75082. RGB16F: number;
  75083. RED: number;
  75084. RG: number;
  75085. R8: number;
  75086. RG8: number;
  75087. UNSIGNED_INT_24_8: number;
  75088. DEPTH24_STENCIL8: number;
  75089. MIN: number;
  75090. MAX: number;
  75091. /* Multiple Render Targets */
  75092. drawBuffers(buffers: number[]): void;
  75093. readBuffer(src: number): void;
  75094. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  75095. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  75096. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  75097. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  75098. // Occlusion Query
  75099. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  75100. ANY_SAMPLES_PASSED: number;
  75101. QUERY_RESULT_AVAILABLE: number;
  75102. QUERY_RESULT: number;
  75103. }
  75104. interface WebGLProgram {
  75105. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  75106. }
  75107. interface EXT_disjoint_timer_query {
  75108. QUERY_COUNTER_BITS_EXT: number;
  75109. TIME_ELAPSED_EXT: number;
  75110. TIMESTAMP_EXT: number;
  75111. GPU_DISJOINT_EXT: number;
  75112. QUERY_RESULT_EXT: number;
  75113. QUERY_RESULT_AVAILABLE_EXT: number;
  75114. queryCounterEXT(query: WebGLQuery, target: number): void;
  75115. createQueryEXT(): WebGLQuery;
  75116. beginQueryEXT(target: number, query: WebGLQuery): void;
  75117. endQueryEXT(target: number): void;
  75118. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  75119. deleteQueryEXT(query: WebGLQuery): void;
  75120. }
  75121. interface WebGLUniformLocation {
  75122. _currentState: any;
  75123. }
  75124. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  75125. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  75126. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  75127. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  75128. interface WebGLRenderingContext {
  75129. readonly RASTERIZER_DISCARD: number;
  75130. readonly DEPTH_COMPONENT24: number;
  75131. readonly TEXTURE_3D: number;
  75132. readonly TEXTURE_2D_ARRAY: number;
  75133. readonly TEXTURE_COMPARE_FUNC: number;
  75134. readonly TEXTURE_COMPARE_MODE: number;
  75135. readonly COMPARE_REF_TO_TEXTURE: number;
  75136. readonly TEXTURE_WRAP_R: number;
  75137. readonly HALF_FLOAT: number;
  75138. readonly RGB8: number;
  75139. readonly RED_INTEGER: number;
  75140. readonly RG_INTEGER: number;
  75141. readonly RGB_INTEGER: number;
  75142. readonly RGBA_INTEGER: number;
  75143. readonly R8_SNORM: number;
  75144. readonly RG8_SNORM: number;
  75145. readonly RGB8_SNORM: number;
  75146. readonly RGBA8_SNORM: number;
  75147. readonly R8I: number;
  75148. readonly RG8I: number;
  75149. readonly RGB8I: number;
  75150. readonly RGBA8I: number;
  75151. readonly R8UI: number;
  75152. readonly RG8UI: number;
  75153. readonly RGB8UI: number;
  75154. readonly RGBA8UI: number;
  75155. readonly R16I: number;
  75156. readonly RG16I: number;
  75157. readonly RGB16I: number;
  75158. readonly RGBA16I: number;
  75159. readonly R16UI: number;
  75160. readonly RG16UI: number;
  75161. readonly RGB16UI: number;
  75162. readonly RGBA16UI: number;
  75163. readonly R32I: number;
  75164. readonly RG32I: number;
  75165. readonly RGB32I: number;
  75166. readonly RGBA32I: number;
  75167. readonly R32UI: number;
  75168. readonly RG32UI: number;
  75169. readonly RGB32UI: number;
  75170. readonly RGBA32UI: number;
  75171. readonly RGB10_A2UI: number;
  75172. readonly R11F_G11F_B10F: number;
  75173. readonly RGB9_E5: number;
  75174. readonly RGB10_A2: number;
  75175. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  75176. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  75177. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  75178. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  75179. readonly DEPTH_COMPONENT32F: number;
  75180. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  75181. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  75182. 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;
  75183. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  75184. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  75185. readonly TRANSFORM_FEEDBACK: number;
  75186. readonly INTERLEAVED_ATTRIBS: number;
  75187. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  75188. createTransformFeedback(): WebGLTransformFeedback;
  75189. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  75190. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  75191. beginTransformFeedback(primitiveMode: number): void;
  75192. endTransformFeedback(): void;
  75193. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  75194. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75195. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75196. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75197. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  75198. }
  75199. interface ImageBitmap {
  75200. readonly width: number;
  75201. readonly height: number;
  75202. close(): void;
  75203. }
  75204. interface WebGLQuery extends WebGLObject {
  75205. }
  75206. declare var WebGLQuery: {
  75207. prototype: WebGLQuery;
  75208. new(): WebGLQuery;
  75209. };
  75210. interface WebGLSampler extends WebGLObject {
  75211. }
  75212. declare var WebGLSampler: {
  75213. prototype: WebGLSampler;
  75214. new(): WebGLSampler;
  75215. };
  75216. interface WebGLSync extends WebGLObject {
  75217. }
  75218. declare var WebGLSync: {
  75219. prototype: WebGLSync;
  75220. new(): WebGLSync;
  75221. };
  75222. interface WebGLTransformFeedback extends WebGLObject {
  75223. }
  75224. declare var WebGLTransformFeedback: {
  75225. prototype: WebGLTransformFeedback;
  75226. new(): WebGLTransformFeedback;
  75227. };
  75228. interface WebGLVertexArrayObject extends WebGLObject {
  75229. }
  75230. declare var WebGLVertexArrayObject: {
  75231. prototype: WebGLVertexArrayObject;
  75232. new(): WebGLVertexArrayObject;
  75233. };
  75234. // Type definitions for WebVR API
  75235. // Project: https://w3c.github.io/webvr/
  75236. // Definitions by: six a <https://github.com/lostfictions>
  75237. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  75238. interface VRDisplay extends EventTarget {
  75239. /**
  75240. * Dictionary of capabilities describing the VRDisplay.
  75241. */
  75242. readonly capabilities: VRDisplayCapabilities;
  75243. /**
  75244. * z-depth defining the far plane of the eye view frustum
  75245. * enables mapping of values in the render target depth
  75246. * attachment to scene coordinates. Initially set to 10000.0.
  75247. */
  75248. depthFar: number;
  75249. /**
  75250. * z-depth defining the near plane of the eye view frustum
  75251. * enables mapping of values in the render target depth
  75252. * attachment to scene coordinates. Initially set to 0.01.
  75253. */
  75254. depthNear: number;
  75255. /**
  75256. * An identifier for this distinct VRDisplay. Used as an
  75257. * association point in the Gamepad API.
  75258. */
  75259. readonly displayId: number;
  75260. /**
  75261. * A display name, a user-readable name identifying it.
  75262. */
  75263. readonly displayName: string;
  75264. readonly isConnected: boolean;
  75265. readonly isPresenting: boolean;
  75266. /**
  75267. * If this VRDisplay supports room-scale experiences, the optional
  75268. * stage attribute contains details on the room-scale parameters.
  75269. */
  75270. readonly stageParameters: VRStageParameters | null;
  75271. /**
  75272. * Passing the value returned by `requestAnimationFrame` to
  75273. * `cancelAnimationFrame` will unregister the callback.
  75274. * @param handle Define the hanle of the request to cancel
  75275. */
  75276. cancelAnimationFrame(handle: number): void;
  75277. /**
  75278. * Stops presenting to the VRDisplay.
  75279. * @returns a promise to know when it stopped
  75280. */
  75281. exitPresent(): Promise<void>;
  75282. /**
  75283. * Return the current VREyeParameters for the given eye.
  75284. * @param whichEye Define the eye we want the parameter for
  75285. * @returns the eye parameters
  75286. */
  75287. getEyeParameters(whichEye: string): VREyeParameters;
  75288. /**
  75289. * Populates the passed VRFrameData with the information required to render
  75290. * the current frame.
  75291. * @param frameData Define the data structure to populate
  75292. * @returns true if ok otherwise false
  75293. */
  75294. getFrameData(frameData: VRFrameData): boolean;
  75295. /**
  75296. * Get the layers currently being presented.
  75297. * @returns the list of VR layers
  75298. */
  75299. getLayers(): VRLayer[];
  75300. /**
  75301. * Return a VRPose containing the future predicted pose of the VRDisplay
  75302. * when the current frame will be presented. The value returned will not
  75303. * change until JavaScript has returned control to the browser.
  75304. *
  75305. * The VRPose will contain the position, orientation, velocity,
  75306. * and acceleration of each of these properties.
  75307. * @returns the pose object
  75308. */
  75309. getPose(): VRPose;
  75310. /**
  75311. * Return the current instantaneous pose of the VRDisplay, with no
  75312. * prediction applied.
  75313. * @returns the current instantaneous pose
  75314. */
  75315. getImmediatePose(): VRPose;
  75316. /**
  75317. * The callback passed to `requestAnimationFrame` will be called
  75318. * any time a new frame should be rendered. When the VRDisplay is
  75319. * presenting the callback will be called at the native refresh
  75320. * rate of the HMD. When not presenting this function acts
  75321. * identically to how window.requestAnimationFrame acts. Content should
  75322. * make no assumptions of frame rate or vsync behavior as the HMD runs
  75323. * asynchronously from other displays and at differing refresh rates.
  75324. * @param callback Define the eaction to run next frame
  75325. * @returns the request handle it
  75326. */
  75327. requestAnimationFrame(callback: FrameRequestCallback): number;
  75328. /**
  75329. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  75330. * Repeat calls while already presenting will update the VRLayers being displayed.
  75331. * @param layers Define the list of layer to present
  75332. * @returns a promise to know when the request has been fulfilled
  75333. */
  75334. requestPresent(layers: VRLayer[]): Promise<void>;
  75335. /**
  75336. * Reset the pose for this display, treating its current position and
  75337. * orientation as the "origin/zero" values. VRPose.position,
  75338. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  75339. * updated when calling resetPose(). This should be called in only
  75340. * sitting-space experiences.
  75341. */
  75342. resetPose(): void;
  75343. /**
  75344. * The VRLayer provided to the VRDisplay will be captured and presented
  75345. * in the HMD. Calling this function has the same effect on the source
  75346. * canvas as any other operation that uses its source image, and canvases
  75347. * created without preserveDrawingBuffer set to true will be cleared.
  75348. * @param pose Define the pose to submit
  75349. */
  75350. submitFrame(pose?: VRPose): void;
  75351. }
  75352. declare var VRDisplay: {
  75353. prototype: VRDisplay;
  75354. new(): VRDisplay;
  75355. };
  75356. interface VRLayer {
  75357. leftBounds?: number[] | Float32Array | null;
  75358. rightBounds?: number[] | Float32Array | null;
  75359. source?: HTMLCanvasElement | null;
  75360. }
  75361. interface VRDisplayCapabilities {
  75362. readonly canPresent: boolean;
  75363. readonly hasExternalDisplay: boolean;
  75364. readonly hasOrientation: boolean;
  75365. readonly hasPosition: boolean;
  75366. readonly maxLayers: number;
  75367. }
  75368. interface VREyeParameters {
  75369. /** @deprecated */
  75370. readonly fieldOfView: VRFieldOfView;
  75371. readonly offset: Float32Array;
  75372. readonly renderHeight: number;
  75373. readonly renderWidth: number;
  75374. }
  75375. interface VRFieldOfView {
  75376. readonly downDegrees: number;
  75377. readonly leftDegrees: number;
  75378. readonly rightDegrees: number;
  75379. readonly upDegrees: number;
  75380. }
  75381. interface VRFrameData {
  75382. readonly leftProjectionMatrix: Float32Array;
  75383. readonly leftViewMatrix: Float32Array;
  75384. readonly pose: VRPose;
  75385. readonly rightProjectionMatrix: Float32Array;
  75386. readonly rightViewMatrix: Float32Array;
  75387. readonly timestamp: number;
  75388. }
  75389. interface VRPose {
  75390. readonly angularAcceleration: Float32Array | null;
  75391. readonly angularVelocity: Float32Array | null;
  75392. readonly linearAcceleration: Float32Array | null;
  75393. readonly linearVelocity: Float32Array | null;
  75394. readonly orientation: Float32Array | null;
  75395. readonly position: Float32Array | null;
  75396. readonly timestamp: number;
  75397. }
  75398. interface VRStageParameters {
  75399. sittingToStandingTransform?: Float32Array;
  75400. sizeX?: number;
  75401. sizeY?: number;
  75402. }
  75403. interface Navigator {
  75404. getVRDisplays(): Promise<VRDisplay[]>;
  75405. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  75406. }
  75407. interface Window {
  75408. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  75409. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  75410. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  75411. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  75412. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  75413. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  75414. }
  75415. interface Gamepad {
  75416. readonly displayId: number;
  75417. }
  75418. type XRSessionMode =
  75419. | "inline"
  75420. | "immersive-vr"
  75421. | "immersive-ar";
  75422. type XRReferenceSpaceType =
  75423. | "viewer"
  75424. | "local"
  75425. | "local-floor"
  75426. | "bounded-floor"
  75427. | "unbounded";
  75428. type XREnvironmentBlendMode =
  75429. | "opaque"
  75430. | "additive"
  75431. | "alpha-blend";
  75432. type XRVisibilityState =
  75433. | "visible"
  75434. | "visible-blurred"
  75435. | "hidden";
  75436. type XRHandedness =
  75437. | "none"
  75438. | "left"
  75439. | "right";
  75440. type XRTargetRayMode =
  75441. | "gaze"
  75442. | "tracked-pointer"
  75443. | "screen";
  75444. type XREye =
  75445. | "none"
  75446. | "left"
  75447. | "right";
  75448. type XREventType =
  75449. | "devicechange"
  75450. | "visibilitychange"
  75451. | "end"
  75452. | "inputsourceschange"
  75453. | "select"
  75454. | "selectstart"
  75455. | "selectend"
  75456. | "squeeze"
  75457. | "squeezestart"
  75458. | "squeezeend"
  75459. | "reset";
  75460. interface XRSpace extends EventTarget {
  75461. }
  75462. interface XRRenderState {
  75463. depthNear?: number;
  75464. depthFar?: number;
  75465. inlineVerticalFieldOfView?: number;
  75466. baseLayer?: XRWebGLLayer;
  75467. }
  75468. interface XRInputSource {
  75469. handedness: XRHandedness;
  75470. targetRayMode: XRTargetRayMode;
  75471. targetRaySpace: XRSpace;
  75472. gripSpace: XRSpace | undefined;
  75473. gamepad: Gamepad | undefined;
  75474. profiles: Array<string>;
  75475. }
  75476. interface XRSessionInit {
  75477. optionalFeatures?: string[];
  75478. requiredFeatures?: string[];
  75479. }
  75480. interface XRSession {
  75481. addEventListener: Function;
  75482. removeEventListener: Function;
  75483. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  75484. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  75485. requestAnimationFrame: Function;
  75486. end(): Promise<void>;
  75487. renderState: XRRenderState;
  75488. inputSources: Array<XRInputSource>;
  75489. // hit test
  75490. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  75491. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  75492. // legacy AR hit test
  75493. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75494. // legacy plane detection
  75495. updateWorldTrackingState(options: {
  75496. planeDetectionState?: { enabled: boolean; }
  75497. }): void;
  75498. }
  75499. interface XRReferenceSpace extends XRSpace {
  75500. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  75501. onreset: any;
  75502. }
  75503. type XRPlaneSet = Set<XRPlane>;
  75504. type XRAnchorSet = Set<XRAnchor>;
  75505. interface XRFrame {
  75506. session: XRSession;
  75507. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  75508. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  75509. // AR
  75510. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  75511. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  75512. // Anchors
  75513. trackedAnchors?: XRAnchorSet;
  75514. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  75515. // Planes
  75516. worldInformation: {
  75517. detectedPlanes?: XRPlaneSet;
  75518. };
  75519. }
  75520. interface XRViewerPose extends XRPose {
  75521. views: Array<XRView>;
  75522. }
  75523. interface XRPose {
  75524. transform: XRRigidTransform;
  75525. emulatedPosition: boolean;
  75526. }
  75527. interface XRWebGLLayerOptions {
  75528. antialias?: boolean;
  75529. depth?: boolean;
  75530. stencil?: boolean;
  75531. alpha?: boolean;
  75532. multiview?: boolean;
  75533. framebufferScaleFactor?: number;
  75534. }
  75535. declare var XRWebGLLayer: {
  75536. prototype: XRWebGLLayer;
  75537. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  75538. };
  75539. interface XRWebGLLayer {
  75540. framebuffer: WebGLFramebuffer;
  75541. framebufferWidth: number;
  75542. framebufferHeight: number;
  75543. getViewport: Function;
  75544. }
  75545. declare class XRRigidTransform {
  75546. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  75547. position: DOMPointReadOnly;
  75548. orientation: DOMPointReadOnly;
  75549. matrix: Float32Array;
  75550. inverse: XRRigidTransform;
  75551. }
  75552. interface XRView {
  75553. eye: XREye;
  75554. projectionMatrix: Float32Array;
  75555. transform: XRRigidTransform;
  75556. }
  75557. interface XRInputSourceChangeEvent {
  75558. session: XRSession;
  75559. removed: Array<XRInputSource>;
  75560. added: Array<XRInputSource>;
  75561. }
  75562. interface XRInputSourceEvent extends Event {
  75563. readonly frame: XRFrame;
  75564. readonly inputSource: XRInputSource;
  75565. }
  75566. // Experimental(er) features
  75567. declare class XRRay {
  75568. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  75569. origin: DOMPointReadOnly;
  75570. direction: DOMPointReadOnly;
  75571. matrix: Float32Array;
  75572. }
  75573. declare enum XRHitTestTrackableType {
  75574. "point",
  75575. "plane",
  75576. "mesh"
  75577. }
  75578. interface XRHitResult {
  75579. hitMatrix: Float32Array;
  75580. }
  75581. interface XRTransientInputHitTestResult {
  75582. readonly inputSource: XRInputSource;
  75583. readonly results: Array<XRHitTestResult>;
  75584. }
  75585. interface XRHitTestResult {
  75586. getPose(baseSpace: XRSpace): XRPose | undefined;
  75587. // When anchor system is enabled
  75588. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  75589. }
  75590. interface XRHitTestSource {
  75591. cancel(): void;
  75592. }
  75593. interface XRTransientInputHitTestSource {
  75594. cancel(): void;
  75595. }
  75596. interface XRHitTestOptionsInit {
  75597. space: XRSpace;
  75598. entityTypes?: Array<XRHitTestTrackableType>;
  75599. offsetRay?: XRRay;
  75600. }
  75601. interface XRTransientInputHitTestOptionsInit {
  75602. profile: string;
  75603. entityTypes?: Array<XRHitTestTrackableType>;
  75604. offsetRay?: XRRay;
  75605. }
  75606. interface XRAnchor {
  75607. anchorSpace: XRSpace;
  75608. delete(): void;
  75609. }
  75610. interface XRPlane {
  75611. orientation: "Horizontal" | "Vertical";
  75612. planeSpace: XRSpace;
  75613. polygon: Array<DOMPointReadOnly>;
  75614. lastChangedTime: number;
  75615. }
  75616. /**
  75617. * @ignore
  75618. */
  75619. declare module BABYLON.GLTF2.Exporter {
  75620. }
  75621. /**
  75622. * @ignore
  75623. */
  75624. declare module BABYLON.GLTF1 {
  75625. }
  75626. declare module BABYLON.GUI {
  75627. /**
  75628. * Class used to specific a value and its associated unit
  75629. */
  75630. export class ValueAndUnit {
  75631. /** defines the unit to store */
  75632. unit: number;
  75633. /** defines a boolean indicating if the value can be negative */
  75634. negativeValueAllowed: boolean;
  75635. private _value;
  75636. private _originalUnit;
  75637. /**
  75638. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  75639. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75640. */
  75641. ignoreAdaptiveScaling: boolean;
  75642. /**
  75643. * Creates a new ValueAndUnit
  75644. * @param value defines the value to store
  75645. * @param unit defines the unit to store
  75646. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  75647. */
  75648. constructor(value: number,
  75649. /** defines the unit to store */
  75650. unit?: number,
  75651. /** defines a boolean indicating if the value can be negative */
  75652. negativeValueAllowed?: boolean);
  75653. /** Gets a boolean indicating if the value is a percentage */
  75654. get isPercentage(): boolean;
  75655. /** Gets a boolean indicating if the value is store as pixel */
  75656. get isPixel(): boolean;
  75657. /** Gets direct internal value */
  75658. get internalValue(): number;
  75659. /**
  75660. * Gets value as pixel
  75661. * @param host defines the root host
  75662. * @param refValue defines the reference value for percentages
  75663. * @returns the value as pixel
  75664. */
  75665. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  75666. /**
  75667. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  75668. * @param value defines the value to store
  75669. * @param unit defines the unit to store
  75670. * @returns the current ValueAndUnit
  75671. */
  75672. updateInPlace(value: number, unit?: number): ValueAndUnit;
  75673. /**
  75674. * Gets the value accordingly to its unit
  75675. * @param host defines the root host
  75676. * @returns the value
  75677. */
  75678. getValue(host: AdvancedDynamicTexture): number;
  75679. /**
  75680. * Gets a string representation of the value
  75681. * @param host defines the root host
  75682. * @param decimals defines an optional number of decimals to display
  75683. * @returns a string
  75684. */
  75685. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  75686. /**
  75687. * Store a value parsed from a string
  75688. * @param source defines the source string
  75689. * @returns true if the value was successfully parsed
  75690. */
  75691. fromString(source: string | number): boolean;
  75692. private static _Regex;
  75693. private static _UNITMODE_PERCENTAGE;
  75694. private static _UNITMODE_PIXEL;
  75695. /** UNITMODE_PERCENTAGE */
  75696. static get UNITMODE_PERCENTAGE(): number;
  75697. /** UNITMODE_PIXEL */
  75698. static get UNITMODE_PIXEL(): number;
  75699. }
  75700. }
  75701. declare module BABYLON.GUI {
  75702. /**
  75703. * Define a style used by control to automatically setup properties based on a template.
  75704. * Only support font related properties so far
  75705. */
  75706. export class Style implements BABYLON.IDisposable {
  75707. private _fontFamily;
  75708. private _fontStyle;
  75709. private _fontWeight;
  75710. /** @hidden */
  75711. _host: AdvancedDynamicTexture;
  75712. /** @hidden */
  75713. _fontSize: ValueAndUnit;
  75714. /**
  75715. * BABYLON.Observable raised when the style values are changed
  75716. */
  75717. onChangedObservable: BABYLON.Observable<Style>;
  75718. /**
  75719. * Creates a new style object
  75720. * @param host defines the AdvancedDynamicTexture which hosts this style
  75721. */
  75722. constructor(host: AdvancedDynamicTexture);
  75723. /**
  75724. * Gets or sets the font size
  75725. */
  75726. get fontSize(): string | number;
  75727. set fontSize(value: string | number);
  75728. /**
  75729. * Gets or sets the font family
  75730. */
  75731. get fontFamily(): string;
  75732. set fontFamily(value: string);
  75733. /**
  75734. * Gets or sets the font style
  75735. */
  75736. get fontStyle(): string;
  75737. set fontStyle(value: string);
  75738. /** Gets or sets font weight */
  75739. get fontWeight(): string;
  75740. set fontWeight(value: string);
  75741. /** Dispose all associated resources */
  75742. dispose(): void;
  75743. }
  75744. }
  75745. declare module BABYLON.GUI {
  75746. /**
  75747. * Class used to transport BABYLON.Vector2 information for pointer events
  75748. */
  75749. export class Vector2WithInfo extends BABYLON.Vector2 {
  75750. /** defines the current mouse button index */
  75751. buttonIndex: number;
  75752. /**
  75753. * Creates a new Vector2WithInfo
  75754. * @param source defines the vector2 data to transport
  75755. * @param buttonIndex defines the current mouse button index
  75756. */
  75757. constructor(source: BABYLON.Vector2,
  75758. /** defines the current mouse button index */
  75759. buttonIndex?: number);
  75760. }
  75761. /** Class used to provide 2D matrix features */
  75762. export class Matrix2D {
  75763. /** Gets the internal array of 6 floats used to store matrix data */
  75764. m: Float32Array;
  75765. /**
  75766. * Creates a new matrix
  75767. * @param m00 defines value for (0, 0)
  75768. * @param m01 defines value for (0, 1)
  75769. * @param m10 defines value for (1, 0)
  75770. * @param m11 defines value for (1, 1)
  75771. * @param m20 defines value for (2, 0)
  75772. * @param m21 defines value for (2, 1)
  75773. */
  75774. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  75775. /**
  75776. * Fills the matrix from direct values
  75777. * @param m00 defines value for (0, 0)
  75778. * @param m01 defines value for (0, 1)
  75779. * @param m10 defines value for (1, 0)
  75780. * @param m11 defines value for (1, 1)
  75781. * @param m20 defines value for (2, 0)
  75782. * @param m21 defines value for (2, 1)
  75783. * @returns the current modified matrix
  75784. */
  75785. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  75786. /**
  75787. * Gets matrix determinant
  75788. * @returns the determinant
  75789. */
  75790. determinant(): number;
  75791. /**
  75792. * Inverses the matrix and stores it in a target matrix
  75793. * @param result defines the target matrix
  75794. * @returns the current matrix
  75795. */
  75796. invertToRef(result: Matrix2D): Matrix2D;
  75797. /**
  75798. * Multiplies the current matrix with another one
  75799. * @param other defines the second operand
  75800. * @param result defines the target matrix
  75801. * @returns the current matrix
  75802. */
  75803. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  75804. /**
  75805. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  75806. * @param x defines the x coordinate to transform
  75807. * @param y defines the x coordinate to transform
  75808. * @param result defines the target vector2
  75809. * @returns the current matrix
  75810. */
  75811. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  75812. /**
  75813. * Creates an identity matrix
  75814. * @returns a new matrix
  75815. */
  75816. static Identity(): Matrix2D;
  75817. /**
  75818. * Creates a translation matrix and stores it in a target matrix
  75819. * @param x defines the x coordinate of the translation
  75820. * @param y defines the y coordinate of the translation
  75821. * @param result defines the target matrix
  75822. */
  75823. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  75824. /**
  75825. * Creates a scaling matrix and stores it in a target matrix
  75826. * @param x defines the x coordinate of the scaling
  75827. * @param y defines the y coordinate of the scaling
  75828. * @param result defines the target matrix
  75829. */
  75830. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  75831. /**
  75832. * Creates a rotation matrix and stores it in a target matrix
  75833. * @param angle defines the rotation angle
  75834. * @param result defines the target matrix
  75835. */
  75836. static RotationToRef(angle: number, result: Matrix2D): void;
  75837. private static _TempPreTranslationMatrix;
  75838. private static _TempPostTranslationMatrix;
  75839. private static _TempRotationMatrix;
  75840. private static _TempScalingMatrix;
  75841. private static _TempCompose0;
  75842. private static _TempCompose1;
  75843. private static _TempCompose2;
  75844. /**
  75845. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  75846. * @param tx defines the x coordinate of the translation
  75847. * @param ty defines the y coordinate of the translation
  75848. * @param angle defines the rotation angle
  75849. * @param scaleX defines the x coordinate of the scaling
  75850. * @param scaleY defines the y coordinate of the scaling
  75851. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  75852. * @param result defines the target matrix
  75853. */
  75854. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  75855. }
  75856. }
  75857. declare module BABYLON.GUI {
  75858. /**
  75859. * Class used to store 2D control sizes
  75860. */
  75861. export class Measure {
  75862. /** defines left coordinate */
  75863. left: number;
  75864. /** defines top coordinate */
  75865. top: number;
  75866. /** defines width dimension */
  75867. width: number;
  75868. /** defines height dimension */
  75869. height: number;
  75870. /**
  75871. * Creates a new measure
  75872. * @param left defines left coordinate
  75873. * @param top defines top coordinate
  75874. * @param width defines width dimension
  75875. * @param height defines height dimension
  75876. */
  75877. constructor(
  75878. /** defines left coordinate */
  75879. left: number,
  75880. /** defines top coordinate */
  75881. top: number,
  75882. /** defines width dimension */
  75883. width: number,
  75884. /** defines height dimension */
  75885. height: number);
  75886. /**
  75887. * Copy from another measure
  75888. * @param other defines the other measure to copy from
  75889. */
  75890. copyFrom(other: Measure): void;
  75891. /**
  75892. * Copy from a group of 4 floats
  75893. * @param left defines left coordinate
  75894. * @param top defines top coordinate
  75895. * @param width defines width dimension
  75896. * @param height defines height dimension
  75897. */
  75898. copyFromFloats(left: number, top: number, width: number, height: number): void;
  75899. /**
  75900. * Computes the axis aligned bounding box measure for two given measures
  75901. * @param a Input measure
  75902. * @param b Input measure
  75903. * @param result the resulting bounding measure
  75904. */
  75905. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  75906. /**
  75907. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  75908. * @param transform the matrix to transform the measure before computing the AABB
  75909. * @param addX number to add to left
  75910. * @param addY number to add to top
  75911. * @param addWidth number to add to width
  75912. * @param addHeight number to add to height
  75913. * @param result the resulting AABB
  75914. */
  75915. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  75916. /**
  75917. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  75918. * @param transform the matrix to transform the measure before computing the AABB
  75919. * @param result the resulting AABB
  75920. */
  75921. transformToRef(transform: Matrix2D, result: Measure): void;
  75922. /**
  75923. * Check equality between this measure and another one
  75924. * @param other defines the other measures
  75925. * @returns true if both measures are equals
  75926. */
  75927. isEqualsTo(other: Measure): boolean;
  75928. /**
  75929. * Creates an empty measure
  75930. * @returns a new measure
  75931. */
  75932. static Empty(): Measure;
  75933. }
  75934. }
  75935. declare module BABYLON.GUI {
  75936. /**
  75937. * Interface used to define a control that can receive focus
  75938. */
  75939. export interface IFocusableControl {
  75940. /**
  75941. * Function called when the control receives the focus
  75942. */
  75943. onFocus(): void;
  75944. /**
  75945. * Function called when the control loses the focus
  75946. */
  75947. onBlur(): void;
  75948. /**
  75949. * Function called to let the control handle keyboard events
  75950. * @param evt defines the current keyboard event
  75951. */
  75952. processKeyboard(evt: KeyboardEvent): void;
  75953. /**
  75954. * Function called to get the list of controls that should not steal the focus from this control
  75955. * @returns an array of controls
  75956. */
  75957. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  75958. }
  75959. /**
  75960. * Class used to create texture to support 2D GUI elements
  75961. * @see https://doc.babylonjs.com/how_to/gui
  75962. */
  75963. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  75964. private _isDirty;
  75965. private _renderObserver;
  75966. private _resizeObserver;
  75967. private _preKeyboardObserver;
  75968. private _pointerMoveObserver;
  75969. private _pointerObserver;
  75970. private _canvasPointerOutObserver;
  75971. private _canvasBlurObserver;
  75972. private _background;
  75973. /** @hidden */
  75974. _rootContainer: Container;
  75975. /** @hidden */
  75976. _lastPickedControl: Control;
  75977. /** @hidden */
  75978. _lastControlOver: {
  75979. [pointerId: number]: Control;
  75980. };
  75981. /** @hidden */
  75982. _lastControlDown: {
  75983. [pointerId: number]: Control;
  75984. };
  75985. /** @hidden */
  75986. _capturingControl: {
  75987. [pointerId: number]: Control;
  75988. };
  75989. /** @hidden */
  75990. _shouldBlockPointer: boolean;
  75991. /** @hidden */
  75992. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  75993. /** @hidden */
  75994. _linkedControls: Control[];
  75995. private _isFullscreen;
  75996. private _fullscreenViewport;
  75997. private _idealWidth;
  75998. private _idealHeight;
  75999. private _useSmallestIdeal;
  76000. private _renderAtIdealSize;
  76001. private _focusedControl;
  76002. private _blockNextFocusCheck;
  76003. private _renderScale;
  76004. private _rootElement;
  76005. private _cursorChanged;
  76006. private _defaultMousePointerId;
  76007. /** @hidden */
  76008. _numLayoutCalls: number;
  76009. /** Gets the number of layout calls made the last time the ADT has been rendered */
  76010. get numLayoutCalls(): number;
  76011. /** @hidden */
  76012. _numRenderCalls: number;
  76013. /** Gets the number of render calls made the last time the ADT has been rendered */
  76014. get numRenderCalls(): number;
  76015. /**
  76016. * Define type to string to ensure compatibility across browsers
  76017. * Safari doesn't support DataTransfer constructor
  76018. */
  76019. private _clipboardData;
  76020. /**
  76021. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  76022. */
  76023. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  76024. /**
  76025. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  76026. */
  76027. onControlPickedObservable: BABYLON.Observable<Control>;
  76028. /**
  76029. * BABYLON.Observable event triggered before layout is evaluated
  76030. */
  76031. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76032. /**
  76033. * BABYLON.Observable event triggered after the layout was evaluated
  76034. */
  76035. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76036. /**
  76037. * BABYLON.Observable event triggered before the texture is rendered
  76038. */
  76039. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76040. /**
  76041. * BABYLON.Observable event triggered after the texture was rendered
  76042. */
  76043. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76044. /**
  76045. * Gets or sets a boolean defining if alpha is stored as premultiplied
  76046. */
  76047. premulAlpha: boolean;
  76048. /**
  76049. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  76050. * Useful when you want more antialiasing
  76051. */
  76052. get renderScale(): number;
  76053. set renderScale(value: number);
  76054. /** Gets or sets the background color */
  76055. get background(): string;
  76056. set background(value: string);
  76057. /**
  76058. * Gets or sets the ideal width used to design controls.
  76059. * The GUI will then rescale everything accordingly
  76060. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76061. */
  76062. get idealWidth(): number;
  76063. set idealWidth(value: number);
  76064. /**
  76065. * Gets or sets the ideal height used to design controls.
  76066. * The GUI will then rescale everything accordingly
  76067. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76068. */
  76069. get idealHeight(): number;
  76070. set idealHeight(value: number);
  76071. /**
  76072. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  76073. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76074. */
  76075. get useSmallestIdeal(): boolean;
  76076. set useSmallestIdeal(value: boolean);
  76077. /**
  76078. * Gets or sets a boolean indicating if adaptive scaling must be used
  76079. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76080. */
  76081. get renderAtIdealSize(): boolean;
  76082. set renderAtIdealSize(value: boolean);
  76083. /**
  76084. * Gets the ratio used when in "ideal mode"
  76085. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76086. * */
  76087. get idealRatio(): number;
  76088. /**
  76089. * Gets the underlying layer used to render the texture when in fullscreen mode
  76090. */
  76091. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  76092. /**
  76093. * Gets the root container control
  76094. */
  76095. get rootContainer(): Container;
  76096. /**
  76097. * Returns an array containing the root container.
  76098. * This is mostly used to let the Inspector introspects the ADT
  76099. * @returns an array containing the rootContainer
  76100. */
  76101. getChildren(): Array<Container>;
  76102. /**
  76103. * Will return all controls that are inside this texture
  76104. * @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
  76105. * @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
  76106. * @return all child controls
  76107. */
  76108. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  76109. /**
  76110. * Gets or sets the current focused control
  76111. */
  76112. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  76113. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  76114. /**
  76115. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  76116. */
  76117. get isForeground(): boolean;
  76118. set isForeground(value: boolean);
  76119. /**
  76120. * Gets or set information about clipboardData
  76121. */
  76122. get clipboardData(): string;
  76123. set clipboardData(value: string);
  76124. /**
  76125. * Creates a new AdvancedDynamicTexture
  76126. * @param name defines the name of the texture
  76127. * @param width defines the width of the texture
  76128. * @param height defines the height of the texture
  76129. * @param scene defines the hosting scene
  76130. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  76131. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  76132. */
  76133. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  76134. /**
  76135. * Get the current class name of the texture useful for serialization or dynamic coding.
  76136. * @returns "AdvancedDynamicTexture"
  76137. */
  76138. getClassName(): string;
  76139. /**
  76140. * Function used to execute a function on all controls
  76141. * @param func defines the function to execute
  76142. * @param container defines the container where controls belong. If null the root container will be used
  76143. */
  76144. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  76145. private _useInvalidateRectOptimization;
  76146. /**
  76147. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  76148. */
  76149. get useInvalidateRectOptimization(): boolean;
  76150. set useInvalidateRectOptimization(value: boolean);
  76151. private _invalidatedRectangle;
  76152. /**
  76153. * Invalidates a rectangle area on the gui texture
  76154. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  76155. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  76156. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  76157. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  76158. */
  76159. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  76160. /**
  76161. * Marks the texture as dirty forcing a complete update
  76162. */
  76163. markAsDirty(): void;
  76164. /**
  76165. * Helper function used to create a new style
  76166. * @returns a new style
  76167. * @see https://doc.babylonjs.com/how_to/gui#styles
  76168. */
  76169. createStyle(): Style;
  76170. /**
  76171. * Adds a new control to the root container
  76172. * @param control defines the control to add
  76173. * @returns the current texture
  76174. */
  76175. addControl(control: Control): AdvancedDynamicTexture;
  76176. /**
  76177. * Removes a control from the root container
  76178. * @param control defines the control to remove
  76179. * @returns the current texture
  76180. */
  76181. removeControl(control: Control): AdvancedDynamicTexture;
  76182. /**
  76183. * Release all resources
  76184. */
  76185. dispose(): void;
  76186. private _onResize;
  76187. /** @hidden */
  76188. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  76189. /**
  76190. * Get screen coordinates for a vector3
  76191. * @param position defines the position to project
  76192. * @param worldMatrix defines the world matrix to use
  76193. * @returns the projected position
  76194. */
  76195. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  76196. private _checkUpdate;
  76197. private _clearMeasure;
  76198. private _render;
  76199. /** @hidden */
  76200. _changeCursor(cursor: string): void;
  76201. /** @hidden */
  76202. _registerLastControlDown(control: Control, pointerId: number): void;
  76203. private _doPicking;
  76204. /** @hidden */
  76205. _cleanControlAfterRemovalFromList(list: {
  76206. [pointerId: number]: Control;
  76207. }, control: Control): void;
  76208. /** @hidden */
  76209. _cleanControlAfterRemoval(control: Control): void;
  76210. /** Attach to all scene events required to support pointer events */
  76211. attach(): void;
  76212. /** @hidden */
  76213. private onClipboardCopy;
  76214. /** @hidden */
  76215. private onClipboardCut;
  76216. /** @hidden */
  76217. private onClipboardPaste;
  76218. /**
  76219. * Register the clipboard Events onto the canvas
  76220. */
  76221. registerClipboardEvents(): void;
  76222. /**
  76223. * Unregister the clipboard Events from the canvas
  76224. */
  76225. unRegisterClipboardEvents(): void;
  76226. /**
  76227. * Connect the texture to a hosting mesh to enable interactions
  76228. * @param mesh defines the mesh to attach to
  76229. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  76230. */
  76231. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  76232. /**
  76233. * Move the focus to a specific control
  76234. * @param control defines the control which will receive the focus
  76235. */
  76236. moveFocusToControl(control: IFocusableControl): void;
  76237. private _manageFocus;
  76238. private _attachToOnPointerOut;
  76239. private _attachToOnBlur;
  76240. /**
  76241. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  76242. * @param mesh defines the mesh which will receive the texture
  76243. * @param width defines the texture width (1024 by default)
  76244. * @param height defines the texture height (1024 by default)
  76245. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  76246. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  76247. * @returns a new AdvancedDynamicTexture
  76248. */
  76249. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  76250. /**
  76251. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  76252. * In this mode the texture will rely on a layer for its rendering.
  76253. * This allows it to be treated like any other layer.
  76254. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  76255. * LayerMask is set through advancedTexture.layer.layerMask
  76256. * @param name defines name for the texture
  76257. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  76258. * @param scene defines the hsoting scene
  76259. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  76260. * @returns a new AdvancedDynamicTexture
  76261. */
  76262. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  76263. }
  76264. }
  76265. declare module BABYLON.GUI {
  76266. /**
  76267. * Root class used for all 2D controls
  76268. * @see https://doc.babylonjs.com/how_to/gui#controls
  76269. */
  76270. export class Control {
  76271. /** defines the name of the control */
  76272. name?: string | undefined;
  76273. /**
  76274. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  76275. */
  76276. static AllowAlphaInheritance: boolean;
  76277. private _alpha;
  76278. private _alphaSet;
  76279. private _zIndex;
  76280. /** @hidden */
  76281. _host: AdvancedDynamicTexture;
  76282. /** Gets or sets the control parent */
  76283. parent: BABYLON.Nullable<Container>;
  76284. /** @hidden */
  76285. _currentMeasure: Measure;
  76286. private _fontFamily;
  76287. private _fontStyle;
  76288. private _fontWeight;
  76289. private _fontSize;
  76290. private _font;
  76291. /** @hidden */
  76292. _width: ValueAndUnit;
  76293. /** @hidden */
  76294. _height: ValueAndUnit;
  76295. /** @hidden */
  76296. protected _fontOffset: {
  76297. ascent: number;
  76298. height: number;
  76299. descent: number;
  76300. };
  76301. private _color;
  76302. private _style;
  76303. private _styleObserver;
  76304. /** @hidden */
  76305. protected _horizontalAlignment: number;
  76306. /** @hidden */
  76307. protected _verticalAlignment: number;
  76308. /** @hidden */
  76309. protected _isDirty: boolean;
  76310. /** @hidden */
  76311. protected _wasDirty: boolean;
  76312. /** @hidden */
  76313. _tempParentMeasure: Measure;
  76314. /** @hidden */
  76315. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  76316. /** @hidden */
  76317. protected _cachedParentMeasure: Measure;
  76318. private _paddingLeft;
  76319. private _paddingRight;
  76320. private _paddingTop;
  76321. private _paddingBottom;
  76322. /** @hidden */
  76323. _left: ValueAndUnit;
  76324. /** @hidden */
  76325. _top: ValueAndUnit;
  76326. private _scaleX;
  76327. private _scaleY;
  76328. private _rotation;
  76329. private _transformCenterX;
  76330. private _transformCenterY;
  76331. /** @hidden */
  76332. _transformMatrix: Matrix2D;
  76333. /** @hidden */
  76334. protected _invertTransformMatrix: Matrix2D;
  76335. /** @hidden */
  76336. protected _transformedPosition: BABYLON.Vector2;
  76337. private _isMatrixDirty;
  76338. private _cachedOffsetX;
  76339. private _cachedOffsetY;
  76340. private _isVisible;
  76341. private _isHighlighted;
  76342. /** @hidden */
  76343. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  76344. private _fontSet;
  76345. private _dummyVector2;
  76346. private _downCount;
  76347. private _enterCount;
  76348. private _doNotRender;
  76349. private _downPointerIds;
  76350. protected _isEnabled: boolean;
  76351. protected _disabledColor: string;
  76352. protected _disabledColorItem: string;
  76353. /** @hidden */
  76354. protected _rebuildLayout: boolean;
  76355. /** @hidden */
  76356. _customData: any;
  76357. /** @hidden */
  76358. _isClipped: boolean;
  76359. /** @hidden */
  76360. _automaticSize: boolean;
  76361. /** @hidden */
  76362. _tag: any;
  76363. /**
  76364. * 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
  76365. */
  76366. uniqueId: number;
  76367. /**
  76368. * Gets or sets an object used to store user defined information for the node
  76369. */
  76370. metadata: any;
  76371. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  76372. isHitTestVisible: boolean;
  76373. /** Gets or sets a boolean indicating if the control can block pointer events */
  76374. isPointerBlocker: boolean;
  76375. /** Gets or sets a boolean indicating if the control can be focusable */
  76376. isFocusInvisible: boolean;
  76377. /**
  76378. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  76379. * 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
  76380. */
  76381. clipChildren: boolean;
  76382. /**
  76383. * Gets or sets a boolean indicating that control content must be clipped
  76384. * 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
  76385. */
  76386. clipContent: boolean;
  76387. /**
  76388. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  76389. */
  76390. useBitmapCache: boolean;
  76391. private _cacheData;
  76392. private _shadowOffsetX;
  76393. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  76394. get shadowOffsetX(): number;
  76395. set shadowOffsetX(value: number);
  76396. private _shadowOffsetY;
  76397. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  76398. get shadowOffsetY(): number;
  76399. set shadowOffsetY(value: number);
  76400. private _shadowBlur;
  76401. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  76402. get shadowBlur(): number;
  76403. set shadowBlur(value: number);
  76404. private _shadowColor;
  76405. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  76406. get shadowColor(): string;
  76407. set shadowColor(value: string);
  76408. /** Gets or sets the cursor to use when the control is hovered */
  76409. hoverCursor: string;
  76410. /** @hidden */
  76411. protected _linkOffsetX: ValueAndUnit;
  76412. /** @hidden */
  76413. protected _linkOffsetY: ValueAndUnit;
  76414. /** Gets the control type name */
  76415. get typeName(): string;
  76416. /**
  76417. * Get the current class name of the control.
  76418. * @returns current class name
  76419. */
  76420. getClassName(): string;
  76421. /**
  76422. * An event triggered when pointer wheel is scrolled
  76423. */
  76424. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  76425. /**
  76426. * An event triggered when the pointer move over the control.
  76427. */
  76428. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  76429. /**
  76430. * An event triggered when the pointer move out of the control.
  76431. */
  76432. onPointerOutObservable: BABYLON.Observable<Control>;
  76433. /**
  76434. * An event triggered when the pointer taps the control
  76435. */
  76436. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  76437. /**
  76438. * An event triggered when pointer up
  76439. */
  76440. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  76441. /**
  76442. * An event triggered when a control is clicked on
  76443. */
  76444. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  76445. /**
  76446. * An event triggered when pointer enters the control
  76447. */
  76448. onPointerEnterObservable: BABYLON.Observable<Control>;
  76449. /**
  76450. * An event triggered when the control is marked as dirty
  76451. */
  76452. onDirtyObservable: BABYLON.Observable<Control>;
  76453. /**
  76454. * An event triggered before drawing the control
  76455. */
  76456. onBeforeDrawObservable: BABYLON.Observable<Control>;
  76457. /**
  76458. * An event triggered after the control was drawn
  76459. */
  76460. onAfterDrawObservable: BABYLON.Observable<Control>;
  76461. /**
  76462. * An event triggered when the control has been disposed
  76463. */
  76464. onDisposeObservable: BABYLON.Observable<Control>;
  76465. /**
  76466. * Get the hosting AdvancedDynamicTexture
  76467. */
  76468. get host(): AdvancedDynamicTexture;
  76469. /** Gets or set information about font offsets (used to render and align text) */
  76470. get fontOffset(): {
  76471. ascent: number;
  76472. height: number;
  76473. descent: number;
  76474. };
  76475. set fontOffset(offset: {
  76476. ascent: number;
  76477. height: number;
  76478. descent: number;
  76479. });
  76480. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  76481. get alpha(): number;
  76482. set alpha(value: number);
  76483. /**
  76484. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  76485. */
  76486. get isHighlighted(): boolean;
  76487. set isHighlighted(value: boolean);
  76488. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  76489. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76490. */
  76491. get scaleX(): number;
  76492. set scaleX(value: number);
  76493. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  76494. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76495. */
  76496. get scaleY(): number;
  76497. set scaleY(value: number);
  76498. /** Gets or sets the rotation angle (0 by default)
  76499. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76500. */
  76501. get rotation(): number;
  76502. set rotation(value: number);
  76503. /** Gets or sets the transformation center on Y axis (0 by default)
  76504. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76505. */
  76506. get transformCenterY(): number;
  76507. set transformCenterY(value: number);
  76508. /** Gets or sets the transformation center on X axis (0 by default)
  76509. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76510. */
  76511. get transformCenterX(): number;
  76512. set transformCenterX(value: number);
  76513. /**
  76514. * Gets or sets the horizontal alignment
  76515. * @see https://doc.babylonjs.com/how_to/gui#alignments
  76516. */
  76517. get horizontalAlignment(): number;
  76518. set horizontalAlignment(value: number);
  76519. /**
  76520. * Gets or sets the vertical alignment
  76521. * @see https://doc.babylonjs.com/how_to/gui#alignments
  76522. */
  76523. get verticalAlignment(): number;
  76524. set verticalAlignment(value: number);
  76525. /**
  76526. * Gets or sets a fixed ratio for this control.
  76527. * When different from 0, the ratio is used to compute the "second" dimension.
  76528. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  76529. * second dimension is computed as first dimension * fixedRatio
  76530. */
  76531. fixedRatio: number;
  76532. private _fixedRatioMasterIsWidth;
  76533. /**
  76534. * Gets or sets control width
  76535. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76536. */
  76537. get width(): string | number;
  76538. set width(value: string | number);
  76539. /**
  76540. * Gets or sets the control width in pixel
  76541. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76542. */
  76543. get widthInPixels(): number;
  76544. set widthInPixels(value: number);
  76545. /**
  76546. * Gets or sets control height
  76547. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76548. */
  76549. get height(): string | number;
  76550. set height(value: string | number);
  76551. /**
  76552. * Gets or sets control height in pixel
  76553. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76554. */
  76555. get heightInPixels(): number;
  76556. set heightInPixels(value: number);
  76557. /** Gets or set font family */
  76558. get fontFamily(): string;
  76559. set fontFamily(value: string);
  76560. /** Gets or sets font style */
  76561. get fontStyle(): string;
  76562. set fontStyle(value: string);
  76563. /** Gets or sets font weight */
  76564. get fontWeight(): string;
  76565. set fontWeight(value: string);
  76566. /**
  76567. * Gets or sets style
  76568. * @see https://doc.babylonjs.com/how_to/gui#styles
  76569. */
  76570. get style(): BABYLON.Nullable<Style>;
  76571. set style(value: BABYLON.Nullable<Style>);
  76572. /** @hidden */
  76573. get _isFontSizeInPercentage(): boolean;
  76574. /** Gets or sets font size in pixels */
  76575. get fontSizeInPixels(): number;
  76576. set fontSizeInPixels(value: number);
  76577. /** Gets or sets font size */
  76578. get fontSize(): string | number;
  76579. set fontSize(value: string | number);
  76580. /** Gets or sets foreground color */
  76581. get color(): string;
  76582. set color(value: string);
  76583. /** Gets or sets z index which is used to reorder controls on the z axis */
  76584. get zIndex(): number;
  76585. set zIndex(value: number);
  76586. /** Gets or sets a boolean indicating if the control can be rendered */
  76587. get notRenderable(): boolean;
  76588. set notRenderable(value: boolean);
  76589. /** Gets or sets a boolean indicating if the control is visible */
  76590. get isVisible(): boolean;
  76591. set isVisible(value: boolean);
  76592. /** Gets a boolean indicating that the control needs to update its rendering */
  76593. get isDirty(): boolean;
  76594. /**
  76595. * Gets the current linked mesh (or null if none)
  76596. */
  76597. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  76598. /**
  76599. * Gets or sets a value indicating the padding to use on the left of the control
  76600. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76601. */
  76602. get paddingLeft(): string | number;
  76603. set paddingLeft(value: string | number);
  76604. /**
  76605. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  76606. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76607. */
  76608. get paddingLeftInPixels(): number;
  76609. set paddingLeftInPixels(value: number);
  76610. /**
  76611. * Gets or sets a value indicating the padding to use on the right of the control
  76612. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76613. */
  76614. get paddingRight(): string | number;
  76615. set paddingRight(value: string | number);
  76616. /**
  76617. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  76618. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76619. */
  76620. get paddingRightInPixels(): number;
  76621. set paddingRightInPixels(value: number);
  76622. /**
  76623. * Gets or sets a value indicating the padding to use on the top of the control
  76624. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76625. */
  76626. get paddingTop(): string | number;
  76627. set paddingTop(value: string | number);
  76628. /**
  76629. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  76630. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76631. */
  76632. get paddingTopInPixels(): number;
  76633. set paddingTopInPixels(value: number);
  76634. /**
  76635. * Gets or sets a value indicating the padding to use on the bottom of the control
  76636. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76637. */
  76638. get paddingBottom(): string | number;
  76639. set paddingBottom(value: string | number);
  76640. /**
  76641. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  76642. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76643. */
  76644. get paddingBottomInPixels(): number;
  76645. set paddingBottomInPixels(value: number);
  76646. /**
  76647. * Gets or sets a value indicating the left coordinate of the control
  76648. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76649. */
  76650. get left(): string | number;
  76651. set left(value: string | number);
  76652. /**
  76653. * Gets or sets a value indicating the left coordinate in pixels of the control
  76654. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76655. */
  76656. get leftInPixels(): number;
  76657. set leftInPixels(value: number);
  76658. /**
  76659. * Gets or sets a value indicating the top coordinate of the control
  76660. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76661. */
  76662. get top(): string | number;
  76663. set top(value: string | number);
  76664. /**
  76665. * Gets or sets a value indicating the top coordinate in pixels of the control
  76666. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76667. */
  76668. get topInPixels(): number;
  76669. set topInPixels(value: number);
  76670. /**
  76671. * Gets or sets a value indicating the offset on X axis to the linked mesh
  76672. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76673. */
  76674. get linkOffsetX(): string | number;
  76675. set linkOffsetX(value: string | number);
  76676. /**
  76677. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  76678. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76679. */
  76680. get linkOffsetXInPixels(): number;
  76681. set linkOffsetXInPixels(value: number);
  76682. /**
  76683. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  76684. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76685. */
  76686. get linkOffsetY(): string | number;
  76687. set linkOffsetY(value: string | number);
  76688. /**
  76689. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  76690. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76691. */
  76692. get linkOffsetYInPixels(): number;
  76693. set linkOffsetYInPixels(value: number);
  76694. /** Gets the center coordinate on X axis */
  76695. get centerX(): number;
  76696. /** Gets the center coordinate on Y axis */
  76697. get centerY(): number;
  76698. /** Gets or sets if control is Enabled*/
  76699. get isEnabled(): boolean;
  76700. set isEnabled(value: boolean);
  76701. /** Gets or sets background color of control if it's disabled*/
  76702. get disabledColor(): string;
  76703. set disabledColor(value: string);
  76704. /** Gets or sets front color of control if it's disabled*/
  76705. get disabledColorItem(): string;
  76706. set disabledColorItem(value: string);
  76707. /**
  76708. * Creates a new control
  76709. * @param name defines the name of the control
  76710. */
  76711. constructor(
  76712. /** defines the name of the control */
  76713. name?: string | undefined);
  76714. /** @hidden */
  76715. protected _getTypeName(): string;
  76716. /**
  76717. * Gets the first ascendant in the hierarchy of the given type
  76718. * @param className defines the required type
  76719. * @returns the ascendant or null if not found
  76720. */
  76721. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  76722. /** @hidden */
  76723. _resetFontCache(): void;
  76724. /**
  76725. * Determines if a container is an ascendant of the current control
  76726. * @param container defines the container to look for
  76727. * @returns true if the container is one of the ascendant of the control
  76728. */
  76729. isAscendant(container: Control): boolean;
  76730. /**
  76731. * Gets coordinates in local control space
  76732. * @param globalCoordinates defines the coordinates to transform
  76733. * @returns the new coordinates in local space
  76734. */
  76735. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  76736. /**
  76737. * Gets coordinates in local control space
  76738. * @param globalCoordinates defines the coordinates to transform
  76739. * @param result defines the target vector2 where to store the result
  76740. * @returns the current control
  76741. */
  76742. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  76743. /**
  76744. * Gets coordinates in parent local control space
  76745. * @param globalCoordinates defines the coordinates to transform
  76746. * @returns the new coordinates in parent local space
  76747. */
  76748. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  76749. /**
  76750. * Move the current control to a vector3 position projected onto the screen.
  76751. * @param position defines the target position
  76752. * @param scene defines the hosting scene
  76753. */
  76754. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  76755. /**
  76756. * Will store all controls that have this control as ascendant in a given array
  76757. * @param results defines the array where to store the descendants
  76758. * @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
  76759. * @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
  76760. */
  76761. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  76762. /**
  76763. * Will return all controls that have this control as ascendant
  76764. * @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
  76765. * @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
  76766. * @return all child controls
  76767. */
  76768. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  76769. /**
  76770. * Link current control with a target mesh
  76771. * @param mesh defines the mesh to link with
  76772. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76773. */
  76774. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  76775. /** @hidden */
  76776. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  76777. /** @hidden */
  76778. _offsetLeft(offset: number): void;
  76779. /** @hidden */
  76780. _offsetTop(offset: number): void;
  76781. /** @hidden */
  76782. _markMatrixAsDirty(): void;
  76783. /** @hidden */
  76784. _flagDescendantsAsMatrixDirty(): void;
  76785. /** @hidden */
  76786. _intersectsRect(rect: Measure): boolean;
  76787. /** @hidden */
  76788. protected invalidateRect(): void;
  76789. /** @hidden */
  76790. _markAsDirty(force?: boolean): void;
  76791. /** @hidden */
  76792. _markAllAsDirty(): void;
  76793. /** @hidden */
  76794. _link(host: AdvancedDynamicTexture): void;
  76795. /** @hidden */
  76796. protected _transform(context?: CanvasRenderingContext2D): void;
  76797. /** @hidden */
  76798. _renderHighlight(context: CanvasRenderingContext2D): void;
  76799. /** @hidden */
  76800. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76801. /** @hidden */
  76802. protected _applyStates(context: CanvasRenderingContext2D): void;
  76803. /** @hidden */
  76804. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76805. /** @hidden */
  76806. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76807. protected _evaluateClippingState(parentMeasure: Measure): void;
  76808. /** @hidden */
  76809. _measure(): void;
  76810. /** @hidden */
  76811. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76812. /** @hidden */
  76813. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76814. /** @hidden */
  76815. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76816. /** @hidden */
  76817. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76818. private static _ClipMeasure;
  76819. private _tmpMeasureA;
  76820. private _clip;
  76821. /** @hidden */
  76822. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  76823. /** @hidden */
  76824. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76825. /**
  76826. * Tests if a given coordinates belong to the current control
  76827. * @param x defines x coordinate to test
  76828. * @param y defines y coordinate to test
  76829. * @returns true if the coordinates are inside the control
  76830. */
  76831. contains(x: number, y: number): boolean;
  76832. /** @hidden */
  76833. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76834. /** @hidden */
  76835. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76836. /** @hidden */
  76837. _onPointerEnter(target: Control): boolean;
  76838. /** @hidden */
  76839. _onPointerOut(target: Control, force?: boolean): void;
  76840. /** @hidden */
  76841. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76842. /** @hidden */
  76843. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76844. /** @hidden */
  76845. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  76846. /** @hidden */
  76847. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  76848. /** @hidden */
  76849. _onCanvasBlur(): void;
  76850. /** @hidden */
  76851. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76852. private _prepareFont;
  76853. /** Releases associated resources */
  76854. dispose(): void;
  76855. private static _HORIZONTAL_ALIGNMENT_LEFT;
  76856. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  76857. private static _HORIZONTAL_ALIGNMENT_CENTER;
  76858. private static _VERTICAL_ALIGNMENT_TOP;
  76859. private static _VERTICAL_ALIGNMENT_BOTTOM;
  76860. private static _VERTICAL_ALIGNMENT_CENTER;
  76861. /** HORIZONTAL_ALIGNMENT_LEFT */
  76862. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  76863. /** HORIZONTAL_ALIGNMENT_RIGHT */
  76864. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  76865. /** HORIZONTAL_ALIGNMENT_CENTER */
  76866. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  76867. /** VERTICAL_ALIGNMENT_TOP */
  76868. static get VERTICAL_ALIGNMENT_TOP(): number;
  76869. /** VERTICAL_ALIGNMENT_BOTTOM */
  76870. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  76871. /** VERTICAL_ALIGNMENT_CENTER */
  76872. static get VERTICAL_ALIGNMENT_CENTER(): number;
  76873. private static _FontHeightSizes;
  76874. /** @hidden */
  76875. static _GetFontOffset(font: string): {
  76876. ascent: number;
  76877. height: number;
  76878. descent: number;
  76879. };
  76880. /**
  76881. * Creates a stack panel that can be used to render headers
  76882. * @param control defines the control to associate with the header
  76883. * @param text defines the text of the header
  76884. * @param size defines the size of the header
  76885. * @param options defines options used to configure the header
  76886. * @returns a new StackPanel
  76887. * @ignore
  76888. * @hidden
  76889. */
  76890. static AddHeader: (control: Control, text: string, size: string | number, options: {
  76891. isHorizontal: boolean;
  76892. controlFirst: boolean;
  76893. }) => any;
  76894. /** @hidden */
  76895. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  76896. }
  76897. }
  76898. declare module BABYLON.GUI {
  76899. /**
  76900. * Root class for 2D containers
  76901. * @see https://doc.babylonjs.com/how_to/gui#containers
  76902. */
  76903. export class Container extends Control {
  76904. name?: string | undefined;
  76905. /** @hidden */
  76906. _children: Control[];
  76907. /** @hidden */
  76908. protected _measureForChildren: Measure;
  76909. /** @hidden */
  76910. protected _background: string;
  76911. /** @hidden */
  76912. protected _adaptWidthToChildren: boolean;
  76913. /** @hidden */
  76914. protected _adaptHeightToChildren: boolean;
  76915. /**
  76916. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  76917. */
  76918. logLayoutCycleErrors: boolean;
  76919. /**
  76920. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  76921. */
  76922. maxLayoutCycle: number;
  76923. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  76924. get adaptHeightToChildren(): boolean;
  76925. set adaptHeightToChildren(value: boolean);
  76926. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  76927. get adaptWidthToChildren(): boolean;
  76928. set adaptWidthToChildren(value: boolean);
  76929. /** Gets or sets background color */
  76930. get background(): string;
  76931. set background(value: string);
  76932. /** Gets the list of children */
  76933. get children(): Control[];
  76934. /**
  76935. * Creates a new Container
  76936. * @param name defines the name of the container
  76937. */
  76938. constructor(name?: string | undefined);
  76939. protected _getTypeName(): string;
  76940. _flagDescendantsAsMatrixDirty(): void;
  76941. /**
  76942. * Gets a child using its name
  76943. * @param name defines the child name to look for
  76944. * @returns the child control if found
  76945. */
  76946. getChildByName(name: string): BABYLON.Nullable<Control>;
  76947. /**
  76948. * Gets a child using its type and its name
  76949. * @param name defines the child name to look for
  76950. * @param type defines the child type to look for
  76951. * @returns the child control if found
  76952. */
  76953. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  76954. /**
  76955. * Search for a specific control in children
  76956. * @param control defines the control to look for
  76957. * @returns true if the control is in child list
  76958. */
  76959. containsControl(control: Control): boolean;
  76960. /**
  76961. * Adds a new control to the current container
  76962. * @param control defines the control to add
  76963. * @returns the current container
  76964. */
  76965. addControl(control: BABYLON.Nullable<Control>): Container;
  76966. /**
  76967. * Removes all controls from the current container
  76968. * @returns the current container
  76969. */
  76970. clearControls(): Container;
  76971. /**
  76972. * Removes a control from the current container
  76973. * @param control defines the control to remove
  76974. * @returns the current container
  76975. */
  76976. removeControl(control: Control): Container;
  76977. /** @hidden */
  76978. _reOrderControl(control: Control): void;
  76979. /** @hidden */
  76980. _offsetLeft(offset: number): void;
  76981. /** @hidden */
  76982. _offsetTop(offset: number): void;
  76983. /** @hidden */
  76984. _markAllAsDirty(): void;
  76985. /** @hidden */
  76986. protected _localDraw(context: CanvasRenderingContext2D): void;
  76987. /** @hidden */
  76988. _link(host: AdvancedDynamicTexture): void;
  76989. /** @hidden */
  76990. protected _beforeLayout(): void;
  76991. /** @hidden */
  76992. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76993. /** @hidden */
  76994. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76995. protected _postMeasure(): void;
  76996. /** @hidden */
  76997. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  76998. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  76999. /** @hidden */
  77000. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77001. /** @hidden */
  77002. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77003. /** Releases associated resources */
  77004. dispose(): void;
  77005. }
  77006. }
  77007. declare module BABYLON.GUI {
  77008. /** Class used to create rectangle container */
  77009. export class Rectangle extends Container {
  77010. name?: string | undefined;
  77011. private _thickness;
  77012. private _cornerRadius;
  77013. /** Gets or sets border thickness */
  77014. get thickness(): number;
  77015. set thickness(value: number);
  77016. /** Gets or sets the corner radius angle */
  77017. get cornerRadius(): number;
  77018. set cornerRadius(value: number);
  77019. /**
  77020. * Creates a new Rectangle
  77021. * @param name defines the control name
  77022. */
  77023. constructor(name?: string | undefined);
  77024. protected _getTypeName(): string;
  77025. protected _localDraw(context: CanvasRenderingContext2D): void;
  77026. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77027. private _drawRoundedRect;
  77028. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77029. }
  77030. }
  77031. declare module BABYLON.GUI {
  77032. /**
  77033. * Enum that determines the text-wrapping mode to use.
  77034. */
  77035. export enum TextWrapping {
  77036. /**
  77037. * Clip the text when it's larger than Control.width; this is the default mode.
  77038. */
  77039. Clip = 0,
  77040. /**
  77041. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  77042. */
  77043. WordWrap = 1,
  77044. /**
  77045. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  77046. */
  77047. Ellipsis = 2
  77048. }
  77049. /**
  77050. * Class used to create text block control
  77051. */
  77052. export class TextBlock extends Control {
  77053. /**
  77054. * Defines the name of the control
  77055. */
  77056. name?: string | undefined;
  77057. private _text;
  77058. private _textWrapping;
  77059. private _textHorizontalAlignment;
  77060. private _textVerticalAlignment;
  77061. private _lines;
  77062. private _resizeToFit;
  77063. private _lineSpacing;
  77064. private _outlineWidth;
  77065. private _outlineColor;
  77066. /**
  77067. * An event triggered after the text is changed
  77068. */
  77069. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  77070. /**
  77071. * An event triggered after the text was broken up into lines
  77072. */
  77073. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  77074. /**
  77075. * Function used to split a string into words. By default, a string is split at each space character found
  77076. */
  77077. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  77078. /**
  77079. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  77080. */
  77081. get lines(): any[];
  77082. /**
  77083. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  77084. */
  77085. get resizeToFit(): boolean;
  77086. /**
  77087. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  77088. */
  77089. set resizeToFit(value: boolean);
  77090. /**
  77091. * Gets or sets a boolean indicating if text must be wrapped
  77092. */
  77093. get textWrapping(): TextWrapping | boolean;
  77094. /**
  77095. * Gets or sets a boolean indicating if text must be wrapped
  77096. */
  77097. set textWrapping(value: TextWrapping | boolean);
  77098. /**
  77099. * Gets or sets text to display
  77100. */
  77101. get text(): string;
  77102. /**
  77103. * Gets or sets text to display
  77104. */
  77105. set text(value: string);
  77106. /**
  77107. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  77108. */
  77109. get textHorizontalAlignment(): number;
  77110. /**
  77111. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  77112. */
  77113. set textHorizontalAlignment(value: number);
  77114. /**
  77115. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  77116. */
  77117. get textVerticalAlignment(): number;
  77118. /**
  77119. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  77120. */
  77121. set textVerticalAlignment(value: number);
  77122. /**
  77123. * Gets or sets line spacing value
  77124. */
  77125. set lineSpacing(value: string | number);
  77126. /**
  77127. * Gets or sets line spacing value
  77128. */
  77129. get lineSpacing(): string | number;
  77130. /**
  77131. * Gets or sets outlineWidth of the text to display
  77132. */
  77133. get outlineWidth(): number;
  77134. /**
  77135. * Gets or sets outlineWidth of the text to display
  77136. */
  77137. set outlineWidth(value: number);
  77138. /**
  77139. * Gets or sets outlineColor of the text to display
  77140. */
  77141. get outlineColor(): string;
  77142. /**
  77143. * Gets or sets outlineColor of the text to display
  77144. */
  77145. set outlineColor(value: string);
  77146. /**
  77147. * Creates a new TextBlock object
  77148. * @param name defines the name of the control
  77149. * @param text defines the text to display (emptry string by default)
  77150. */
  77151. constructor(
  77152. /**
  77153. * Defines the name of the control
  77154. */
  77155. name?: string | undefined, text?: string);
  77156. protected _getTypeName(): string;
  77157. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77158. private _drawText;
  77159. /** @hidden */
  77160. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77161. protected _applyStates(context: CanvasRenderingContext2D): void;
  77162. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  77163. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  77164. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  77165. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  77166. protected _renderLines(context: CanvasRenderingContext2D): void;
  77167. /**
  77168. * Given a width constraint applied on the text block, find the expected height
  77169. * @returns expected height
  77170. */
  77171. computeExpectedHeight(): number;
  77172. dispose(): void;
  77173. }
  77174. }
  77175. declare module BABYLON.GUI {
  77176. /**
  77177. * Class used to create 2D images
  77178. */
  77179. export class Image extends Control {
  77180. name?: string | undefined;
  77181. private _workingCanvas;
  77182. private _domImage;
  77183. private _imageWidth;
  77184. private _imageHeight;
  77185. private _loaded;
  77186. private _stretch;
  77187. private _source;
  77188. private _autoScale;
  77189. private _sourceLeft;
  77190. private _sourceTop;
  77191. private _sourceWidth;
  77192. private _sourceHeight;
  77193. private _svgAttributesComputationCompleted;
  77194. private _isSVG;
  77195. private _cellWidth;
  77196. private _cellHeight;
  77197. private _cellId;
  77198. private _populateNinePatchSlicesFromImage;
  77199. private _sliceLeft;
  77200. private _sliceRight;
  77201. private _sliceTop;
  77202. private _sliceBottom;
  77203. private _detectPointerOnOpaqueOnly;
  77204. private _imageDataCache;
  77205. /**
  77206. * BABYLON.Observable notified when the content is loaded
  77207. */
  77208. onImageLoadedObservable: BABYLON.Observable<Image>;
  77209. /**
  77210. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  77211. */
  77212. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  77213. /**
  77214. * Gets a boolean indicating that the content is loaded
  77215. */
  77216. get isLoaded(): boolean;
  77217. /**
  77218. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  77219. */
  77220. get populateNinePatchSlicesFromImage(): boolean;
  77221. set populateNinePatchSlicesFromImage(value: boolean);
  77222. /**
  77223. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  77224. * Beware using this as this will comsume more memory as the image has to be stored twice
  77225. */
  77226. get detectPointerOnOpaqueOnly(): boolean;
  77227. set detectPointerOnOpaqueOnly(value: boolean);
  77228. /**
  77229. * Gets or sets the left value for slicing (9-patch)
  77230. */
  77231. get sliceLeft(): number;
  77232. set sliceLeft(value: number);
  77233. /**
  77234. * Gets or sets the right value for slicing (9-patch)
  77235. */
  77236. get sliceRight(): number;
  77237. set sliceRight(value: number);
  77238. /**
  77239. * Gets or sets the top value for slicing (9-patch)
  77240. */
  77241. get sliceTop(): number;
  77242. set sliceTop(value: number);
  77243. /**
  77244. * Gets or sets the bottom value for slicing (9-patch)
  77245. */
  77246. get sliceBottom(): number;
  77247. set sliceBottom(value: number);
  77248. /**
  77249. * Gets or sets the left coordinate in the source image
  77250. */
  77251. get sourceLeft(): number;
  77252. set sourceLeft(value: number);
  77253. /**
  77254. * Gets or sets the top coordinate in the source image
  77255. */
  77256. get sourceTop(): number;
  77257. set sourceTop(value: number);
  77258. /**
  77259. * Gets or sets the width to capture in the source image
  77260. */
  77261. get sourceWidth(): number;
  77262. set sourceWidth(value: number);
  77263. /**
  77264. * Gets or sets the height to capture in the source image
  77265. */
  77266. get sourceHeight(): number;
  77267. set sourceHeight(value: number);
  77268. /** Indicates if the format of the image is SVG */
  77269. get isSVG(): boolean;
  77270. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  77271. get svgAttributesComputationCompleted(): boolean;
  77272. /**
  77273. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  77274. * @see https://doc.babylonjs.com/how_to/gui#image
  77275. */
  77276. get autoScale(): boolean;
  77277. set autoScale(value: boolean);
  77278. /** Gets or sets the streching mode used by the image */
  77279. get stretch(): number;
  77280. set stretch(value: number);
  77281. /** @hidden */
  77282. _rotate90(n: number, preserveProperties?: boolean): Image;
  77283. private _handleRotationForSVGImage;
  77284. private _rotate90SourceProperties;
  77285. /**
  77286. * Gets or sets the internal DOM image used to render the control
  77287. */
  77288. set domImage(value: HTMLImageElement);
  77289. get domImage(): HTMLImageElement;
  77290. private _onImageLoaded;
  77291. private _extractNinePatchSliceDataFromImage;
  77292. /**
  77293. * Gets or sets image source url
  77294. */
  77295. set source(value: BABYLON.Nullable<string>);
  77296. /**
  77297. * Checks for svg document with icon id present
  77298. */
  77299. private _svgCheck;
  77300. /**
  77301. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  77302. * given external svg file and icon id
  77303. */
  77304. private _getSVGAttribs;
  77305. /**
  77306. * Gets or sets the cell width to use when animation sheet is enabled
  77307. * @see https://doc.babylonjs.com/how_to/gui#image
  77308. */
  77309. get cellWidth(): number;
  77310. set cellWidth(value: number);
  77311. /**
  77312. * Gets or sets the cell height to use when animation sheet is enabled
  77313. * @see https://doc.babylonjs.com/how_to/gui#image
  77314. */
  77315. get cellHeight(): number;
  77316. set cellHeight(value: number);
  77317. /**
  77318. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  77319. * @see https://doc.babylonjs.com/how_to/gui#image
  77320. */
  77321. get cellId(): number;
  77322. set cellId(value: number);
  77323. /**
  77324. * Creates a new Image
  77325. * @param name defines the control name
  77326. * @param url defines the image url
  77327. */
  77328. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  77329. /**
  77330. * Tests if a given coordinates belong to the current control
  77331. * @param x defines x coordinate to test
  77332. * @param y defines y coordinate to test
  77333. * @returns true if the coordinates are inside the control
  77334. */
  77335. contains(x: number, y: number): boolean;
  77336. protected _getTypeName(): string;
  77337. /** Force the control to synchronize with its content */
  77338. synchronizeSizeWithContent(): void;
  77339. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77340. private _prepareWorkingCanvasForOpaqueDetection;
  77341. private _drawImage;
  77342. _draw(context: CanvasRenderingContext2D): void;
  77343. private _renderCornerPatch;
  77344. private _renderNinePatch;
  77345. dispose(): void;
  77346. /** STRETCH_NONE */
  77347. static readonly STRETCH_NONE: number;
  77348. /** STRETCH_FILL */
  77349. static readonly STRETCH_FILL: number;
  77350. /** STRETCH_UNIFORM */
  77351. static readonly STRETCH_UNIFORM: number;
  77352. /** STRETCH_EXTEND */
  77353. static readonly STRETCH_EXTEND: number;
  77354. /** NINE_PATCH */
  77355. static readonly STRETCH_NINE_PATCH: number;
  77356. }
  77357. }
  77358. declare module BABYLON.GUI {
  77359. /**
  77360. * Class used to create 2D buttons
  77361. */
  77362. export class Button extends Rectangle {
  77363. name?: string | undefined;
  77364. /**
  77365. * Function called to generate a pointer enter animation
  77366. */
  77367. pointerEnterAnimation: () => void;
  77368. /**
  77369. * Function called to generate a pointer out animation
  77370. */
  77371. pointerOutAnimation: () => void;
  77372. /**
  77373. * Function called to generate a pointer down animation
  77374. */
  77375. pointerDownAnimation: () => void;
  77376. /**
  77377. * Function called to generate a pointer up animation
  77378. */
  77379. pointerUpAnimation: () => void;
  77380. /**
  77381. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  77382. */
  77383. delegatePickingToChildren: boolean;
  77384. private _image;
  77385. /**
  77386. * Returns the image part of the button (if any)
  77387. */
  77388. get image(): BABYLON.Nullable<Image>;
  77389. private _textBlock;
  77390. /**
  77391. * Returns the image part of the button (if any)
  77392. */
  77393. get textBlock(): BABYLON.Nullable<TextBlock>;
  77394. /**
  77395. * Creates a new Button
  77396. * @param name defines the name of the button
  77397. */
  77398. constructor(name?: string | undefined);
  77399. protected _getTypeName(): string;
  77400. /** @hidden */
  77401. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77402. /** @hidden */
  77403. _onPointerEnter(target: Control): boolean;
  77404. /** @hidden */
  77405. _onPointerOut(target: Control, force?: boolean): void;
  77406. /** @hidden */
  77407. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77408. /** @hidden */
  77409. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77410. /**
  77411. * Creates a new button made with an image and a text
  77412. * @param name defines the name of the button
  77413. * @param text defines the text of the button
  77414. * @param imageUrl defines the url of the image
  77415. * @returns a new Button
  77416. */
  77417. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  77418. /**
  77419. * Creates a new button made with an image
  77420. * @param name defines the name of the button
  77421. * @param imageUrl defines the url of the image
  77422. * @returns a new Button
  77423. */
  77424. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  77425. /**
  77426. * Creates a new button made with a text
  77427. * @param name defines the name of the button
  77428. * @param text defines the text of the button
  77429. * @returns a new Button
  77430. */
  77431. static CreateSimpleButton(name: string, text: string): Button;
  77432. /**
  77433. * Creates a new button made with an image and a centered text
  77434. * @param name defines the name of the button
  77435. * @param text defines the text of the button
  77436. * @param imageUrl defines the url of the image
  77437. * @returns a new Button
  77438. */
  77439. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  77440. }
  77441. }
  77442. declare module BABYLON.GUI {
  77443. /**
  77444. * Class used to create a 2D stack panel container
  77445. */
  77446. export class StackPanel extends Container {
  77447. name?: string | undefined;
  77448. private _isVertical;
  77449. private _manualWidth;
  77450. private _manualHeight;
  77451. private _doNotTrackManualChanges;
  77452. /**
  77453. * Gets or sets a boolean indicating that layou warnings should be ignored
  77454. */
  77455. ignoreLayoutWarnings: boolean;
  77456. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  77457. get isVertical(): boolean;
  77458. set isVertical(value: boolean);
  77459. /**
  77460. * Gets or sets panel width.
  77461. * This value should not be set when in horizontal mode as it will be computed automatically
  77462. */
  77463. set width(value: string | number);
  77464. get width(): string | number;
  77465. /**
  77466. * Gets or sets panel height.
  77467. * This value should not be set when in vertical mode as it will be computed automatically
  77468. */
  77469. set height(value: string | number);
  77470. get height(): string | number;
  77471. /**
  77472. * Creates a new StackPanel
  77473. * @param name defines control name
  77474. */
  77475. constructor(name?: string | undefined);
  77476. protected _getTypeName(): string;
  77477. /** @hidden */
  77478. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77479. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77480. protected _postMeasure(): void;
  77481. }
  77482. }
  77483. declare module BABYLON.GUI {
  77484. /**
  77485. * Class used to represent a 2D checkbox
  77486. */
  77487. export class Checkbox extends Control {
  77488. name?: string | undefined;
  77489. private _isChecked;
  77490. private _background;
  77491. private _checkSizeRatio;
  77492. private _thickness;
  77493. /** Gets or sets border thickness */
  77494. get thickness(): number;
  77495. set thickness(value: number);
  77496. /**
  77497. * BABYLON.Observable raised when isChecked property changes
  77498. */
  77499. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  77500. /** Gets or sets a value indicating the ratio between overall size and check size */
  77501. get checkSizeRatio(): number;
  77502. set checkSizeRatio(value: number);
  77503. /** Gets or sets background color */
  77504. get background(): string;
  77505. set background(value: string);
  77506. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  77507. get isChecked(): boolean;
  77508. set isChecked(value: boolean);
  77509. /**
  77510. * Creates a new CheckBox
  77511. * @param name defines the control name
  77512. */
  77513. constructor(name?: string | undefined);
  77514. protected _getTypeName(): string;
  77515. /** @hidden */
  77516. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77517. /** @hidden */
  77518. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77519. /**
  77520. * Utility function to easily create a checkbox with a header
  77521. * @param title defines the label to use for the header
  77522. * @param onValueChanged defines the callback to call when value changes
  77523. * @returns a StackPanel containing the checkbox and a textBlock
  77524. */
  77525. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  77526. }
  77527. }
  77528. declare module BABYLON.GUI {
  77529. /**
  77530. * Class used to store key control properties
  77531. */
  77532. export class KeyPropertySet {
  77533. /** Width */
  77534. width?: string;
  77535. /** Height */
  77536. height?: string;
  77537. /** Left padding */
  77538. paddingLeft?: string;
  77539. /** Right padding */
  77540. paddingRight?: string;
  77541. /** Top padding */
  77542. paddingTop?: string;
  77543. /** Bottom padding */
  77544. paddingBottom?: string;
  77545. /** Foreground color */
  77546. color?: string;
  77547. /** Background color */
  77548. background?: string;
  77549. }
  77550. /**
  77551. * Class used to create virtual keyboard
  77552. */
  77553. export class VirtualKeyboard extends StackPanel {
  77554. /** BABYLON.Observable raised when a key is pressed */
  77555. onKeyPressObservable: BABYLON.Observable<string>;
  77556. /** Gets or sets default key button width */
  77557. defaultButtonWidth: string;
  77558. /** Gets or sets default key button height */
  77559. defaultButtonHeight: string;
  77560. /** Gets or sets default key button left padding */
  77561. defaultButtonPaddingLeft: string;
  77562. /** Gets or sets default key button right padding */
  77563. defaultButtonPaddingRight: string;
  77564. /** Gets or sets default key button top padding */
  77565. defaultButtonPaddingTop: string;
  77566. /** Gets or sets default key button bottom padding */
  77567. defaultButtonPaddingBottom: string;
  77568. /** Gets or sets default key button foreground color */
  77569. defaultButtonColor: string;
  77570. /** Gets or sets default key button background color */
  77571. defaultButtonBackground: string;
  77572. /** Gets or sets shift button foreground color */
  77573. shiftButtonColor: string;
  77574. /** Gets or sets shift button thickness*/
  77575. selectedShiftThickness: number;
  77576. /** Gets shift key state */
  77577. shiftState: number;
  77578. protected _getTypeName(): string;
  77579. private _createKey;
  77580. /**
  77581. * Adds a new row of keys
  77582. * @param keys defines the list of keys to add
  77583. * @param propertySets defines the associated property sets
  77584. */
  77585. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  77586. /**
  77587. * Set the shift key to a specific state
  77588. * @param shiftState defines the new shift state
  77589. */
  77590. applyShiftState(shiftState: number): void;
  77591. private _currentlyConnectedInputText;
  77592. private _connectedInputTexts;
  77593. private _onKeyPressObserver;
  77594. /** Gets the input text control currently attached to the keyboard */
  77595. get connectedInputText(): BABYLON.Nullable<InputText>;
  77596. /**
  77597. * Connects the keyboard with an input text control
  77598. *
  77599. * @param input defines the target control
  77600. */
  77601. connect(input: InputText): void;
  77602. /**
  77603. * Disconnects the keyboard from connected InputText controls
  77604. *
  77605. * @param input optionally defines a target control, otherwise all are disconnected
  77606. */
  77607. disconnect(input?: InputText): void;
  77608. private _removeConnectedInputObservables;
  77609. /**
  77610. * Release all resources
  77611. */
  77612. dispose(): void;
  77613. /**
  77614. * Creates a new keyboard using a default layout
  77615. *
  77616. * @param name defines control name
  77617. * @returns a new VirtualKeyboard
  77618. */
  77619. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  77620. }
  77621. }
  77622. declare module BABYLON.GUI {
  77623. /**
  77624. * Class used to create input text control
  77625. */
  77626. export class InputText extends Control implements IFocusableControl {
  77627. name?: string | undefined;
  77628. private _text;
  77629. private _placeholderText;
  77630. private _background;
  77631. private _focusedBackground;
  77632. private _focusedColor;
  77633. private _placeholderColor;
  77634. private _thickness;
  77635. private _margin;
  77636. private _autoStretchWidth;
  77637. private _maxWidth;
  77638. private _isFocused;
  77639. private _blinkTimeout;
  77640. private _blinkIsEven;
  77641. private _cursorOffset;
  77642. private _scrollLeft;
  77643. private _textWidth;
  77644. private _clickedCoordinate;
  77645. private _deadKey;
  77646. private _addKey;
  77647. private _currentKey;
  77648. private _isTextHighlightOn;
  77649. private _textHighlightColor;
  77650. private _highligherOpacity;
  77651. private _highlightedText;
  77652. private _startHighlightIndex;
  77653. private _endHighlightIndex;
  77654. private _cursorIndex;
  77655. private _onFocusSelectAll;
  77656. private _isPointerDown;
  77657. private _onClipboardObserver;
  77658. private _onPointerDblTapObserver;
  77659. /** @hidden */
  77660. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  77661. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  77662. promptMessage: string;
  77663. /** Force disable prompt on mobile device */
  77664. disableMobilePrompt: boolean;
  77665. /** BABYLON.Observable raised when the text changes */
  77666. onTextChangedObservable: BABYLON.Observable<InputText>;
  77667. /** BABYLON.Observable raised just before an entered character is to be added */
  77668. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  77669. /** BABYLON.Observable raised when the control gets the focus */
  77670. onFocusObservable: BABYLON.Observable<InputText>;
  77671. /** BABYLON.Observable raised when the control loses the focus */
  77672. onBlurObservable: BABYLON.Observable<InputText>;
  77673. /**Observable raised when the text is highlighted */
  77674. onTextHighlightObservable: BABYLON.Observable<InputText>;
  77675. /**Observable raised when copy event is triggered */
  77676. onTextCopyObservable: BABYLON.Observable<InputText>;
  77677. /** BABYLON.Observable raised when cut event is triggered */
  77678. onTextCutObservable: BABYLON.Observable<InputText>;
  77679. /** BABYLON.Observable raised when paste event is triggered */
  77680. onTextPasteObservable: BABYLON.Observable<InputText>;
  77681. /** BABYLON.Observable raised when a key event was processed */
  77682. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  77683. /** Gets or sets the maximum width allowed by the control */
  77684. get maxWidth(): string | number;
  77685. /** Gets the maximum width allowed by the control in pixels */
  77686. get maxWidthInPixels(): number;
  77687. set maxWidth(value: string | number);
  77688. /** Gets or sets the text highlighter transparency; default: 0.4 */
  77689. get highligherOpacity(): number;
  77690. set highligherOpacity(value: number);
  77691. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  77692. get onFocusSelectAll(): boolean;
  77693. set onFocusSelectAll(value: boolean);
  77694. /** Gets or sets the text hightlight color */
  77695. get textHighlightColor(): string;
  77696. set textHighlightColor(value: string);
  77697. /** Gets or sets control margin */
  77698. get margin(): string;
  77699. /** Gets control margin in pixels */
  77700. get marginInPixels(): number;
  77701. set margin(value: string);
  77702. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  77703. get autoStretchWidth(): boolean;
  77704. set autoStretchWidth(value: boolean);
  77705. /** Gets or sets border thickness */
  77706. get thickness(): number;
  77707. set thickness(value: number);
  77708. /** Gets or sets the background color when focused */
  77709. get focusedBackground(): string;
  77710. set focusedBackground(value: string);
  77711. /** Gets or sets the background color when focused */
  77712. get focusedColor(): string;
  77713. set focusedColor(value: string);
  77714. /** Gets or sets the background color */
  77715. get background(): string;
  77716. set background(value: string);
  77717. /** Gets or sets the placeholder color */
  77718. get placeholderColor(): string;
  77719. set placeholderColor(value: string);
  77720. /** Gets or sets the text displayed when the control is empty */
  77721. get placeholderText(): string;
  77722. set placeholderText(value: string);
  77723. /** Gets or sets the dead key flag */
  77724. get deadKey(): boolean;
  77725. set deadKey(flag: boolean);
  77726. /** Gets or sets the highlight text */
  77727. get highlightedText(): string;
  77728. set highlightedText(text: string);
  77729. /** Gets or sets if the current key should be added */
  77730. get addKey(): boolean;
  77731. set addKey(flag: boolean);
  77732. /** Gets or sets the value of the current key being entered */
  77733. get currentKey(): string;
  77734. set currentKey(key: string);
  77735. /** Gets or sets the text displayed in the control */
  77736. get text(): string;
  77737. set text(value: string);
  77738. /** Gets or sets control width */
  77739. get width(): string | number;
  77740. set width(value: string | number);
  77741. /**
  77742. * Creates a new InputText
  77743. * @param name defines the control name
  77744. * @param text defines the text of the control
  77745. */
  77746. constructor(name?: string | undefined, text?: string);
  77747. /** @hidden */
  77748. onBlur(): void;
  77749. /** @hidden */
  77750. onFocus(): void;
  77751. protected _getTypeName(): string;
  77752. /**
  77753. * Function called to get the list of controls that should not steal the focus from this control
  77754. * @returns an array of controls
  77755. */
  77756. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  77757. /** @hidden */
  77758. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  77759. /** @hidden */
  77760. private _updateValueFromCursorIndex;
  77761. /** @hidden */
  77762. private _processDblClick;
  77763. /** @hidden */
  77764. private _selectAllText;
  77765. /**
  77766. * Handles the keyboard event
  77767. * @param evt Defines the KeyboardEvent
  77768. */
  77769. processKeyboard(evt: KeyboardEvent): void;
  77770. /** @hidden */
  77771. private _onCopyText;
  77772. /** @hidden */
  77773. private _onCutText;
  77774. /** @hidden */
  77775. private _onPasteText;
  77776. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77777. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77778. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77779. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77780. protected _beforeRenderText(text: string): string;
  77781. dispose(): void;
  77782. }
  77783. }
  77784. declare module BABYLON.GUI {
  77785. /**
  77786. * Class used to create a 2D grid container
  77787. */
  77788. export class Grid extends Container {
  77789. name?: string | undefined;
  77790. private _rowDefinitions;
  77791. private _columnDefinitions;
  77792. private _cells;
  77793. private _childControls;
  77794. /**
  77795. * Gets the number of columns
  77796. */
  77797. get columnCount(): number;
  77798. /**
  77799. * Gets the number of rows
  77800. */
  77801. get rowCount(): number;
  77802. /** Gets the list of children */
  77803. get children(): Control[];
  77804. /** Gets the list of cells (e.g. the containers) */
  77805. get cells(): {
  77806. [key: string]: Container;
  77807. };
  77808. /**
  77809. * Gets the definition of a specific row
  77810. * @param index defines the index of the row
  77811. * @returns the row definition
  77812. */
  77813. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  77814. /**
  77815. * Gets the definition of a specific column
  77816. * @param index defines the index of the column
  77817. * @returns the column definition
  77818. */
  77819. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  77820. /**
  77821. * Adds a new row to the grid
  77822. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  77823. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  77824. * @returns the current grid
  77825. */
  77826. addRowDefinition(height: number, isPixel?: boolean): Grid;
  77827. /**
  77828. * Adds a new column to the grid
  77829. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  77830. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  77831. * @returns the current grid
  77832. */
  77833. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  77834. /**
  77835. * Update a row definition
  77836. * @param index defines the index of the row to update
  77837. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  77838. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  77839. * @returns the current grid
  77840. */
  77841. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  77842. /**
  77843. * Update a column definition
  77844. * @param index defines the index of the column to update
  77845. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  77846. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  77847. * @returns the current grid
  77848. */
  77849. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  77850. /**
  77851. * Gets the list of children stored in a specific cell
  77852. * @param row defines the row to check
  77853. * @param column defines the column to check
  77854. * @returns the list of controls
  77855. */
  77856. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  77857. /**
  77858. * Gets a string representing the child cell info (row x column)
  77859. * @param child defines the control to get info from
  77860. * @returns a string containing the child cell info (row x column)
  77861. */
  77862. getChildCellInfo(child: Control): string;
  77863. private _removeCell;
  77864. private _offsetCell;
  77865. /**
  77866. * Remove a column definition at specified index
  77867. * @param index defines the index of the column to remove
  77868. * @returns the current grid
  77869. */
  77870. removeColumnDefinition(index: number): Grid;
  77871. /**
  77872. * Remove a row definition at specified index
  77873. * @param index defines the index of the row to remove
  77874. * @returns the current grid
  77875. */
  77876. removeRowDefinition(index: number): Grid;
  77877. /**
  77878. * Adds a new control to the current grid
  77879. * @param control defines the control to add
  77880. * @param row defines the row where to add the control (0 by default)
  77881. * @param column defines the column where to add the control (0 by default)
  77882. * @returns the current grid
  77883. */
  77884. addControl(control: Control, row?: number, column?: number): Grid;
  77885. /**
  77886. * Removes a control from the current container
  77887. * @param control defines the control to remove
  77888. * @returns the current container
  77889. */
  77890. removeControl(control: Control): Container;
  77891. /**
  77892. * Creates a new Grid
  77893. * @param name defines control name
  77894. */
  77895. constructor(name?: string | undefined);
  77896. protected _getTypeName(): string;
  77897. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  77898. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77899. _flagDescendantsAsMatrixDirty(): void;
  77900. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77901. /** Releases associated resources */
  77902. dispose(): void;
  77903. }
  77904. }
  77905. declare module BABYLON.GUI {
  77906. /** Class used to create color pickers */
  77907. export class ColorPicker extends Control {
  77908. name?: string | undefined;
  77909. private static _Epsilon;
  77910. private _colorWheelCanvas;
  77911. private _value;
  77912. private _tmpColor;
  77913. private _pointerStartedOnSquare;
  77914. private _pointerStartedOnWheel;
  77915. private _squareLeft;
  77916. private _squareTop;
  77917. private _squareSize;
  77918. private _h;
  77919. private _s;
  77920. private _v;
  77921. private _lastPointerDownID;
  77922. /**
  77923. * BABYLON.Observable raised when the value changes
  77924. */
  77925. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  77926. /** Gets or sets the color of the color picker */
  77927. get value(): BABYLON.Color3;
  77928. set value(value: BABYLON.Color3);
  77929. /**
  77930. * Gets or sets control width
  77931. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77932. */
  77933. get width(): string | number;
  77934. set width(value: string | number);
  77935. /**
  77936. * Gets or sets control height
  77937. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77938. */
  77939. get height(): string | number;
  77940. /** Gets or sets control height */
  77941. set height(value: string | number);
  77942. /** Gets or sets control size */
  77943. get size(): string | number;
  77944. set size(value: string | number);
  77945. /**
  77946. * Creates a new ColorPicker
  77947. * @param name defines the control name
  77948. */
  77949. constructor(name?: string | undefined);
  77950. protected _getTypeName(): string;
  77951. /** @hidden */
  77952. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77953. private _updateSquareProps;
  77954. private _drawGradientSquare;
  77955. private _drawCircle;
  77956. private _createColorWheelCanvas;
  77957. /** @hidden */
  77958. _draw(context: CanvasRenderingContext2D): void;
  77959. private _pointerIsDown;
  77960. private _updateValueFromPointer;
  77961. private _isPointOnSquare;
  77962. private _isPointOnWheel;
  77963. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77964. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77965. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77966. _onCanvasBlur(): void;
  77967. /**
  77968. * This function expands the color picker by creating a color picker dialog with manual
  77969. * color value input and the ability to save colors into an array to be used later in
  77970. * subsequent launches of the dialogue.
  77971. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  77972. * @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.
  77973. * @returns picked color as a hex string and the saved colors array as hex strings.
  77974. */
  77975. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  77976. pickerWidth?: string;
  77977. pickerHeight?: string;
  77978. headerHeight?: string;
  77979. lastColor?: string;
  77980. swatchLimit?: number;
  77981. numSwatchesPerLine?: number;
  77982. savedColors?: Array<string>;
  77983. }): Promise<{
  77984. savedColors?: string[];
  77985. pickedColor: string;
  77986. }>;
  77987. }
  77988. }
  77989. declare module BABYLON.GUI {
  77990. /** Class used to create 2D ellipse containers */
  77991. export class Ellipse extends Container {
  77992. name?: string | undefined;
  77993. private _thickness;
  77994. /** Gets or sets border thickness */
  77995. get thickness(): number;
  77996. set thickness(value: number);
  77997. /**
  77998. * Creates a new Ellipse
  77999. * @param name defines the control name
  78000. */
  78001. constructor(name?: string | undefined);
  78002. protected _getTypeName(): string;
  78003. protected _localDraw(context: CanvasRenderingContext2D): void;
  78004. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78005. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78006. }
  78007. }
  78008. declare module BABYLON.GUI {
  78009. /**
  78010. * Class used to create a password control
  78011. */
  78012. export class InputPassword extends InputText {
  78013. protected _beforeRenderText(text: string): string;
  78014. }
  78015. }
  78016. declare module BABYLON.GUI {
  78017. /** Class used to render 2D lines */
  78018. export class Line extends Control {
  78019. name?: string | undefined;
  78020. private _lineWidth;
  78021. private _x1;
  78022. private _y1;
  78023. private _x2;
  78024. private _y2;
  78025. private _dash;
  78026. private _connectedControl;
  78027. private _connectedControlDirtyObserver;
  78028. /** Gets or sets the dash pattern */
  78029. get dash(): Array<number>;
  78030. set dash(value: Array<number>);
  78031. /** Gets or sets the control connected with the line end */
  78032. get connectedControl(): Control;
  78033. set connectedControl(value: Control);
  78034. /** Gets or sets start coordinates on X axis */
  78035. get x1(): string | number;
  78036. set x1(value: string | number);
  78037. /** Gets or sets start coordinates on Y axis */
  78038. get y1(): string | number;
  78039. set y1(value: string | number);
  78040. /** Gets or sets end coordinates on X axis */
  78041. get x2(): string | number;
  78042. set x2(value: string | number);
  78043. /** Gets or sets end coordinates on Y axis */
  78044. get y2(): string | number;
  78045. set y2(value: string | number);
  78046. /** Gets or sets line width */
  78047. get lineWidth(): number;
  78048. set lineWidth(value: number);
  78049. /** Gets or sets horizontal alignment */
  78050. set horizontalAlignment(value: number);
  78051. /** Gets or sets vertical alignment */
  78052. set verticalAlignment(value: number);
  78053. private get _effectiveX2();
  78054. private get _effectiveY2();
  78055. /**
  78056. * Creates a new Line
  78057. * @param name defines the control name
  78058. */
  78059. constructor(name?: string | undefined);
  78060. protected _getTypeName(): string;
  78061. _draw(context: CanvasRenderingContext2D): void;
  78062. _measure(): void;
  78063. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78064. /**
  78065. * Move one end of the line given 3D cartesian coordinates.
  78066. * @param position Targeted world position
  78067. * @param scene BABYLON.Scene
  78068. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  78069. */
  78070. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  78071. /**
  78072. * Move one end of the line to a position in screen absolute space.
  78073. * @param projectedPosition Position in screen absolute space (X, Y)
  78074. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  78075. */
  78076. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  78077. }
  78078. }
  78079. declare module BABYLON.GUI {
  78080. /**
  78081. * Class used to store a point for a MultiLine object.
  78082. * The point can be pure 2D coordinates, a mesh or a control
  78083. */
  78084. export class MultiLinePoint {
  78085. private _multiLine;
  78086. private _x;
  78087. private _y;
  78088. private _control;
  78089. private _mesh;
  78090. private _controlObserver;
  78091. private _meshObserver;
  78092. /** @hidden */
  78093. _point: BABYLON.Vector2;
  78094. /**
  78095. * Creates a new MultiLinePoint
  78096. * @param multiLine defines the source MultiLine object
  78097. */
  78098. constructor(multiLine: MultiLine);
  78099. /** Gets or sets x coordinate */
  78100. get x(): string | number;
  78101. set x(value: string | number);
  78102. /** Gets or sets y coordinate */
  78103. get y(): string | number;
  78104. set y(value: string | number);
  78105. /** Gets or sets the control associated with this point */
  78106. get control(): BABYLON.Nullable<Control>;
  78107. set control(value: BABYLON.Nullable<Control>);
  78108. /** Gets or sets the mesh associated with this point */
  78109. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  78110. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  78111. /** Resets links */
  78112. resetLinks(): void;
  78113. /**
  78114. * Gets a translation vector
  78115. * @returns the translation vector
  78116. */
  78117. translate(): BABYLON.Vector2;
  78118. private _translatePoint;
  78119. /** Release associated resources */
  78120. dispose(): void;
  78121. }
  78122. }
  78123. declare module BABYLON.GUI {
  78124. /**
  78125. * Class used to create multi line control
  78126. */
  78127. export class MultiLine extends Control {
  78128. name?: string | undefined;
  78129. private _lineWidth;
  78130. private _dash;
  78131. private _points;
  78132. private _minX;
  78133. private _minY;
  78134. private _maxX;
  78135. private _maxY;
  78136. /**
  78137. * Creates a new MultiLine
  78138. * @param name defines the control name
  78139. */
  78140. constructor(name?: string | undefined);
  78141. /** Gets or sets dash pattern */
  78142. get dash(): Array<number>;
  78143. set dash(value: Array<number>);
  78144. /**
  78145. * Gets point stored at specified index
  78146. * @param index defines the index to look for
  78147. * @returns the requested point if found
  78148. */
  78149. getAt(index: number): MultiLinePoint;
  78150. /** Function called when a point is updated */
  78151. onPointUpdate: () => void;
  78152. /**
  78153. * Adds new points to the point collection
  78154. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  78155. * @returns the list of created MultiLinePoint
  78156. */
  78157. add(...items: (AbstractMesh | Control | {
  78158. x: string | number;
  78159. y: string | number;
  78160. })[]): MultiLinePoint[];
  78161. /**
  78162. * Adds a new point to the point collection
  78163. * @param item defines the item (mesh, control or 2d coordiantes) to add
  78164. * @returns the created MultiLinePoint
  78165. */
  78166. push(item?: (AbstractMesh | Control | {
  78167. x: string | number;
  78168. y: string | number;
  78169. })): MultiLinePoint;
  78170. /**
  78171. * Remove a specific value or point from the active point collection
  78172. * @param value defines the value or point to remove
  78173. */
  78174. remove(value: number | MultiLinePoint): void;
  78175. /**
  78176. * Resets this object to initial state (no point)
  78177. */
  78178. reset(): void;
  78179. /**
  78180. * Resets all links
  78181. */
  78182. resetLinks(): void;
  78183. /** Gets or sets line width */
  78184. get lineWidth(): number;
  78185. set lineWidth(value: number);
  78186. set horizontalAlignment(value: number);
  78187. set verticalAlignment(value: number);
  78188. protected _getTypeName(): string;
  78189. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78190. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78191. _measure(): void;
  78192. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78193. dispose(): void;
  78194. }
  78195. }
  78196. declare module BABYLON.GUI {
  78197. /**
  78198. * Class used to create radio button controls
  78199. */
  78200. export class RadioButton extends Control {
  78201. name?: string | undefined;
  78202. private _isChecked;
  78203. private _background;
  78204. private _checkSizeRatio;
  78205. private _thickness;
  78206. /** Gets or sets border thickness */
  78207. get thickness(): number;
  78208. set thickness(value: number);
  78209. /** Gets or sets group name */
  78210. group: string;
  78211. /** BABYLON.Observable raised when isChecked is changed */
  78212. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  78213. /** Gets or sets a value indicating the ratio between overall size and check size */
  78214. get checkSizeRatio(): number;
  78215. set checkSizeRatio(value: number);
  78216. /** Gets or sets background color */
  78217. get background(): string;
  78218. set background(value: string);
  78219. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  78220. get isChecked(): boolean;
  78221. set isChecked(value: boolean);
  78222. /**
  78223. * Creates a new RadioButton
  78224. * @param name defines the control name
  78225. */
  78226. constructor(name?: string | undefined);
  78227. protected _getTypeName(): string;
  78228. _draw(context: CanvasRenderingContext2D): void;
  78229. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78230. /**
  78231. * Utility function to easily create a radio button with a header
  78232. * @param title defines the label to use for the header
  78233. * @param group defines the group to use for the radio button
  78234. * @param isChecked defines the initial state of the radio button
  78235. * @param onValueChanged defines the callback to call when value changes
  78236. * @returns a StackPanel containing the radio button and a textBlock
  78237. */
  78238. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  78239. }
  78240. }
  78241. declare module BABYLON.GUI {
  78242. /**
  78243. * Class used to create slider controls
  78244. */
  78245. export class BaseSlider extends Control {
  78246. name?: string | undefined;
  78247. protected _thumbWidth: ValueAndUnit;
  78248. private _minimum;
  78249. private _maximum;
  78250. private _value;
  78251. private _isVertical;
  78252. protected _barOffset: ValueAndUnit;
  78253. private _isThumbClamped;
  78254. protected _displayThumb: boolean;
  78255. private _step;
  78256. private _lastPointerDownID;
  78257. protected _effectiveBarOffset: number;
  78258. protected _renderLeft: number;
  78259. protected _renderTop: number;
  78260. protected _renderWidth: number;
  78261. protected _renderHeight: number;
  78262. protected _backgroundBoxLength: number;
  78263. protected _backgroundBoxThickness: number;
  78264. protected _effectiveThumbThickness: number;
  78265. /** BABYLON.Observable raised when the sldier value changes */
  78266. onValueChangedObservable: BABYLON.Observable<number>;
  78267. /** Gets or sets a boolean indicating if the thumb must be rendered */
  78268. get displayThumb(): boolean;
  78269. set displayThumb(value: boolean);
  78270. /** Gets or sets a step to apply to values (0 by default) */
  78271. get step(): number;
  78272. set step(value: number);
  78273. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  78274. get barOffset(): string | number;
  78275. /** Gets main bar offset in pixels*/
  78276. get barOffsetInPixels(): number;
  78277. set barOffset(value: string | number);
  78278. /** Gets or sets thumb width */
  78279. get thumbWidth(): string | number;
  78280. /** Gets thumb width in pixels */
  78281. get thumbWidthInPixels(): number;
  78282. set thumbWidth(value: string | number);
  78283. /** Gets or sets minimum value */
  78284. get minimum(): number;
  78285. set minimum(value: number);
  78286. /** Gets or sets maximum value */
  78287. get maximum(): number;
  78288. set maximum(value: number);
  78289. /** Gets or sets current value */
  78290. get value(): number;
  78291. set value(value: number);
  78292. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  78293. get isVertical(): boolean;
  78294. set isVertical(value: boolean);
  78295. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  78296. get isThumbClamped(): boolean;
  78297. set isThumbClamped(value: boolean);
  78298. /**
  78299. * Creates a new BaseSlider
  78300. * @param name defines the control name
  78301. */
  78302. constructor(name?: string | undefined);
  78303. protected _getTypeName(): string;
  78304. protected _getThumbPosition(): number;
  78305. protected _getThumbThickness(type: string): number;
  78306. protected _prepareRenderingData(type: string): void;
  78307. private _pointerIsDown;
  78308. /** @hidden */
  78309. protected _updateValueFromPointer(x: number, y: number): void;
  78310. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78311. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78312. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78313. _onCanvasBlur(): void;
  78314. }
  78315. }
  78316. declare module BABYLON.GUI {
  78317. /**
  78318. * Class used to create slider controls
  78319. */
  78320. export class Slider extends BaseSlider {
  78321. name?: string | undefined;
  78322. private _background;
  78323. private _borderColor;
  78324. private _isThumbCircle;
  78325. protected _displayValueBar: boolean;
  78326. /** Gets or sets a boolean indicating if the value bar must be rendered */
  78327. get displayValueBar(): boolean;
  78328. set displayValueBar(value: boolean);
  78329. /** Gets or sets border color */
  78330. get borderColor(): string;
  78331. set borderColor(value: string);
  78332. /** Gets or sets background color */
  78333. get background(): string;
  78334. set background(value: string);
  78335. /** Gets or sets a boolean indicating if the thumb should be round or square */
  78336. get isThumbCircle(): boolean;
  78337. set isThumbCircle(value: boolean);
  78338. /**
  78339. * Creates a new Slider
  78340. * @param name defines the control name
  78341. */
  78342. constructor(name?: string | undefined);
  78343. protected _getTypeName(): string;
  78344. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78345. }
  78346. }
  78347. declare module BABYLON.GUI {
  78348. /** Class used to create a RadioGroup
  78349. * which contains groups of radio buttons
  78350. */
  78351. export class SelectorGroup {
  78352. /** name of SelectorGroup */
  78353. name: string;
  78354. private _groupPanel;
  78355. private _selectors;
  78356. private _groupHeader;
  78357. /**
  78358. * Creates a new SelectorGroup
  78359. * @param name of group, used as a group heading
  78360. */
  78361. constructor(
  78362. /** name of SelectorGroup */
  78363. name: string);
  78364. /** Gets the groupPanel of the SelectorGroup */
  78365. get groupPanel(): StackPanel;
  78366. /** Gets the selectors array */
  78367. get selectors(): StackPanel[];
  78368. /** Gets and sets the group header */
  78369. get header(): string;
  78370. set header(label: string);
  78371. /** @hidden */
  78372. private _addGroupHeader;
  78373. /** @hidden*/
  78374. _getSelector(selectorNb: number): StackPanel | undefined;
  78375. /** Removes the selector at the given position
  78376. * @param selectorNb the position of the selector within the group
  78377. */
  78378. removeSelector(selectorNb: number): void;
  78379. }
  78380. /** Class used to create a CheckboxGroup
  78381. * which contains groups of checkbox buttons
  78382. */
  78383. export class CheckboxGroup extends SelectorGroup {
  78384. /** Adds a checkbox as a control
  78385. * @param text is the label for the selector
  78386. * @param func is the function called when the Selector is checked
  78387. * @param checked is true when Selector is checked
  78388. */
  78389. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  78390. /** @hidden */
  78391. _setSelectorLabel(selectorNb: number, label: string): void;
  78392. /** @hidden */
  78393. _setSelectorLabelColor(selectorNb: number, color: string): void;
  78394. /** @hidden */
  78395. _setSelectorButtonColor(selectorNb: number, color: string): void;
  78396. /** @hidden */
  78397. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  78398. }
  78399. /** Class used to create a RadioGroup
  78400. * which contains groups of radio buttons
  78401. */
  78402. export class RadioGroup extends SelectorGroup {
  78403. private _selectNb;
  78404. /** Adds a radio button as a control
  78405. * @param label is the label for the selector
  78406. * @param func is the function called when the Selector is checked
  78407. * @param checked is true when Selector is checked
  78408. */
  78409. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  78410. /** @hidden */
  78411. _setSelectorLabel(selectorNb: number, label: string): void;
  78412. /** @hidden */
  78413. _setSelectorLabelColor(selectorNb: number, color: string): void;
  78414. /** @hidden */
  78415. _setSelectorButtonColor(selectorNb: number, color: string): void;
  78416. /** @hidden */
  78417. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  78418. }
  78419. /** Class used to create a SliderGroup
  78420. * which contains groups of slider buttons
  78421. */
  78422. export class SliderGroup extends SelectorGroup {
  78423. /**
  78424. * Adds a slider to the SelectorGroup
  78425. * @param label is the label for the SliderBar
  78426. * @param func is the function called when the Slider moves
  78427. * @param unit is a string describing the units used, eg degrees or metres
  78428. * @param min is the minimum value for the Slider
  78429. * @param max is the maximum value for the Slider
  78430. * @param value is the start value for the Slider between min and max
  78431. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  78432. */
  78433. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  78434. /** @hidden */
  78435. _setSelectorLabel(selectorNb: number, label: string): void;
  78436. /** @hidden */
  78437. _setSelectorLabelColor(selectorNb: number, color: string): void;
  78438. /** @hidden */
  78439. _setSelectorButtonColor(selectorNb: number, color: string): void;
  78440. /** @hidden */
  78441. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  78442. }
  78443. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  78444. * @see https://doc.babylonjs.com/how_to/selector
  78445. */
  78446. export class SelectionPanel extends Rectangle {
  78447. /** name of SelectionPanel */
  78448. name: string;
  78449. /** an array of SelectionGroups */
  78450. groups: SelectorGroup[];
  78451. private _panel;
  78452. private _buttonColor;
  78453. private _buttonBackground;
  78454. private _headerColor;
  78455. private _barColor;
  78456. private _barHeight;
  78457. private _spacerHeight;
  78458. private _labelColor;
  78459. private _groups;
  78460. private _bars;
  78461. /**
  78462. * Creates a new SelectionPanel
  78463. * @param name of SelectionPanel
  78464. * @param groups is an array of SelectionGroups
  78465. */
  78466. constructor(
  78467. /** name of SelectionPanel */
  78468. name: string,
  78469. /** an array of SelectionGroups */
  78470. groups?: SelectorGroup[]);
  78471. protected _getTypeName(): string;
  78472. /** Gets or sets the headerColor */
  78473. get headerColor(): string;
  78474. set headerColor(color: string);
  78475. private _setHeaderColor;
  78476. /** Gets or sets the button color */
  78477. get buttonColor(): string;
  78478. set buttonColor(color: string);
  78479. private _setbuttonColor;
  78480. /** Gets or sets the label color */
  78481. get labelColor(): string;
  78482. set labelColor(color: string);
  78483. private _setLabelColor;
  78484. /** Gets or sets the button background */
  78485. get buttonBackground(): string;
  78486. set buttonBackground(color: string);
  78487. private _setButtonBackground;
  78488. /** Gets or sets the color of separator bar */
  78489. get barColor(): string;
  78490. set barColor(color: string);
  78491. private _setBarColor;
  78492. /** Gets or sets the height of separator bar */
  78493. get barHeight(): string;
  78494. set barHeight(value: string);
  78495. private _setBarHeight;
  78496. /** Gets or sets the height of spacers*/
  78497. get spacerHeight(): string;
  78498. set spacerHeight(value: string);
  78499. private _setSpacerHeight;
  78500. /** Adds a bar between groups */
  78501. private _addSpacer;
  78502. /** Add a group to the selection panel
  78503. * @param group is the selector group to add
  78504. */
  78505. addGroup(group: SelectorGroup): void;
  78506. /** Remove the group from the given position
  78507. * @param groupNb is the position of the group in the list
  78508. */
  78509. removeGroup(groupNb: number): void;
  78510. /** Change a group header label
  78511. * @param label is the new group header label
  78512. * @param groupNb is the number of the group to relabel
  78513. * */
  78514. setHeaderName(label: string, groupNb: number): void;
  78515. /** Change selector label to the one given
  78516. * @param label is the new selector label
  78517. * @param groupNb is the number of the groupcontaining the selector
  78518. * @param selectorNb is the number of the selector within a group to relabel
  78519. * */
  78520. relabel(label: string, groupNb: number, selectorNb: number): void;
  78521. /** For a given group position remove the selector at the given position
  78522. * @param groupNb is the number of the group to remove the selector from
  78523. * @param selectorNb is the number of the selector within the group
  78524. */
  78525. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  78526. /** For a given group position of correct type add a checkbox button
  78527. * @param groupNb is the number of the group to remove the selector from
  78528. * @param label is the label for the selector
  78529. * @param func is the function called when the Selector is checked
  78530. * @param checked is true when Selector is checked
  78531. */
  78532. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  78533. /** For a given group position of correct type add a radio button
  78534. * @param groupNb is the number of the group to remove the selector from
  78535. * @param label is the label for the selector
  78536. * @param func is the function called when the Selector is checked
  78537. * @param checked is true when Selector is checked
  78538. */
  78539. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  78540. /**
  78541. * For a given slider group add a slider
  78542. * @param groupNb is the number of the group to add the slider to
  78543. * @param label is the label for the Slider
  78544. * @param func is the function called when the Slider moves
  78545. * @param unit is a string describing the units used, eg degrees or metres
  78546. * @param min is the minimum value for the Slider
  78547. * @param max is the maximum value for the Slider
  78548. * @param value is the start value for the Slider between min and max
  78549. * @param onVal is the function used to format the value displayed, eg radians to degrees
  78550. */
  78551. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  78552. }
  78553. }
  78554. declare module BABYLON.GUI {
  78555. /**
  78556. * Class used to hold a the container for ScrollViewer
  78557. * @hidden
  78558. */
  78559. export class _ScrollViewerWindow extends Container {
  78560. parentClientWidth: number;
  78561. parentClientHeight: number;
  78562. private _freezeControls;
  78563. private _parentMeasure;
  78564. private _oldLeft;
  78565. private _oldTop;
  78566. get freezeControls(): boolean;
  78567. set freezeControls(value: boolean);
  78568. private _bucketWidth;
  78569. private _bucketHeight;
  78570. private _buckets;
  78571. private _bucketLen;
  78572. get bucketWidth(): number;
  78573. get bucketHeight(): number;
  78574. setBucketSizes(width: number, height: number): void;
  78575. private _useBuckets;
  78576. private _makeBuckets;
  78577. private _dispatchInBuckets;
  78578. private _updateMeasures;
  78579. private _updateChildrenMeasures;
  78580. private _restoreMeasures;
  78581. /**
  78582. * Creates a new ScrollViewerWindow
  78583. * @param name of ScrollViewerWindow
  78584. */
  78585. constructor(name?: string);
  78586. protected _getTypeName(): string;
  78587. /** @hidden */
  78588. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78589. /** @hidden */
  78590. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78591. private _scrollChildren;
  78592. private _scrollChildrenWithBuckets;
  78593. /** @hidden */
  78594. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  78595. protected _postMeasure(): void;
  78596. }
  78597. }
  78598. declare module BABYLON.GUI {
  78599. /**
  78600. * Class used to create slider controls
  78601. */
  78602. export class ScrollBar extends BaseSlider {
  78603. name?: string | undefined;
  78604. private _background;
  78605. private _borderColor;
  78606. private _tempMeasure;
  78607. /** Gets or sets border color */
  78608. get borderColor(): string;
  78609. set borderColor(value: string);
  78610. /** Gets or sets background color */
  78611. get background(): string;
  78612. set background(value: string);
  78613. /**
  78614. * Creates a new Slider
  78615. * @param name defines the control name
  78616. */
  78617. constructor(name?: string | undefined);
  78618. protected _getTypeName(): string;
  78619. protected _getThumbThickness(): number;
  78620. _draw(context: CanvasRenderingContext2D): void;
  78621. private _first;
  78622. private _originX;
  78623. private _originY;
  78624. /** @hidden */
  78625. protected _updateValueFromPointer(x: number, y: number): void;
  78626. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78627. }
  78628. }
  78629. declare module BABYLON.GUI {
  78630. /**
  78631. * Class used to create slider controls
  78632. */
  78633. export class ImageScrollBar extends BaseSlider {
  78634. name?: string | undefined;
  78635. private _backgroundBaseImage;
  78636. private _backgroundImage;
  78637. private _thumbImage;
  78638. private _thumbBaseImage;
  78639. private _thumbLength;
  78640. private _thumbHeight;
  78641. private _barImageHeight;
  78642. private _tempMeasure;
  78643. /** Number of 90° rotation to apply on the images when in vertical mode */
  78644. num90RotationInVerticalMode: number;
  78645. /**
  78646. * Gets or sets the image used to render the background for horizontal bar
  78647. */
  78648. get backgroundImage(): Image;
  78649. set backgroundImage(value: Image);
  78650. /**
  78651. * Gets or sets the image used to render the thumb
  78652. */
  78653. get thumbImage(): Image;
  78654. set thumbImage(value: Image);
  78655. /**
  78656. * Gets or sets the length of the thumb
  78657. */
  78658. get thumbLength(): number;
  78659. set thumbLength(value: number);
  78660. /**
  78661. * Gets or sets the height of the thumb
  78662. */
  78663. get thumbHeight(): number;
  78664. set thumbHeight(value: number);
  78665. /**
  78666. * Gets or sets the height of the bar image
  78667. */
  78668. get barImageHeight(): number;
  78669. set barImageHeight(value: number);
  78670. /**
  78671. * Creates a new ImageScrollBar
  78672. * @param name defines the control name
  78673. */
  78674. constructor(name?: string | undefined);
  78675. protected _getTypeName(): string;
  78676. protected _getThumbThickness(): number;
  78677. _draw(context: CanvasRenderingContext2D): void;
  78678. private _first;
  78679. private _originX;
  78680. private _originY;
  78681. /** @hidden */
  78682. protected _updateValueFromPointer(x: number, y: number): void;
  78683. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78684. }
  78685. }
  78686. declare module BABYLON.GUI {
  78687. /**
  78688. * Class used to hold a viewer window and sliders in a grid
  78689. */
  78690. export class ScrollViewer extends Rectangle {
  78691. private _grid;
  78692. private _horizontalBarSpace;
  78693. private _verticalBarSpace;
  78694. private _dragSpace;
  78695. private _horizontalBar;
  78696. private _verticalBar;
  78697. private _barColor;
  78698. private _barBackground;
  78699. private _barImage;
  78700. private _horizontalBarImage;
  78701. private _verticalBarImage;
  78702. private _barBackgroundImage;
  78703. private _horizontalBarBackgroundImage;
  78704. private _verticalBarBackgroundImage;
  78705. private _barSize;
  78706. private _window;
  78707. private _pointerIsOver;
  78708. private _wheelPrecision;
  78709. private _onWheelObserver;
  78710. private _clientWidth;
  78711. private _clientHeight;
  78712. private _useImageBar;
  78713. private _thumbLength;
  78714. private _thumbHeight;
  78715. private _barImageHeight;
  78716. private _horizontalBarImageHeight;
  78717. private _verticalBarImageHeight;
  78718. private _oldWindowContentsWidth;
  78719. private _oldWindowContentsHeight;
  78720. /**
  78721. * Gets the horizontal scrollbar
  78722. */
  78723. get horizontalBar(): ScrollBar | ImageScrollBar;
  78724. /**
  78725. * Gets the vertical scrollbar
  78726. */
  78727. get verticalBar(): ScrollBar | ImageScrollBar;
  78728. /**
  78729. * Adds a new control to the current container
  78730. * @param control defines the control to add
  78731. * @returns the current container
  78732. */
  78733. addControl(control: BABYLON.Nullable<Control>): Container;
  78734. /**
  78735. * Removes a control from the current container
  78736. * @param control defines the control to remove
  78737. * @returns the current container
  78738. */
  78739. removeControl(control: Control): Container;
  78740. /** Gets the list of children */
  78741. get children(): Control[];
  78742. _flagDescendantsAsMatrixDirty(): void;
  78743. /**
  78744. * Freezes or unfreezes the controls in the window.
  78745. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  78746. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  78747. */
  78748. get freezeControls(): boolean;
  78749. set freezeControls(value: boolean);
  78750. /** Gets the bucket width */
  78751. get bucketWidth(): number;
  78752. /** Gets the bucket height */
  78753. get bucketHeight(): number;
  78754. /**
  78755. * Sets the bucket sizes.
  78756. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  78757. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  78758. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  78759. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  78760. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  78761. * used), that's why it is not enabled by default.
  78762. * @param width width of the bucket
  78763. * @param height height of the bucket
  78764. */
  78765. setBucketSizes(width: number, height: number): void;
  78766. private _forceHorizontalBar;
  78767. private _forceVerticalBar;
  78768. /**
  78769. * Forces the horizontal scroll bar to be displayed
  78770. */
  78771. get forceHorizontalBar(): boolean;
  78772. set forceHorizontalBar(value: boolean);
  78773. /**
  78774. * Forces the vertical scroll bar to be displayed
  78775. */
  78776. get forceVerticalBar(): boolean;
  78777. set forceVerticalBar(value: boolean);
  78778. /**
  78779. * Creates a new ScrollViewer
  78780. * @param name of ScrollViewer
  78781. */
  78782. constructor(name?: string, isImageBased?: boolean);
  78783. /** Reset the scroll viewer window to initial size */
  78784. resetWindow(): void;
  78785. protected _getTypeName(): string;
  78786. private _buildClientSizes;
  78787. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78788. protected _postMeasure(): void;
  78789. /**
  78790. * Gets or sets the mouse wheel precision
  78791. * from 0 to 1 with a default value of 0.05
  78792. * */
  78793. get wheelPrecision(): number;
  78794. set wheelPrecision(value: number);
  78795. /** Gets or sets the scroll bar container background color */
  78796. get scrollBackground(): string;
  78797. set scrollBackground(color: string);
  78798. /** Gets or sets the bar color */
  78799. get barColor(): string;
  78800. set barColor(color: string);
  78801. /** Gets or sets the bar image */
  78802. get thumbImage(): Image;
  78803. set thumbImage(value: Image);
  78804. /** Gets or sets the horizontal bar image */
  78805. get horizontalThumbImage(): Image;
  78806. set horizontalThumbImage(value: Image);
  78807. /** Gets or sets the vertical bar image */
  78808. get verticalThumbImage(): Image;
  78809. set verticalThumbImage(value: Image);
  78810. /** Gets or sets the size of the bar */
  78811. get barSize(): number;
  78812. set barSize(value: number);
  78813. /** Gets or sets the length of the thumb */
  78814. get thumbLength(): number;
  78815. set thumbLength(value: number);
  78816. /** Gets or sets the height of the thumb */
  78817. get thumbHeight(): number;
  78818. set thumbHeight(value: number);
  78819. /** Gets or sets the height of the bar image */
  78820. get barImageHeight(): number;
  78821. set barImageHeight(value: number);
  78822. /** Gets or sets the height of the horizontal bar image */
  78823. get horizontalBarImageHeight(): number;
  78824. set horizontalBarImageHeight(value: number);
  78825. /** Gets or sets the height of the vertical bar image */
  78826. get verticalBarImageHeight(): number;
  78827. set verticalBarImageHeight(value: number);
  78828. /** Gets or sets the bar background */
  78829. get barBackground(): string;
  78830. set barBackground(color: string);
  78831. /** Gets or sets the bar background image */
  78832. get barImage(): Image;
  78833. set barImage(value: Image);
  78834. /** Gets or sets the horizontal bar background image */
  78835. get horizontalBarImage(): Image;
  78836. set horizontalBarImage(value: Image);
  78837. /** Gets or sets the vertical bar background image */
  78838. get verticalBarImage(): Image;
  78839. set verticalBarImage(value: Image);
  78840. private _setWindowPosition;
  78841. /** @hidden */
  78842. private _updateScroller;
  78843. _link(host: AdvancedDynamicTexture): void;
  78844. /** @hidden */
  78845. private _addBar;
  78846. /** @hidden */
  78847. private _attachWheel;
  78848. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78849. /** Releases associated resources */
  78850. dispose(): void;
  78851. }
  78852. }
  78853. declare module BABYLON.GUI {
  78854. /** Class used to render a grid */
  78855. export class DisplayGrid extends Control {
  78856. name?: string | undefined;
  78857. private _cellWidth;
  78858. private _cellHeight;
  78859. private _minorLineTickness;
  78860. private _minorLineColor;
  78861. private _majorLineTickness;
  78862. private _majorLineColor;
  78863. private _majorLineFrequency;
  78864. private _background;
  78865. private _displayMajorLines;
  78866. private _displayMinorLines;
  78867. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  78868. get displayMinorLines(): boolean;
  78869. set displayMinorLines(value: boolean);
  78870. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  78871. get displayMajorLines(): boolean;
  78872. set displayMajorLines(value: boolean);
  78873. /** Gets or sets background color (Black by default) */
  78874. get background(): string;
  78875. set background(value: string);
  78876. /** Gets or sets the width of each cell (20 by default) */
  78877. get cellWidth(): number;
  78878. set cellWidth(value: number);
  78879. /** Gets or sets the height of each cell (20 by default) */
  78880. get cellHeight(): number;
  78881. set cellHeight(value: number);
  78882. /** Gets or sets the tickness of minor lines (1 by default) */
  78883. get minorLineTickness(): number;
  78884. set minorLineTickness(value: number);
  78885. /** Gets or sets the color of minor lines (DarkGray by default) */
  78886. get minorLineColor(): string;
  78887. set minorLineColor(value: string);
  78888. /** Gets or sets the tickness of major lines (2 by default) */
  78889. get majorLineTickness(): number;
  78890. set majorLineTickness(value: number);
  78891. /** Gets or sets the color of major lines (White by default) */
  78892. get majorLineColor(): string;
  78893. set majorLineColor(value: string);
  78894. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  78895. get majorLineFrequency(): number;
  78896. set majorLineFrequency(value: number);
  78897. /**
  78898. * Creates a new GridDisplayRectangle
  78899. * @param name defines the control name
  78900. */
  78901. constructor(name?: string | undefined);
  78902. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78903. protected _getTypeName(): string;
  78904. }
  78905. }
  78906. declare module BABYLON.GUI {
  78907. /**
  78908. * Class used to create slider controls based on images
  78909. */
  78910. export class ImageBasedSlider extends BaseSlider {
  78911. name?: string | undefined;
  78912. private _backgroundImage;
  78913. private _thumbImage;
  78914. private _valueBarImage;
  78915. private _tempMeasure;
  78916. get displayThumb(): boolean;
  78917. set displayThumb(value: boolean);
  78918. /**
  78919. * Gets or sets the image used to render the background
  78920. */
  78921. get backgroundImage(): Image;
  78922. set backgroundImage(value: Image);
  78923. /**
  78924. * Gets or sets the image used to render the value bar
  78925. */
  78926. get valueBarImage(): Image;
  78927. set valueBarImage(value: Image);
  78928. /**
  78929. * Gets or sets the image used to render the thumb
  78930. */
  78931. get thumbImage(): Image;
  78932. set thumbImage(value: Image);
  78933. /**
  78934. * Creates a new ImageBasedSlider
  78935. * @param name defines the control name
  78936. */
  78937. constructor(name?: string | undefined);
  78938. protected _getTypeName(): string;
  78939. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78940. }
  78941. }
  78942. declare module BABYLON.GUI {
  78943. /**
  78944. * Forcing an export so that this code will execute
  78945. * @hidden
  78946. */
  78947. const name = "Statics";
  78948. }
  78949. declare module BABYLON.GUI {
  78950. /**
  78951. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  78952. */
  78953. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  78954. /**
  78955. * Define the instrumented AdvancedDynamicTexture.
  78956. */
  78957. texture: AdvancedDynamicTexture;
  78958. private _captureRenderTime;
  78959. private _renderTime;
  78960. private _captureLayoutTime;
  78961. private _layoutTime;
  78962. private _onBeginRenderObserver;
  78963. private _onEndRenderObserver;
  78964. private _onBeginLayoutObserver;
  78965. private _onEndLayoutObserver;
  78966. /**
  78967. * Gets the perf counter used to capture render time
  78968. */
  78969. get renderTimeCounter(): BABYLON.PerfCounter;
  78970. /**
  78971. * Gets the perf counter used to capture layout time
  78972. */
  78973. get layoutTimeCounter(): BABYLON.PerfCounter;
  78974. /**
  78975. * Enable or disable the render time capture
  78976. */
  78977. get captureRenderTime(): boolean;
  78978. set captureRenderTime(value: boolean);
  78979. /**
  78980. * Enable or disable the layout time capture
  78981. */
  78982. get captureLayoutTime(): boolean;
  78983. set captureLayoutTime(value: boolean);
  78984. /**
  78985. * Instantiates a new advanced dynamic texture instrumentation.
  78986. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  78987. * @param texture Defines the AdvancedDynamicTexture to instrument
  78988. */
  78989. constructor(
  78990. /**
  78991. * Define the instrumented AdvancedDynamicTexture.
  78992. */
  78993. texture: AdvancedDynamicTexture);
  78994. /**
  78995. * Dispose and release associated resources.
  78996. */
  78997. dispose(): void;
  78998. }
  78999. }
  79000. declare module BABYLON.GUI {
  79001. /**
  79002. * Class used to load GUI via XML.
  79003. */
  79004. export class XmlLoader {
  79005. private _nodes;
  79006. private _nodeTypes;
  79007. private _isLoaded;
  79008. private _objectAttributes;
  79009. private _parentClass;
  79010. /**
  79011. * Create a new xml loader
  79012. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  79013. */
  79014. constructor(parentClass?: null);
  79015. private _getChainElement;
  79016. private _getClassAttribute;
  79017. private _createGuiElement;
  79018. private _parseGrid;
  79019. private _parseElement;
  79020. private _prepareSourceElement;
  79021. private _parseElementsFromSource;
  79022. private _parseXml;
  79023. /**
  79024. * Gets if the loading has finished.
  79025. * @returns whether the loading has finished or not
  79026. */
  79027. isLoaded(): boolean;
  79028. /**
  79029. * Gets a loaded node / control by id.
  79030. * @param id the Controls id set in the xml
  79031. * @returns element of type Control
  79032. */
  79033. getNodeById(id: string): any;
  79034. /**
  79035. * Gets all loaded nodes / controls
  79036. * @returns Array of controls
  79037. */
  79038. getNodes(): any;
  79039. /**
  79040. * Initiates the xml layout loading
  79041. * @param xmlFile defines the xml layout to load
  79042. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  79043. * @param callback defines the callback called on layout load.
  79044. */
  79045. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  79046. }
  79047. }
  79048. declare module BABYLON.GUI {
  79049. /**
  79050. * Class used to create containers for controls
  79051. */
  79052. export class Container3D extends Control3D {
  79053. private _blockLayout;
  79054. /**
  79055. * Gets the list of child controls
  79056. */
  79057. protected _children: Control3D[];
  79058. /**
  79059. * Gets the list of child controls
  79060. */
  79061. get children(): Array<Control3D>;
  79062. /**
  79063. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  79064. * This is helpful to optimize layout operation when adding multiple children in a row
  79065. */
  79066. get blockLayout(): boolean;
  79067. set blockLayout(value: boolean);
  79068. /**
  79069. * Creates a new container
  79070. * @param name defines the container name
  79071. */
  79072. constructor(name?: string);
  79073. /**
  79074. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  79075. * @returns the current container
  79076. */
  79077. updateLayout(): Container3D;
  79078. /**
  79079. * Gets a boolean indicating if the given control is in the children of this control
  79080. * @param control defines the control to check
  79081. * @returns true if the control is in the child list
  79082. */
  79083. containsControl(control: Control3D): boolean;
  79084. /**
  79085. * Adds a control to the children of this control
  79086. * @param control defines the control to add
  79087. * @returns the current container
  79088. */
  79089. addControl(control: Control3D): Container3D;
  79090. /**
  79091. * This function will be called everytime a new control is added
  79092. */
  79093. protected _arrangeChildren(): void;
  79094. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  79095. /**
  79096. * Removes a control from the children of this control
  79097. * @param control defines the control to remove
  79098. * @returns the current container
  79099. */
  79100. removeControl(control: Control3D): Container3D;
  79101. protected _getTypeName(): string;
  79102. /**
  79103. * Releases all associated resources
  79104. */
  79105. dispose(): void;
  79106. /** Control rotation will remain unchanged */
  79107. static readonly UNSET_ORIENTATION: number;
  79108. /** Control will rotate to make it look at sphere central axis */
  79109. static readonly FACEORIGIN_ORIENTATION: number;
  79110. /** Control will rotate to make it look back at sphere central axis */
  79111. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  79112. /** Control will rotate to look at z axis (0, 0, 1) */
  79113. static readonly FACEFORWARD_ORIENTATION: number;
  79114. /** Control will rotate to look at negative z axis (0, 0, -1) */
  79115. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  79116. }
  79117. }
  79118. declare module BABYLON.GUI {
  79119. /**
  79120. * Class used to manage 3D user interface
  79121. * @see https://doc.babylonjs.com/how_to/gui3d
  79122. */
  79123. export class GUI3DManager implements BABYLON.IDisposable {
  79124. private _scene;
  79125. private _sceneDisposeObserver;
  79126. private _utilityLayer;
  79127. private _rootContainer;
  79128. private _pointerObserver;
  79129. private _pointerOutObserver;
  79130. /** @hidden */
  79131. _lastPickedControl: Control3D;
  79132. /** @hidden */
  79133. _lastControlOver: {
  79134. [pointerId: number]: Control3D;
  79135. };
  79136. /** @hidden */
  79137. _lastControlDown: {
  79138. [pointerId: number]: Control3D;
  79139. };
  79140. /**
  79141. * BABYLON.Observable raised when the point picked by the pointer events changed
  79142. */
  79143. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  79144. /** @hidden */
  79145. _sharedMaterials: {
  79146. [key: string]: BABYLON.Material;
  79147. };
  79148. /** Gets the hosting scene */
  79149. get scene(): BABYLON.Scene;
  79150. /** Gets associated utility layer */
  79151. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  79152. /**
  79153. * Creates a new GUI3DManager
  79154. * @param scene
  79155. */
  79156. constructor(scene?: BABYLON.Scene);
  79157. private _handlePointerOut;
  79158. private _doPicking;
  79159. /**
  79160. * Gets the root container
  79161. */
  79162. get rootContainer(): Container3D;
  79163. /**
  79164. * Gets a boolean indicating if the given control is in the root child list
  79165. * @param control defines the control to check
  79166. * @returns true if the control is in the root child list
  79167. */
  79168. containsControl(control: Control3D): boolean;
  79169. /**
  79170. * Adds a control to the root child list
  79171. * @param control defines the control to add
  79172. * @returns the current manager
  79173. */
  79174. addControl(control: Control3D): GUI3DManager;
  79175. /**
  79176. * Removes a control from the root child list
  79177. * @param control defines the control to remove
  79178. * @returns the current container
  79179. */
  79180. removeControl(control: Control3D): GUI3DManager;
  79181. /**
  79182. * Releases all associated resources
  79183. */
  79184. dispose(): void;
  79185. }
  79186. }
  79187. declare module BABYLON.GUI {
  79188. /**
  79189. * Class used to transport BABYLON.Vector3 information for pointer events
  79190. */
  79191. export class Vector3WithInfo extends BABYLON.Vector3 {
  79192. /** defines the current mouse button index */
  79193. buttonIndex: number;
  79194. /**
  79195. * Creates a new Vector3WithInfo
  79196. * @param source defines the vector3 data to transport
  79197. * @param buttonIndex defines the current mouse button index
  79198. */
  79199. constructor(source: BABYLON.Vector3,
  79200. /** defines the current mouse button index */
  79201. buttonIndex?: number);
  79202. }
  79203. }
  79204. declare module BABYLON.GUI {
  79205. /**
  79206. * Class used as base class for controls
  79207. */
  79208. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  79209. /** Defines the control name */
  79210. name?: string | undefined;
  79211. /** @hidden */
  79212. _host: GUI3DManager;
  79213. private _node;
  79214. private _downCount;
  79215. private _enterCount;
  79216. private _downPointerIds;
  79217. private _isVisible;
  79218. /** Gets or sets the control position in world space */
  79219. get position(): BABYLON.Vector3;
  79220. set position(value: BABYLON.Vector3);
  79221. /** Gets or sets the control scaling in world space */
  79222. get scaling(): BABYLON.Vector3;
  79223. set scaling(value: BABYLON.Vector3);
  79224. /** Callback used to start pointer enter animation */
  79225. pointerEnterAnimation: () => void;
  79226. /** Callback used to start pointer out animation */
  79227. pointerOutAnimation: () => void;
  79228. /** Callback used to start pointer down animation */
  79229. pointerDownAnimation: () => void;
  79230. /** Callback used to start pointer up animation */
  79231. pointerUpAnimation: () => void;
  79232. /**
  79233. * An event triggered when the pointer move over the control
  79234. */
  79235. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  79236. /**
  79237. * An event triggered when the pointer move out of the control
  79238. */
  79239. onPointerOutObservable: BABYLON.Observable<Control3D>;
  79240. /**
  79241. * An event triggered when the pointer taps the control
  79242. */
  79243. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  79244. /**
  79245. * An event triggered when pointer is up
  79246. */
  79247. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  79248. /**
  79249. * An event triggered when a control is clicked on (with a mouse)
  79250. */
  79251. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  79252. /**
  79253. * An event triggered when pointer enters the control
  79254. */
  79255. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  79256. /**
  79257. * Gets or sets the parent container
  79258. */
  79259. parent: BABYLON.Nullable<Container3D>;
  79260. private _behaviors;
  79261. /**
  79262. * Gets the list of attached behaviors
  79263. * @see https://doc.babylonjs.com/features/behaviour
  79264. */
  79265. get behaviors(): BABYLON.Behavior<Control3D>[];
  79266. /**
  79267. * Attach a behavior to the control
  79268. * @see https://doc.babylonjs.com/features/behaviour
  79269. * @param behavior defines the behavior to attach
  79270. * @returns the current control
  79271. */
  79272. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  79273. /**
  79274. * Remove an attached behavior
  79275. * @see https://doc.babylonjs.com/features/behaviour
  79276. * @param behavior defines the behavior to attach
  79277. * @returns the current control
  79278. */
  79279. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  79280. /**
  79281. * Gets an attached behavior by name
  79282. * @param name defines the name of the behavior to look for
  79283. * @see https://doc.babylonjs.com/features/behaviour
  79284. * @returns null if behavior was not found else the requested behavior
  79285. */
  79286. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  79287. /** Gets or sets a boolean indicating if the control is visible */
  79288. get isVisible(): boolean;
  79289. set isVisible(value: boolean);
  79290. /**
  79291. * Creates a new control
  79292. * @param name defines the control name
  79293. */
  79294. constructor(
  79295. /** Defines the control name */
  79296. name?: string | undefined);
  79297. /**
  79298. * Gets a string representing the class name
  79299. */
  79300. get typeName(): string;
  79301. /**
  79302. * Get the current class name of the control.
  79303. * @returns current class name
  79304. */
  79305. getClassName(): string;
  79306. protected _getTypeName(): string;
  79307. /**
  79308. * Gets the transform node used by this control
  79309. */
  79310. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  79311. /**
  79312. * Gets the mesh used to render this control
  79313. */
  79314. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  79315. /**
  79316. * Link the control as child of the given node
  79317. * @param node defines the node to link to. Use null to unlink the control
  79318. * @returns the current control
  79319. */
  79320. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  79321. /** @hidden **/
  79322. _prepareNode(scene: BABYLON.Scene): void;
  79323. /**
  79324. * Node creation.
  79325. * Can be overriden by children
  79326. * @param scene defines the scene where the node must be attached
  79327. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  79328. */
  79329. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  79330. /**
  79331. * Affect a material to the given mesh
  79332. * @param mesh defines the mesh which will represent the control
  79333. */
  79334. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  79335. /** @hidden */
  79336. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  79337. /** @hidden */
  79338. _onPointerEnter(target: Control3D): boolean;
  79339. /** @hidden */
  79340. _onPointerOut(target: Control3D): void;
  79341. /** @hidden */
  79342. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  79343. /** @hidden */
  79344. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79345. /** @hidden */
  79346. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  79347. /** @hidden */
  79348. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  79349. /** @hidden */
  79350. _disposeNode(): void;
  79351. /**
  79352. * Releases all associated resources
  79353. */
  79354. dispose(): void;
  79355. }
  79356. }
  79357. declare module BABYLON.GUI {
  79358. /**
  79359. * Class used as a root to all buttons
  79360. */
  79361. export class AbstractButton3D extends Control3D {
  79362. /**
  79363. * Creates a new button
  79364. * @param name defines the control name
  79365. */
  79366. constructor(name?: string);
  79367. protected _getTypeName(): string;
  79368. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79369. }
  79370. }
  79371. declare module BABYLON.GUI {
  79372. /**
  79373. * Class used to create a button in 3D
  79374. */
  79375. export class Button3D extends AbstractButton3D {
  79376. /** @hidden */
  79377. protected _currentMaterial: BABYLON.Material;
  79378. private _facadeTexture;
  79379. private _content;
  79380. private _contentResolution;
  79381. private _contentScaleRatio;
  79382. /**
  79383. * Gets or sets the texture resolution used to render content (512 by default)
  79384. */
  79385. get contentResolution(): BABYLON.int;
  79386. set contentResolution(value: BABYLON.int);
  79387. /**
  79388. * Gets or sets the texture scale ratio used to render content (2 by default)
  79389. */
  79390. get contentScaleRatio(): number;
  79391. set contentScaleRatio(value: number);
  79392. protected _disposeFacadeTexture(): void;
  79393. protected _resetContent(): void;
  79394. /**
  79395. * Creates a new button
  79396. * @param name defines the control name
  79397. */
  79398. constructor(name?: string);
  79399. /**
  79400. * Gets or sets the GUI 2D content used to display the button's facade
  79401. */
  79402. get content(): Control;
  79403. set content(value: Control);
  79404. /**
  79405. * Apply the facade texture (created from the content property).
  79406. * This function can be overloaded by child classes
  79407. * @param facadeTexture defines the AdvancedDynamicTexture to use
  79408. */
  79409. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  79410. protected _getTypeName(): string;
  79411. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79412. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  79413. /**
  79414. * Releases all associated resources
  79415. */
  79416. dispose(): void;
  79417. }
  79418. }
  79419. declare module BABYLON.GUI {
  79420. /**
  79421. * Abstract class used to create a container panel deployed on the surface of a volume
  79422. */
  79423. export abstract class VolumeBasedPanel extends Container3D {
  79424. private _columns;
  79425. private _rows;
  79426. private _rowThenColum;
  79427. private _orientation;
  79428. protected _cellWidth: number;
  79429. protected _cellHeight: number;
  79430. /**
  79431. * Gets or sets the distance between elements
  79432. */
  79433. margin: number;
  79434. /**
  79435. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  79436. * | Value | Type | Description |
  79437. * | ----- | ----------------------------------- | ----------- |
  79438. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  79439. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  79440. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  79441. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  79442. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  79443. */
  79444. get orientation(): number;
  79445. set orientation(value: number);
  79446. /**
  79447. * Gets or sets the number of columns requested (10 by default).
  79448. * The panel will automatically compute the number of rows based on number of child controls.
  79449. */
  79450. get columns(): BABYLON.int;
  79451. set columns(value: BABYLON.int);
  79452. /**
  79453. * Gets or sets a the number of rows requested.
  79454. * The panel will automatically compute the number of columns based on number of child controls.
  79455. */
  79456. get rows(): BABYLON.int;
  79457. set rows(value: BABYLON.int);
  79458. /**
  79459. * Creates new VolumeBasedPanel
  79460. */
  79461. constructor();
  79462. protected _arrangeChildren(): void;
  79463. /** Child classes must implement this function to provide correct control positioning */
  79464. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79465. /** Child classes can implement this function to provide additional processing */
  79466. protected _finalProcessing(): void;
  79467. }
  79468. }
  79469. declare module BABYLON.GUI {
  79470. /**
  79471. * Class used to create a container panel deployed on the surface of a cylinder
  79472. */
  79473. export class CylinderPanel extends VolumeBasedPanel {
  79474. private _radius;
  79475. /**
  79476. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  79477. */
  79478. get radius(): BABYLON.float;
  79479. set radius(value: BABYLON.float);
  79480. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79481. private _cylindricalMapping;
  79482. }
  79483. }
  79484. declare module BABYLON.GUI {
  79485. /** @hidden */
  79486. export var fluentVertexShader: {
  79487. name: string;
  79488. shader: string;
  79489. };
  79490. }
  79491. declare module BABYLON.GUI {
  79492. /** @hidden */
  79493. export var fluentPixelShader: {
  79494. name: string;
  79495. shader: string;
  79496. };
  79497. }
  79498. declare module BABYLON.GUI {
  79499. /** @hidden */
  79500. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  79501. INNERGLOW: boolean;
  79502. BORDER: boolean;
  79503. HOVERLIGHT: boolean;
  79504. TEXTURE: boolean;
  79505. constructor();
  79506. }
  79507. /**
  79508. * Class used to render controls with fluent desgin
  79509. */
  79510. export class FluentMaterial extends BABYLON.PushMaterial {
  79511. /**
  79512. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  79513. */
  79514. innerGlowColorIntensity: number;
  79515. /**
  79516. * Gets or sets the inner glow color (white by default)
  79517. */
  79518. innerGlowColor: BABYLON.Color3;
  79519. /**
  79520. * Gets or sets alpha value (default is 1.0)
  79521. */
  79522. alpha: number;
  79523. /**
  79524. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  79525. */
  79526. albedoColor: BABYLON.Color3;
  79527. /**
  79528. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  79529. */
  79530. renderBorders: boolean;
  79531. /**
  79532. * Gets or sets border width (default is 0.5)
  79533. */
  79534. borderWidth: number;
  79535. /**
  79536. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  79537. */
  79538. edgeSmoothingValue: number;
  79539. /**
  79540. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  79541. */
  79542. borderMinValue: number;
  79543. /**
  79544. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  79545. */
  79546. renderHoverLight: boolean;
  79547. /**
  79548. * Gets or sets the radius used to render the hover light (default is 1.0)
  79549. */
  79550. hoverRadius: number;
  79551. /**
  79552. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  79553. */
  79554. hoverColor: BABYLON.Color4;
  79555. /**
  79556. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  79557. */
  79558. hoverPosition: BABYLON.Vector3;
  79559. private _albedoTexture;
  79560. /** Gets or sets the texture to use for albedo color */
  79561. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79562. /**
  79563. * Creates a new Fluent material
  79564. * @param name defines the name of the material
  79565. * @param scene defines the hosting scene
  79566. */
  79567. constructor(name: string, scene: BABYLON.Scene);
  79568. needAlphaBlending(): boolean;
  79569. needAlphaTesting(): boolean;
  79570. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79571. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79572. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79573. getActiveTextures(): BABYLON.BaseTexture[];
  79574. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79575. dispose(forceDisposeEffect?: boolean): void;
  79576. clone(name: string): FluentMaterial;
  79577. serialize(): any;
  79578. getClassName(): string;
  79579. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  79580. }
  79581. }
  79582. declare module BABYLON.GUI {
  79583. /**
  79584. * Class used to create a holographic button in 3D
  79585. */
  79586. export class HolographicButton extends Button3D {
  79587. private _backPlate;
  79588. private _textPlate;
  79589. private _frontPlate;
  79590. private _text;
  79591. private _imageUrl;
  79592. private _shareMaterials;
  79593. private _frontMaterial;
  79594. private _backMaterial;
  79595. private _plateMaterial;
  79596. private _pickedPointObserver;
  79597. private _tooltipFade;
  79598. private _tooltipTextBlock;
  79599. private _tooltipTexture;
  79600. private _tooltipMesh;
  79601. private _tooltipHoverObserver;
  79602. private _tooltipOutObserver;
  79603. private _disposeTooltip;
  79604. /**
  79605. * Rendering ground id of all the mesh in the button
  79606. */
  79607. set renderingGroupId(id: number);
  79608. get renderingGroupId(): number;
  79609. /**
  79610. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  79611. */
  79612. set tooltipText(text: BABYLON.Nullable<string>);
  79613. get tooltipText(): BABYLON.Nullable<string>;
  79614. /**
  79615. * Gets or sets text for the button
  79616. */
  79617. get text(): string;
  79618. set text(value: string);
  79619. /**
  79620. * Gets or sets the image url for the button
  79621. */
  79622. get imageUrl(): string;
  79623. set imageUrl(value: string);
  79624. /**
  79625. * Gets the back material used by this button
  79626. */
  79627. get backMaterial(): FluentMaterial;
  79628. /**
  79629. * Gets the front material used by this button
  79630. */
  79631. get frontMaterial(): FluentMaterial;
  79632. /**
  79633. * Gets the plate material used by this button
  79634. */
  79635. get plateMaterial(): BABYLON.StandardMaterial;
  79636. /**
  79637. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  79638. */
  79639. get shareMaterials(): boolean;
  79640. /**
  79641. * Creates a new button
  79642. * @param name defines the control name
  79643. */
  79644. constructor(name?: string, shareMaterials?: boolean);
  79645. protected _getTypeName(): string;
  79646. private _rebuildContent;
  79647. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79648. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  79649. private _createBackMaterial;
  79650. private _createFrontMaterial;
  79651. private _createPlateMaterial;
  79652. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  79653. /**
  79654. * Releases all associated resources
  79655. */
  79656. dispose(): void;
  79657. }
  79658. }
  79659. declare module BABYLON.GUI {
  79660. /**
  79661. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  79662. */
  79663. export class MeshButton3D extends Button3D {
  79664. /** @hidden */
  79665. protected _currentMesh: BABYLON.Mesh;
  79666. /**
  79667. * Creates a new 3D button based on a mesh
  79668. * @param mesh mesh to become a 3D button
  79669. * @param name defines the control name
  79670. */
  79671. constructor(mesh: BABYLON.Mesh, name?: string);
  79672. protected _getTypeName(): string;
  79673. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79674. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  79675. }
  79676. }
  79677. declare module BABYLON.GUI {
  79678. /**
  79679. * Class used to create a container panel deployed on the surface of a plane
  79680. */
  79681. export class PlanePanel extends VolumeBasedPanel {
  79682. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79683. }
  79684. }
  79685. declare module BABYLON.GUI {
  79686. /**
  79687. * Class used to create a container panel where items get randomized planar mapping
  79688. */
  79689. export class ScatterPanel extends VolumeBasedPanel {
  79690. private _iteration;
  79691. /**
  79692. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  79693. */
  79694. get iteration(): BABYLON.float;
  79695. set iteration(value: BABYLON.float);
  79696. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79697. private _scatterMapping;
  79698. protected _finalProcessing(): void;
  79699. }
  79700. }
  79701. declare module BABYLON.GUI {
  79702. /**
  79703. * Class used to create a container panel deployed on the surface of a sphere
  79704. */
  79705. export class SpherePanel extends VolumeBasedPanel {
  79706. private _radius;
  79707. /**
  79708. * Gets or sets the radius of the sphere where to project controls (5 by default)
  79709. */
  79710. get radius(): BABYLON.float;
  79711. set radius(value: BABYLON.float);
  79712. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79713. private _sphericalMapping;
  79714. }
  79715. }
  79716. declare module BABYLON.GUI {
  79717. /**
  79718. * Class used to create a stack panel in 3D on XY plane
  79719. */
  79720. export class StackPanel3D extends Container3D {
  79721. private _isVertical;
  79722. /**
  79723. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  79724. */
  79725. get isVertical(): boolean;
  79726. set isVertical(value: boolean);
  79727. /**
  79728. * Gets or sets the distance between elements
  79729. */
  79730. margin: number;
  79731. /**
  79732. * Creates new StackPanel
  79733. * @param isVertical
  79734. */
  79735. constructor(isVertical?: boolean);
  79736. protected _arrangeChildren(): void;
  79737. }
  79738. }
  79739. declare module BABYLON {
  79740. /**
  79741. * Configuration for glTF validation
  79742. */
  79743. export interface IGLTFValidationConfiguration {
  79744. /**
  79745. * The url of the glTF validator.
  79746. */
  79747. url: string;
  79748. }
  79749. /**
  79750. * glTF validation
  79751. */
  79752. export class GLTFValidation {
  79753. /**
  79754. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  79755. */
  79756. static Configuration: IGLTFValidationConfiguration;
  79757. private static _LoadScriptPromise;
  79758. /**
  79759. * Validate a glTF asset using the glTF-Validator.
  79760. * @param data The JSON of a glTF or the array buffer of a binary glTF
  79761. * @param rootUrl The root url for the glTF
  79762. * @param fileName The file name for the glTF
  79763. * @param getExternalResource The callback to get external resources for the glTF validator
  79764. * @returns A promise that resolves with the glTF validation results once complete
  79765. */
  79766. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  79767. }
  79768. }
  79769. declare module BABYLON {
  79770. /**
  79771. * Mode that determines the coordinate system to use.
  79772. */
  79773. export enum GLTFLoaderCoordinateSystemMode {
  79774. /**
  79775. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  79776. */
  79777. AUTO = 0,
  79778. /**
  79779. * Sets the useRightHandedSystem flag on the scene.
  79780. */
  79781. FORCE_RIGHT_HANDED = 1
  79782. }
  79783. /**
  79784. * Mode that determines what animations will start.
  79785. */
  79786. export enum GLTFLoaderAnimationStartMode {
  79787. /**
  79788. * No animation will start.
  79789. */
  79790. NONE = 0,
  79791. /**
  79792. * The first animation will start.
  79793. */
  79794. FIRST = 1,
  79795. /**
  79796. * All animations will start.
  79797. */
  79798. ALL = 2
  79799. }
  79800. /**
  79801. * Interface that contains the data for the glTF asset.
  79802. */
  79803. export interface IGLTFLoaderData {
  79804. /**
  79805. * The object that represents the glTF JSON.
  79806. */
  79807. json: Object;
  79808. /**
  79809. * The BIN chunk of a binary glTF.
  79810. */
  79811. bin: Nullable<IDataBuffer>;
  79812. }
  79813. /**
  79814. * Interface for extending the loader.
  79815. */
  79816. export interface IGLTFLoaderExtension {
  79817. /**
  79818. * The name of this extension.
  79819. */
  79820. readonly name: string;
  79821. /**
  79822. * Defines whether this extension is enabled.
  79823. */
  79824. enabled: boolean;
  79825. /**
  79826. * Defines the order of this extension.
  79827. * The loader sorts the extensions using these values when loading.
  79828. */
  79829. order?: number;
  79830. }
  79831. /**
  79832. * Loader state.
  79833. */
  79834. export enum GLTFLoaderState {
  79835. /**
  79836. * The asset is loading.
  79837. */
  79838. LOADING = 0,
  79839. /**
  79840. * The asset is ready for rendering.
  79841. */
  79842. READY = 1,
  79843. /**
  79844. * The asset is completely loaded.
  79845. */
  79846. COMPLETE = 2
  79847. }
  79848. /** @hidden */
  79849. export interface IImportMeshAsyncOutput {
  79850. meshes: AbstractMesh[];
  79851. particleSystems: IParticleSystem[];
  79852. skeletons: Skeleton[];
  79853. animationGroups: AnimationGroup[];
  79854. lights: Light[];
  79855. transformNodes: TransformNode[];
  79856. }
  79857. /** @hidden */
  79858. export interface IGLTFLoader extends IDisposable {
  79859. readonly state: Nullable<GLTFLoaderState>;
  79860. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  79861. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  79862. }
  79863. /**
  79864. * File loader for loading glTF files into a scene.
  79865. */
  79866. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  79867. /** @hidden */
  79868. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  79869. /** @hidden */
  79870. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  79871. /**
  79872. * Raised when the asset has been parsed
  79873. */
  79874. onParsedObservable: Observable<IGLTFLoaderData>;
  79875. private _onParsedObserver;
  79876. /**
  79877. * Raised when the asset has been parsed
  79878. */
  79879. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  79880. /**
  79881. * 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.
  79882. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  79883. * Defaults to true.
  79884. * @hidden
  79885. */
  79886. static IncrementalLoading: boolean;
  79887. /**
  79888. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  79889. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  79890. * @hidden
  79891. */
  79892. static HomogeneousCoordinates: boolean;
  79893. /**
  79894. * The coordinate system mode. Defaults to AUTO.
  79895. */
  79896. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  79897. /**
  79898. * The animation start mode. Defaults to FIRST.
  79899. */
  79900. animationStartMode: GLTFLoaderAnimationStartMode;
  79901. /**
  79902. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  79903. */
  79904. compileMaterials: boolean;
  79905. /**
  79906. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  79907. */
  79908. useClipPlane: boolean;
  79909. /**
  79910. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  79911. */
  79912. compileShadowGenerators: boolean;
  79913. /**
  79914. * Defines if the Alpha blended materials are only applied as coverage.
  79915. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  79916. * If true, no extra effects are applied to transparent pixels.
  79917. */
  79918. transparencyAsCoverage: boolean;
  79919. /**
  79920. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  79921. * Enabling will disable offline support and glTF validator.
  79922. * Defaults to false.
  79923. */
  79924. useRangeRequests: boolean;
  79925. /**
  79926. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  79927. */
  79928. createInstances: boolean;
  79929. /**
  79930. * 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.
  79931. */
  79932. alwaysComputeBoundingBox: boolean;
  79933. /**
  79934. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  79935. */
  79936. loadAllMaterials: boolean;
  79937. /**
  79938. * Function called before loading a url referenced by the asset.
  79939. */
  79940. preprocessUrlAsync: (url: string) => Promise<string>;
  79941. /**
  79942. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  79943. */
  79944. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  79945. private _onMeshLoadedObserver;
  79946. /**
  79947. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  79948. */
  79949. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  79950. /**
  79951. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  79952. */
  79953. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  79954. private _onTextureLoadedObserver;
  79955. /**
  79956. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  79957. */
  79958. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  79959. /**
  79960. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  79961. */
  79962. readonly onMaterialLoadedObservable: Observable<Material>;
  79963. private _onMaterialLoadedObserver;
  79964. /**
  79965. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  79966. */
  79967. set onMaterialLoaded(callback: (material: Material) => void);
  79968. /**
  79969. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  79970. */
  79971. readonly onCameraLoadedObservable: Observable<Camera>;
  79972. private _onCameraLoadedObserver;
  79973. /**
  79974. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  79975. */
  79976. set onCameraLoaded(callback: (camera: Camera) => void);
  79977. /**
  79978. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  79979. * For assets with LODs, raised when all of the LODs are complete.
  79980. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  79981. */
  79982. readonly onCompleteObservable: Observable<void>;
  79983. private _onCompleteObserver;
  79984. /**
  79985. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  79986. * For assets with LODs, raised when all of the LODs are complete.
  79987. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  79988. */
  79989. set onComplete(callback: () => void);
  79990. /**
  79991. * Observable raised when an error occurs.
  79992. */
  79993. readonly onErrorObservable: Observable<any>;
  79994. private _onErrorObserver;
  79995. /**
  79996. * Callback raised when an error occurs.
  79997. */
  79998. set onError(callback: (reason: any) => void);
  79999. /**
  80000. * Observable raised after the loader is disposed.
  80001. */
  80002. readonly onDisposeObservable: Observable<void>;
  80003. private _onDisposeObserver;
  80004. /**
  80005. * Callback raised after the loader is disposed.
  80006. */
  80007. set onDispose(callback: () => void);
  80008. /**
  80009. * Observable raised after a loader extension is created.
  80010. * Set additional options for a loader extension in this event.
  80011. */
  80012. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  80013. private _onExtensionLoadedObserver;
  80014. /**
  80015. * Callback raised after a loader extension is created.
  80016. */
  80017. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  80018. /**
  80019. * Defines if the loader logging is enabled.
  80020. */
  80021. get loggingEnabled(): boolean;
  80022. set loggingEnabled(value: boolean);
  80023. /**
  80024. * Defines if the loader should capture performance counters.
  80025. */
  80026. get capturePerformanceCounters(): boolean;
  80027. set capturePerformanceCounters(value: boolean);
  80028. /**
  80029. * Defines if the loader should validate the asset.
  80030. */
  80031. validate: boolean;
  80032. /**
  80033. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  80034. */
  80035. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  80036. private _onValidatedObserver;
  80037. /**
  80038. * Callback raised after a loader extension is created.
  80039. */
  80040. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  80041. private _loader;
  80042. private _progressCallback?;
  80043. private _requests;
  80044. private static magicBase64Encoded;
  80045. /**
  80046. * Name of the loader ("gltf")
  80047. */
  80048. name: string;
  80049. /** @hidden */
  80050. extensions: ISceneLoaderPluginExtensions;
  80051. /**
  80052. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  80053. */
  80054. dispose(): void;
  80055. /** @hidden */
  80056. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  80057. /** @hidden */
  80058. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  80059. /** @hidden */
  80060. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  80061. meshes: AbstractMesh[];
  80062. particleSystems: IParticleSystem[];
  80063. skeletons: Skeleton[];
  80064. animationGroups: AnimationGroup[];
  80065. }>;
  80066. /** @hidden */
  80067. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80068. /** @hidden */
  80069. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  80070. /** @hidden */
  80071. canDirectLoad(data: string): boolean;
  80072. /** @hidden */
  80073. directLoad(scene: Scene, data: string): Promise<any>;
  80074. /**
  80075. * The callback that allows custom handling of the root url based on the response url.
  80076. * @param rootUrl the original root url
  80077. * @param responseURL the response url if available
  80078. * @returns the new root url
  80079. */
  80080. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  80081. /** @hidden */
  80082. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  80083. /**
  80084. * The loader state or null if the loader is not active.
  80085. */
  80086. get loaderState(): Nullable<GLTFLoaderState>;
  80087. /**
  80088. * Returns a promise that resolves when the asset is completely loaded.
  80089. * @returns a promise that resolves when the asset is completely loaded.
  80090. */
  80091. whenCompleteAsync(): Promise<void>;
  80092. /** @hidden */
  80093. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  80094. /** @hidden */
  80095. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  80096. private _onProgress;
  80097. private _validate;
  80098. private _getLoader;
  80099. private _parseJson;
  80100. private _unpackBinaryAsync;
  80101. private _unpackBinaryV1Async;
  80102. private _unpackBinaryV2Async;
  80103. private static _parseVersion;
  80104. private static _compareVersion;
  80105. private static readonly _logSpaces;
  80106. private _logIndentLevel;
  80107. private _loggingEnabled;
  80108. /** @hidden */
  80109. _log: (message: string) => void;
  80110. /** @hidden */
  80111. _logOpen(message: string): void;
  80112. /** @hidden */
  80113. _logClose(): void;
  80114. private _logEnabled;
  80115. private _logDisabled;
  80116. private _capturePerformanceCounters;
  80117. /** @hidden */
  80118. _startPerformanceCounter: (counterName: string) => void;
  80119. /** @hidden */
  80120. _endPerformanceCounter: (counterName: string) => void;
  80121. private _startPerformanceCounterEnabled;
  80122. private _startPerformanceCounterDisabled;
  80123. private _endPerformanceCounterEnabled;
  80124. private _endPerformanceCounterDisabled;
  80125. }
  80126. }
  80127. declare module BABYLON.GLTF1 {
  80128. /**
  80129. * Enums
  80130. * @hidden
  80131. */
  80132. export enum EComponentType {
  80133. BYTE = 5120,
  80134. UNSIGNED_BYTE = 5121,
  80135. SHORT = 5122,
  80136. UNSIGNED_SHORT = 5123,
  80137. FLOAT = 5126
  80138. }
  80139. /** @hidden */
  80140. export enum EShaderType {
  80141. FRAGMENT = 35632,
  80142. VERTEX = 35633
  80143. }
  80144. /** @hidden */
  80145. export enum EParameterType {
  80146. BYTE = 5120,
  80147. UNSIGNED_BYTE = 5121,
  80148. SHORT = 5122,
  80149. UNSIGNED_SHORT = 5123,
  80150. INT = 5124,
  80151. UNSIGNED_INT = 5125,
  80152. FLOAT = 5126,
  80153. FLOAT_VEC2 = 35664,
  80154. FLOAT_VEC3 = 35665,
  80155. FLOAT_VEC4 = 35666,
  80156. INT_VEC2 = 35667,
  80157. INT_VEC3 = 35668,
  80158. INT_VEC4 = 35669,
  80159. BOOL = 35670,
  80160. BOOL_VEC2 = 35671,
  80161. BOOL_VEC3 = 35672,
  80162. BOOL_VEC4 = 35673,
  80163. FLOAT_MAT2 = 35674,
  80164. FLOAT_MAT3 = 35675,
  80165. FLOAT_MAT4 = 35676,
  80166. SAMPLER_2D = 35678
  80167. }
  80168. /** @hidden */
  80169. export enum ETextureWrapMode {
  80170. CLAMP_TO_EDGE = 33071,
  80171. MIRRORED_REPEAT = 33648,
  80172. REPEAT = 10497
  80173. }
  80174. /** @hidden */
  80175. export enum ETextureFilterType {
  80176. NEAREST = 9728,
  80177. LINEAR = 9728,
  80178. NEAREST_MIPMAP_NEAREST = 9984,
  80179. LINEAR_MIPMAP_NEAREST = 9985,
  80180. NEAREST_MIPMAP_LINEAR = 9986,
  80181. LINEAR_MIPMAP_LINEAR = 9987
  80182. }
  80183. /** @hidden */
  80184. export enum ETextureFormat {
  80185. ALPHA = 6406,
  80186. RGB = 6407,
  80187. RGBA = 6408,
  80188. LUMINANCE = 6409,
  80189. LUMINANCE_ALPHA = 6410
  80190. }
  80191. /** @hidden */
  80192. export enum ECullingType {
  80193. FRONT = 1028,
  80194. BACK = 1029,
  80195. FRONT_AND_BACK = 1032
  80196. }
  80197. /** @hidden */
  80198. export enum EBlendingFunction {
  80199. ZERO = 0,
  80200. ONE = 1,
  80201. SRC_COLOR = 768,
  80202. ONE_MINUS_SRC_COLOR = 769,
  80203. DST_COLOR = 774,
  80204. ONE_MINUS_DST_COLOR = 775,
  80205. SRC_ALPHA = 770,
  80206. ONE_MINUS_SRC_ALPHA = 771,
  80207. DST_ALPHA = 772,
  80208. ONE_MINUS_DST_ALPHA = 773,
  80209. CONSTANT_COLOR = 32769,
  80210. ONE_MINUS_CONSTANT_COLOR = 32770,
  80211. CONSTANT_ALPHA = 32771,
  80212. ONE_MINUS_CONSTANT_ALPHA = 32772,
  80213. SRC_ALPHA_SATURATE = 776
  80214. }
  80215. /** @hidden */
  80216. export interface IGLTFProperty {
  80217. extensions?: {
  80218. [key: string]: any;
  80219. };
  80220. extras?: Object;
  80221. }
  80222. /** @hidden */
  80223. export interface IGLTFChildRootProperty extends IGLTFProperty {
  80224. name?: string;
  80225. }
  80226. /** @hidden */
  80227. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  80228. bufferView: string;
  80229. byteOffset: number;
  80230. byteStride: number;
  80231. count: number;
  80232. type: string;
  80233. componentType: EComponentType;
  80234. max?: number[];
  80235. min?: number[];
  80236. name?: string;
  80237. }
  80238. /** @hidden */
  80239. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  80240. buffer: string;
  80241. byteOffset: number;
  80242. byteLength: number;
  80243. byteStride: number;
  80244. target?: number;
  80245. }
  80246. /** @hidden */
  80247. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  80248. uri: string;
  80249. byteLength?: number;
  80250. type?: string;
  80251. }
  80252. /** @hidden */
  80253. export interface IGLTFShader extends IGLTFChildRootProperty {
  80254. uri: string;
  80255. type: EShaderType;
  80256. }
  80257. /** @hidden */
  80258. export interface IGLTFProgram extends IGLTFChildRootProperty {
  80259. attributes: string[];
  80260. fragmentShader: string;
  80261. vertexShader: string;
  80262. }
  80263. /** @hidden */
  80264. export interface IGLTFTechniqueParameter {
  80265. type: number;
  80266. count?: number;
  80267. semantic?: string;
  80268. node?: string;
  80269. value?: number | boolean | string | Array<any>;
  80270. source?: string;
  80271. babylonValue?: any;
  80272. }
  80273. /** @hidden */
  80274. export interface IGLTFTechniqueCommonProfile {
  80275. lightingModel: string;
  80276. texcoordBindings: Object;
  80277. parameters?: Array<any>;
  80278. }
  80279. /** @hidden */
  80280. export interface IGLTFTechniqueStatesFunctions {
  80281. blendColor?: number[];
  80282. blendEquationSeparate?: number[];
  80283. blendFuncSeparate?: number[];
  80284. colorMask: boolean[];
  80285. cullFace: number[];
  80286. }
  80287. /** @hidden */
  80288. export interface IGLTFTechniqueStates {
  80289. enable: number[];
  80290. functions: IGLTFTechniqueStatesFunctions;
  80291. }
  80292. /** @hidden */
  80293. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  80294. parameters: {
  80295. [key: string]: IGLTFTechniqueParameter;
  80296. };
  80297. program: string;
  80298. attributes: {
  80299. [key: string]: string;
  80300. };
  80301. uniforms: {
  80302. [key: string]: string;
  80303. };
  80304. states: IGLTFTechniqueStates;
  80305. }
  80306. /** @hidden */
  80307. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  80308. technique?: string;
  80309. values: string[];
  80310. }
  80311. /** @hidden */
  80312. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  80313. attributes: {
  80314. [key: string]: string;
  80315. };
  80316. indices: string;
  80317. material: string;
  80318. mode?: number;
  80319. }
  80320. /** @hidden */
  80321. export interface IGLTFMesh extends IGLTFChildRootProperty {
  80322. primitives: IGLTFMeshPrimitive[];
  80323. }
  80324. /** @hidden */
  80325. export interface IGLTFImage extends IGLTFChildRootProperty {
  80326. uri: string;
  80327. }
  80328. /** @hidden */
  80329. export interface IGLTFSampler extends IGLTFChildRootProperty {
  80330. magFilter?: number;
  80331. minFilter?: number;
  80332. wrapS?: number;
  80333. wrapT?: number;
  80334. }
  80335. /** @hidden */
  80336. export interface IGLTFTexture extends IGLTFChildRootProperty {
  80337. sampler: string;
  80338. source: string;
  80339. format?: ETextureFormat;
  80340. internalFormat?: ETextureFormat;
  80341. target?: number;
  80342. type?: number;
  80343. babylonTexture?: Texture;
  80344. }
  80345. /** @hidden */
  80346. export interface IGLTFAmbienLight {
  80347. color?: number[];
  80348. }
  80349. /** @hidden */
  80350. export interface IGLTFDirectionalLight {
  80351. color?: number[];
  80352. }
  80353. /** @hidden */
  80354. export interface IGLTFPointLight {
  80355. color?: number[];
  80356. constantAttenuation?: number;
  80357. linearAttenuation?: number;
  80358. quadraticAttenuation?: number;
  80359. }
  80360. /** @hidden */
  80361. export interface IGLTFSpotLight {
  80362. color?: number[];
  80363. constantAttenuation?: number;
  80364. fallOfAngle?: number;
  80365. fallOffExponent?: number;
  80366. linearAttenuation?: number;
  80367. quadraticAttenuation?: number;
  80368. }
  80369. /** @hidden */
  80370. export interface IGLTFLight extends IGLTFChildRootProperty {
  80371. type: string;
  80372. }
  80373. /** @hidden */
  80374. export interface IGLTFCameraOrthographic {
  80375. xmag: number;
  80376. ymag: number;
  80377. zfar: number;
  80378. znear: number;
  80379. }
  80380. /** @hidden */
  80381. export interface IGLTFCameraPerspective {
  80382. aspectRatio: number;
  80383. yfov: number;
  80384. zfar: number;
  80385. znear: number;
  80386. }
  80387. /** @hidden */
  80388. export interface IGLTFCamera extends IGLTFChildRootProperty {
  80389. type: string;
  80390. }
  80391. /** @hidden */
  80392. export interface IGLTFAnimationChannelTarget {
  80393. id: string;
  80394. path: string;
  80395. }
  80396. /** @hidden */
  80397. export interface IGLTFAnimationChannel {
  80398. sampler: string;
  80399. target: IGLTFAnimationChannelTarget;
  80400. }
  80401. /** @hidden */
  80402. export interface IGLTFAnimationSampler {
  80403. input: string;
  80404. output: string;
  80405. interpolation?: string;
  80406. }
  80407. /** @hidden */
  80408. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  80409. channels?: IGLTFAnimationChannel[];
  80410. parameters?: {
  80411. [key: string]: string;
  80412. };
  80413. samplers?: {
  80414. [key: string]: IGLTFAnimationSampler;
  80415. };
  80416. }
  80417. /** @hidden */
  80418. export interface IGLTFNodeInstanceSkin {
  80419. skeletons: string[];
  80420. skin: string;
  80421. meshes: string[];
  80422. }
  80423. /** @hidden */
  80424. export interface IGLTFSkins extends IGLTFChildRootProperty {
  80425. bindShapeMatrix: number[];
  80426. inverseBindMatrices: string;
  80427. jointNames: string[];
  80428. babylonSkeleton?: Skeleton;
  80429. }
  80430. /** @hidden */
  80431. export interface IGLTFNode extends IGLTFChildRootProperty {
  80432. camera?: string;
  80433. children: string[];
  80434. skin?: string;
  80435. jointName?: string;
  80436. light?: string;
  80437. matrix: number[];
  80438. mesh?: string;
  80439. meshes?: string[];
  80440. rotation?: number[];
  80441. scale?: number[];
  80442. translation?: number[];
  80443. babylonNode?: Node;
  80444. }
  80445. /** @hidden */
  80446. export interface IGLTFScene extends IGLTFChildRootProperty {
  80447. nodes: string[];
  80448. }
  80449. /** @hidden */
  80450. export interface IGLTFRuntime {
  80451. extensions: {
  80452. [key: string]: any;
  80453. };
  80454. accessors: {
  80455. [key: string]: IGLTFAccessor;
  80456. };
  80457. buffers: {
  80458. [key: string]: IGLTFBuffer;
  80459. };
  80460. bufferViews: {
  80461. [key: string]: IGLTFBufferView;
  80462. };
  80463. meshes: {
  80464. [key: string]: IGLTFMesh;
  80465. };
  80466. lights: {
  80467. [key: string]: IGLTFLight;
  80468. };
  80469. cameras: {
  80470. [key: string]: IGLTFCamera;
  80471. };
  80472. nodes: {
  80473. [key: string]: IGLTFNode;
  80474. };
  80475. images: {
  80476. [key: string]: IGLTFImage;
  80477. };
  80478. textures: {
  80479. [key: string]: IGLTFTexture;
  80480. };
  80481. shaders: {
  80482. [key: string]: IGLTFShader;
  80483. };
  80484. programs: {
  80485. [key: string]: IGLTFProgram;
  80486. };
  80487. samplers: {
  80488. [key: string]: IGLTFSampler;
  80489. };
  80490. techniques: {
  80491. [key: string]: IGLTFTechnique;
  80492. };
  80493. materials: {
  80494. [key: string]: IGLTFMaterial;
  80495. };
  80496. animations: {
  80497. [key: string]: IGLTFAnimation;
  80498. };
  80499. skins: {
  80500. [key: string]: IGLTFSkins;
  80501. };
  80502. currentScene?: Object;
  80503. scenes: {
  80504. [key: string]: IGLTFScene;
  80505. };
  80506. extensionsUsed: string[];
  80507. extensionsRequired?: string[];
  80508. buffersCount: number;
  80509. shaderscount: number;
  80510. scene: Scene;
  80511. rootUrl: string;
  80512. loadedBufferCount: number;
  80513. loadedBufferViews: {
  80514. [name: string]: ArrayBufferView;
  80515. };
  80516. loadedShaderCount: number;
  80517. importOnlyMeshes: boolean;
  80518. importMeshesNames?: string[];
  80519. dummyNodes: Node[];
  80520. forAssetContainer: boolean;
  80521. }
  80522. /** @hidden */
  80523. export interface INodeToRoot {
  80524. bone: Bone;
  80525. node: IGLTFNode;
  80526. id: string;
  80527. }
  80528. /** @hidden */
  80529. export interface IJointNode {
  80530. node: IGLTFNode;
  80531. id: string;
  80532. }
  80533. }
  80534. declare module BABYLON.GLTF1 {
  80535. /**
  80536. * Utils functions for GLTF
  80537. * @hidden
  80538. */
  80539. export class GLTFUtils {
  80540. /**
  80541. * Sets the given "parameter" matrix
  80542. * @param scene: the Scene object
  80543. * @param source: the source node where to pick the matrix
  80544. * @param parameter: the GLTF technique parameter
  80545. * @param uniformName: the name of the shader's uniform
  80546. * @param shaderMaterial: the shader material
  80547. */
  80548. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  80549. /**
  80550. * Sets the given "parameter" matrix
  80551. * @param shaderMaterial: the shader material
  80552. * @param uniform: the name of the shader's uniform
  80553. * @param value: the value of the uniform
  80554. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  80555. */
  80556. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  80557. /**
  80558. * Returns the wrap mode of the texture
  80559. * @param mode: the mode value
  80560. */
  80561. static GetWrapMode(mode: number): number;
  80562. /**
  80563. * Returns the byte stride giving an accessor
  80564. * @param accessor: the GLTF accessor objet
  80565. */
  80566. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  80567. /**
  80568. * Returns the texture filter mode giving a mode value
  80569. * @param mode: the filter mode value
  80570. */
  80571. static GetTextureFilterMode(mode: number): ETextureFilterType;
  80572. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  80573. /**
  80574. * Returns a buffer from its accessor
  80575. * @param gltfRuntime: the GLTF runtime
  80576. * @param accessor: the GLTF accessor
  80577. */
  80578. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  80579. /**
  80580. * Decodes a buffer view into a string
  80581. * @param view: the buffer view
  80582. */
  80583. static DecodeBufferToText(view: ArrayBufferView): string;
  80584. /**
  80585. * Returns the default material of gltf. Related to
  80586. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  80587. * @param scene: the Babylon.js scene
  80588. */
  80589. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  80590. private static _DefaultMaterial;
  80591. }
  80592. }
  80593. declare module BABYLON.GLTF1 {
  80594. /**
  80595. * Implementation of the base glTF spec
  80596. * @hidden
  80597. */
  80598. export class GLTFLoaderBase {
  80599. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  80600. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  80601. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  80602. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  80603. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  80604. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  80605. }
  80606. /**
  80607. * glTF V1 Loader
  80608. * @hidden
  80609. */
  80610. export class GLTFLoader implements IGLTFLoader {
  80611. static Extensions: {
  80612. [name: string]: GLTFLoaderExtension;
  80613. };
  80614. static RegisterExtension(extension: GLTFLoaderExtension): void;
  80615. state: Nullable<GLTFLoaderState>;
  80616. dispose(): void;
  80617. private _importMeshAsync;
  80618. /**
  80619. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  80620. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  80621. * @param scene the scene the meshes should be added to
  80622. * @param forAssetContainer defines if the entities must be stored in the scene
  80623. * @param data gltf data containing information of the meshes in a loaded file
  80624. * @param rootUrl root url to load from
  80625. * @param onProgress event that fires when loading progress has occured
  80626. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  80627. */
  80628. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  80629. private _loadAsync;
  80630. /**
  80631. * Imports all objects from a loaded gltf file and adds them to the scene
  80632. * @param scene the scene the objects should be added to
  80633. * @param data gltf data containing information of the meshes in a loaded file
  80634. * @param rootUrl root url to load from
  80635. * @param onProgress event that fires when loading progress has occured
  80636. * @returns a promise which completes when objects have been loaded to the scene
  80637. */
  80638. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  80639. private _loadShadersAsync;
  80640. private _loadBuffersAsync;
  80641. private _createNodes;
  80642. }
  80643. /** @hidden */
  80644. export abstract class GLTFLoaderExtension {
  80645. private _name;
  80646. constructor(name: string);
  80647. get name(): string;
  80648. /**
  80649. * Defines an override for loading the runtime
  80650. * Return true to stop further extensions from loading the runtime
  80651. */
  80652. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  80653. /**
  80654. * Defines an onverride for creating gltf runtime
  80655. * Return true to stop further extensions from creating the runtime
  80656. */
  80657. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  80658. /**
  80659. * Defines an override for loading buffers
  80660. * Return true to stop further extensions from loading this buffer
  80661. */
  80662. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  80663. /**
  80664. * Defines an override for loading texture buffers
  80665. * Return true to stop further extensions from loading this texture data
  80666. */
  80667. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  80668. /**
  80669. * Defines an override for creating textures
  80670. * Return true to stop further extensions from loading this texture
  80671. */
  80672. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  80673. /**
  80674. * Defines an override for loading shader strings
  80675. * Return true to stop further extensions from loading this shader data
  80676. */
  80677. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  80678. /**
  80679. * Defines an override for loading materials
  80680. * Return true to stop further extensions from loading this material
  80681. */
  80682. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  80683. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  80684. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  80685. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  80686. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  80687. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  80688. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  80689. private static LoadTextureBufferAsync;
  80690. private static CreateTextureAsync;
  80691. private static ApplyExtensions;
  80692. }
  80693. }
  80694. declare module BABYLON.GLTF1 {
  80695. /** @hidden */
  80696. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  80697. private _bin;
  80698. constructor();
  80699. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  80700. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  80701. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  80702. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  80703. }
  80704. }
  80705. declare module BABYLON.GLTF1 {
  80706. /** @hidden */
  80707. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  80708. constructor();
  80709. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  80710. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  80711. private _loadTexture;
  80712. }
  80713. }
  80714. declare module BABYLON.GLTF2.Loader {
  80715. /**
  80716. * Loader interface with an index field.
  80717. */
  80718. export interface IArrayItem {
  80719. /**
  80720. * The index of this item in the array.
  80721. */
  80722. index: number;
  80723. }
  80724. /**
  80725. * Loader interface with additional members.
  80726. */
  80727. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  80728. /** @hidden */
  80729. _data?: Promise<ArrayBufferView>;
  80730. /** @hidden */
  80731. _babylonVertexBuffer?: Promise<VertexBuffer>;
  80732. }
  80733. /**
  80734. * Loader interface with additional members.
  80735. */
  80736. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  80737. }
  80738. /** @hidden */
  80739. export interface _IAnimationSamplerData {
  80740. input: Float32Array;
  80741. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  80742. output: Float32Array;
  80743. }
  80744. /**
  80745. * Loader interface with additional members.
  80746. */
  80747. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  80748. /** @hidden */
  80749. _data?: Promise<_IAnimationSamplerData>;
  80750. }
  80751. /**
  80752. * Loader interface with additional members.
  80753. */
  80754. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  80755. channels: IAnimationChannel[];
  80756. samplers: IAnimationSampler[];
  80757. /** @hidden */
  80758. _babylonAnimationGroup?: AnimationGroup;
  80759. }
  80760. /**
  80761. * Loader interface with additional members.
  80762. */
  80763. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  80764. /** @hidden */
  80765. _data?: Promise<ArrayBufferView>;
  80766. }
  80767. /**
  80768. * Loader interface with additional members.
  80769. */
  80770. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  80771. /** @hidden */
  80772. _data?: Promise<ArrayBufferView>;
  80773. /** @hidden */
  80774. _babylonBuffer?: Promise<Buffer>;
  80775. }
  80776. /**
  80777. * Loader interface with additional members.
  80778. */
  80779. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  80780. }
  80781. /**
  80782. * Loader interface with additional members.
  80783. */
  80784. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  80785. /** @hidden */
  80786. _data?: Promise<ArrayBufferView>;
  80787. }
  80788. /**
  80789. * Loader interface with additional members.
  80790. */
  80791. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  80792. }
  80793. /**
  80794. * Loader interface with additional members.
  80795. */
  80796. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  80797. }
  80798. /**
  80799. * Loader interface with additional members.
  80800. */
  80801. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  80802. baseColorTexture?: ITextureInfo;
  80803. metallicRoughnessTexture?: ITextureInfo;
  80804. }
  80805. /**
  80806. * Loader interface with additional members.
  80807. */
  80808. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  80809. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  80810. normalTexture?: IMaterialNormalTextureInfo;
  80811. occlusionTexture?: IMaterialOcclusionTextureInfo;
  80812. emissiveTexture?: ITextureInfo;
  80813. /** @hidden */
  80814. _data?: {
  80815. [babylonDrawMode: number]: {
  80816. babylonMaterial: Material;
  80817. babylonMeshes: AbstractMesh[];
  80818. promise: Promise<void>;
  80819. };
  80820. };
  80821. }
  80822. /**
  80823. * Loader interface with additional members.
  80824. */
  80825. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  80826. primitives: IMeshPrimitive[];
  80827. }
  80828. /**
  80829. * Loader interface with additional members.
  80830. */
  80831. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  80832. /** @hidden */
  80833. _instanceData?: {
  80834. babylonSourceMesh: Mesh;
  80835. promise: Promise<any>;
  80836. };
  80837. }
  80838. /**
  80839. * Loader interface with additional members.
  80840. */
  80841. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  80842. /**
  80843. * The parent glTF node.
  80844. */
  80845. parent?: INode;
  80846. /** @hidden */
  80847. _babylonTransformNode?: TransformNode;
  80848. /** @hidden */
  80849. _primitiveBabylonMeshes?: AbstractMesh[];
  80850. /** @hidden */
  80851. _babylonBones?: Bone[];
  80852. /** @hidden */
  80853. _numMorphTargets?: number;
  80854. }
  80855. /** @hidden */
  80856. export interface _ISamplerData {
  80857. noMipMaps: boolean;
  80858. samplingMode: number;
  80859. wrapU: number;
  80860. wrapV: number;
  80861. }
  80862. /**
  80863. * Loader interface with additional members.
  80864. */
  80865. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  80866. /** @hidden */
  80867. _data?: _ISamplerData;
  80868. }
  80869. /**
  80870. * Loader interface with additional members.
  80871. */
  80872. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  80873. }
  80874. /**
  80875. * Loader interface with additional members.
  80876. */
  80877. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  80878. /** @hidden */
  80879. _data?: {
  80880. babylonSkeleton: Skeleton;
  80881. promise: Promise<void>;
  80882. };
  80883. }
  80884. /**
  80885. * Loader interface with additional members.
  80886. */
  80887. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  80888. }
  80889. /**
  80890. * Loader interface with additional members.
  80891. */
  80892. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  80893. }
  80894. /**
  80895. * Loader interface with additional members.
  80896. */
  80897. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  80898. accessors?: IAccessor[];
  80899. animations?: IAnimation[];
  80900. buffers?: IBuffer[];
  80901. bufferViews?: IBufferView[];
  80902. cameras?: ICamera[];
  80903. images?: IImage[];
  80904. materials?: IMaterial[];
  80905. meshes?: IMesh[];
  80906. nodes?: INode[];
  80907. samplers?: ISampler[];
  80908. scenes?: IScene[];
  80909. skins?: ISkin[];
  80910. textures?: ITexture[];
  80911. }
  80912. }
  80913. declare module BABYLON.GLTF2 {
  80914. /**
  80915. * Interface for a glTF loader extension.
  80916. */
  80917. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  80918. /**
  80919. * Called after the loader state changes to LOADING.
  80920. */
  80921. onLoading?(): void;
  80922. /**
  80923. * Called after the loader state changes to READY.
  80924. */
  80925. onReady?(): void;
  80926. /**
  80927. * Define this method to modify the default behavior when loading scenes.
  80928. * @param context The context when loading the asset
  80929. * @param scene The glTF scene property
  80930. * @returns A promise that resolves when the load is complete or null if not handled
  80931. */
  80932. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  80933. /**
  80934. * Define this method to modify the default behavior when loading nodes.
  80935. * @param context The context when loading the asset
  80936. * @param node The glTF node property
  80937. * @param assign A function called synchronously after parsing the glTF properties
  80938. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  80939. */
  80940. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80941. /**
  80942. * Define this method to modify the default behavior when loading cameras.
  80943. * @param context The context when loading the asset
  80944. * @param camera The glTF camera property
  80945. * @param assign A function called synchronously after parsing the glTF properties
  80946. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  80947. */
  80948. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  80949. /**
  80950. * @hidden
  80951. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  80952. * @param context The context when loading the asset
  80953. * @param primitive The glTF mesh primitive property
  80954. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  80955. */
  80956. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  80957. /**
  80958. * @hidden
  80959. * Define this method to modify the default behavior when loading data for mesh primitives.
  80960. * @param context The context when loading the asset
  80961. * @param name The mesh name when loading the asset
  80962. * @param node The glTF node when loading the asset
  80963. * @param mesh The glTF mesh when loading the asset
  80964. * @param primitive The glTF mesh primitive property
  80965. * @param assign A function called synchronously after parsing the glTF properties
  80966. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  80967. */
  80968. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  80969. /**
  80970. * @hidden
  80971. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  80972. * @param context The context when loading the asset
  80973. * @param material The glTF material property
  80974. * @param assign A function called synchronously after parsing the glTF properties
  80975. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  80976. */
  80977. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  80978. /**
  80979. * Define this method to modify the default behavior when creating materials.
  80980. * @param context The context when loading the asset
  80981. * @param material The glTF material property
  80982. * @param babylonDrawMode The draw mode for the Babylon material
  80983. * @returns The Babylon material or null if not handled
  80984. */
  80985. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  80986. /**
  80987. * Define this method to modify the default behavior when loading material properties.
  80988. * @param context The context when loading the asset
  80989. * @param material The glTF material property
  80990. * @param babylonMaterial The Babylon material
  80991. * @returns A promise that resolves when the load is complete or null if not handled
  80992. */
  80993. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80994. /**
  80995. * Define this method to modify the default behavior when loading texture infos.
  80996. * @param context The context when loading the asset
  80997. * @param textureInfo The glTF texture info property
  80998. * @param assign A function called synchronously after parsing the glTF properties
  80999. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  81000. */
  81001. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81002. /**
  81003. * @hidden
  81004. * Define this method to modify the default behavior when loading textures.
  81005. * @param context The context when loading the asset
  81006. * @param texture The glTF texture property
  81007. * @param assign A function called synchronously after parsing the glTF properties
  81008. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  81009. */
  81010. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81011. /**
  81012. * Define this method to modify the default behavior when loading animations.
  81013. * @param context The context when loading the asset
  81014. * @param animation The glTF animation property
  81015. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  81016. */
  81017. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  81018. /**
  81019. * @hidden
  81020. * Define this method to modify the default behavior when loading skins.
  81021. * @param context The context when loading the asset
  81022. * @param node The glTF node property
  81023. * @param skin The glTF skin property
  81024. * @returns A promise that resolves when the load is complete or null if not handled
  81025. */
  81026. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  81027. /**
  81028. * @hidden
  81029. * Define this method to modify the default behavior when loading uris.
  81030. * @param context The context when loading the asset
  81031. * @param property The glTF property associated with the uri
  81032. * @param uri The uri to load
  81033. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  81034. */
  81035. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  81036. /**
  81037. * Define this method to modify the default behavior when loading buffer views.
  81038. * @param context The context when loading the asset
  81039. * @param bufferView The glTF buffer view property
  81040. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  81041. */
  81042. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  81043. /**
  81044. * Define this method to modify the default behavior when loading buffers.
  81045. * @param context The context when loading the asset
  81046. * @param buffer The glTF buffer property
  81047. * @param byteOffset The byte offset to load
  81048. * @param byteLength The byte length to load
  81049. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  81050. */
  81051. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  81052. }
  81053. }
  81054. declare module BABYLON.GLTF2 {
  81055. /**
  81056. * Helper class for working with arrays when loading the glTF asset
  81057. */
  81058. export class ArrayItem {
  81059. /**
  81060. * Gets an item from the given array.
  81061. * @param context The context when loading the asset
  81062. * @param array The array to get the item from
  81063. * @param index The index to the array
  81064. * @returns The array item
  81065. */
  81066. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  81067. /**
  81068. * Assign an `index` field to each item of the given array.
  81069. * @param array The array of items
  81070. */
  81071. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  81072. }
  81073. /**
  81074. * The glTF 2.0 loader
  81075. */
  81076. export class GLTFLoader implements IGLTFLoader {
  81077. /** @hidden */
  81078. _completePromises: Promise<any>[];
  81079. /** @hidden */
  81080. _forAssetContainer: boolean;
  81081. /** Storage */
  81082. _babylonLights: Light[];
  81083. /** @hidden */
  81084. _disableInstancedMesh: number;
  81085. private _disposed;
  81086. private _parent;
  81087. private _state;
  81088. private _extensions;
  81089. private _rootUrl;
  81090. private _fileName;
  81091. private _uniqueRootUrl;
  81092. private _gltf;
  81093. private _bin;
  81094. private _babylonScene;
  81095. private _rootBabylonMesh;
  81096. private _defaultBabylonMaterialData;
  81097. private static _RegisteredExtensions;
  81098. /**
  81099. * The default glTF sampler.
  81100. */
  81101. static readonly DefaultSampler: ISampler;
  81102. /**
  81103. * Registers a loader extension.
  81104. * @param name The name of the loader extension.
  81105. * @param factory The factory function that creates the loader extension.
  81106. */
  81107. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  81108. /**
  81109. * Unregisters a loader extension.
  81110. * @param name The name of the loader extension.
  81111. * @returns A boolean indicating whether the extension has been unregistered
  81112. */
  81113. static UnregisterExtension(name: string): boolean;
  81114. /**
  81115. * The loader state.
  81116. */
  81117. get state(): Nullable<GLTFLoaderState>;
  81118. /**
  81119. * The object that represents the glTF JSON.
  81120. */
  81121. get gltf(): IGLTF;
  81122. /**
  81123. * The BIN chunk of a binary glTF.
  81124. */
  81125. get bin(): Nullable<IDataBuffer>;
  81126. /**
  81127. * The parent file loader.
  81128. */
  81129. get parent(): GLTFFileLoader;
  81130. /**
  81131. * The Babylon scene when loading the asset.
  81132. */
  81133. get babylonScene(): Scene;
  81134. /**
  81135. * The root Babylon mesh when loading the asset.
  81136. */
  81137. get rootBabylonMesh(): Mesh;
  81138. /** @hidden */
  81139. constructor(parent: GLTFFileLoader);
  81140. /** @hidden */
  81141. dispose(): void;
  81142. /** @hidden */
  81143. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  81144. /** @hidden */
  81145. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81146. private _loadAsync;
  81147. private _loadData;
  81148. private _setupData;
  81149. private _loadExtensions;
  81150. private _checkExtensions;
  81151. private _setState;
  81152. private _createRootNode;
  81153. /**
  81154. * Loads a glTF scene.
  81155. * @param context The context when loading the asset
  81156. * @param scene The glTF scene property
  81157. * @returns A promise that resolves when the load is complete
  81158. */
  81159. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  81160. private _forEachPrimitive;
  81161. private _getMeshes;
  81162. private _getTransformNodes;
  81163. private _getSkeletons;
  81164. private _getAnimationGroups;
  81165. private _startAnimations;
  81166. /**
  81167. * Loads a glTF node.
  81168. * @param context The context when loading the asset
  81169. * @param node The glTF node property
  81170. * @param assign A function called synchronously after parsing the glTF properties
  81171. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  81172. */
  81173. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  81174. private _loadMeshAsync;
  81175. /**
  81176. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  81177. * @param context The context when loading the asset
  81178. * @param name The mesh name when loading the asset
  81179. * @param node The glTF node when loading the asset
  81180. * @param mesh The glTF mesh when loading the asset
  81181. * @param primitive The glTF mesh primitive property
  81182. * @param assign A function called synchronously after parsing the glTF properties
  81183. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  81184. */
  81185. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  81186. private _loadVertexDataAsync;
  81187. private _createMorphTargets;
  81188. private _loadMorphTargetsAsync;
  81189. private _loadMorphTargetVertexDataAsync;
  81190. private static _LoadTransform;
  81191. private _loadSkinAsync;
  81192. private _loadBones;
  81193. private _loadBone;
  81194. private _loadSkinInverseBindMatricesDataAsync;
  81195. private _updateBoneMatrices;
  81196. private _getNodeMatrix;
  81197. /**
  81198. * Loads a glTF camera.
  81199. * @param context The context when loading the asset
  81200. * @param camera The glTF camera property
  81201. * @param assign A function called synchronously after parsing the glTF properties
  81202. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  81203. */
  81204. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  81205. private _loadAnimationsAsync;
  81206. /**
  81207. * Loads a glTF animation.
  81208. * @param context The context when loading the asset
  81209. * @param animation The glTF animation property
  81210. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  81211. */
  81212. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  81213. /**
  81214. * @hidden Loads a glTF animation channel.
  81215. * @param context The context when loading the asset
  81216. * @param animationContext The context of the animation when loading the asset
  81217. * @param animation The glTF animation property
  81218. * @param channel The glTF animation channel property
  81219. * @param babylonAnimationGroup The babylon animation group property
  81220. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  81221. * @returns A void promise when the channel load is complete
  81222. */
  81223. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  81224. private _loadAnimationSamplerAsync;
  81225. private _loadBufferAsync;
  81226. /**
  81227. * Loads a glTF buffer view.
  81228. * @param context The context when loading the asset
  81229. * @param bufferView The glTF buffer view property
  81230. * @returns A promise that resolves with the loaded data when the load is complete
  81231. */
  81232. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  81233. private _loadAccessorAsync;
  81234. /** @hidden */
  81235. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  81236. private _loadIndicesAccessorAsync;
  81237. private _loadVertexBufferViewAsync;
  81238. private _loadVertexAccessorAsync;
  81239. private _loadMaterialMetallicRoughnessPropertiesAsync;
  81240. /** @hidden */
  81241. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  81242. private _createDefaultMaterial;
  81243. /**
  81244. * Creates a Babylon material from a glTF material.
  81245. * @param context The context when loading the asset
  81246. * @param material The glTF material property
  81247. * @param babylonDrawMode The draw mode for the Babylon material
  81248. * @returns The Babylon material
  81249. */
  81250. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  81251. /**
  81252. * Loads properties from a glTF material into a Babylon material.
  81253. * @param context The context when loading the asset
  81254. * @param material The glTF material property
  81255. * @param babylonMaterial The Babylon material
  81256. * @returns A promise that resolves when the load is complete
  81257. */
  81258. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  81259. /**
  81260. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  81261. * @param context The context when loading the asset
  81262. * @param material The glTF material property
  81263. * @param babylonMaterial The Babylon material
  81264. * @returns A promise that resolves when the load is complete
  81265. */
  81266. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  81267. /**
  81268. * Loads the alpha properties from a glTF material into a Babylon material.
  81269. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  81270. * @param context The context when loading the asset
  81271. * @param material The glTF material property
  81272. * @param babylonMaterial The Babylon material
  81273. */
  81274. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  81275. /**
  81276. * Loads a glTF texture info.
  81277. * @param context The context when loading the asset
  81278. * @param textureInfo The glTF texture info property
  81279. * @param assign A function called synchronously after parsing the glTF properties
  81280. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  81281. */
  81282. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  81283. /** @hidden */
  81284. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  81285. /** @hidden */
  81286. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  81287. private _loadSampler;
  81288. /**
  81289. * Loads a glTF image.
  81290. * @param context The context when loading the asset
  81291. * @param image The glTF image property
  81292. * @returns A promise that resolves with the loaded data when the load is complete
  81293. */
  81294. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  81295. /**
  81296. * Loads a glTF uri.
  81297. * @param context The context when loading the asset
  81298. * @param property The glTF property associated with the uri
  81299. * @param uri The base64 or relative uri
  81300. * @returns A promise that resolves with the loaded data when the load is complete
  81301. */
  81302. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  81303. /**
  81304. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  81305. * @param babylonObject the Babylon object with metadata
  81306. * @param pointer the JSON pointer
  81307. */
  81308. static AddPointerMetadata(babylonObject: {
  81309. metadata: any;
  81310. }, pointer: string): void;
  81311. private static _GetTextureWrapMode;
  81312. private static _GetTextureSamplingMode;
  81313. private static _GetTypedArrayConstructor;
  81314. private static _GetTypedArray;
  81315. private static _GetNumComponents;
  81316. private static _ValidateUri;
  81317. /** @hidden */
  81318. static _GetDrawMode(context: string, mode: number | undefined): number;
  81319. private _compileMaterialsAsync;
  81320. private _compileShadowGeneratorsAsync;
  81321. private _forEachExtensions;
  81322. private _applyExtensions;
  81323. private _extensionsOnLoading;
  81324. private _extensionsOnReady;
  81325. private _extensionsLoadSceneAsync;
  81326. private _extensionsLoadNodeAsync;
  81327. private _extensionsLoadCameraAsync;
  81328. private _extensionsLoadVertexDataAsync;
  81329. private _extensionsLoadMeshPrimitiveAsync;
  81330. private _extensionsLoadMaterialAsync;
  81331. private _extensionsCreateMaterial;
  81332. private _extensionsLoadMaterialPropertiesAsync;
  81333. private _extensionsLoadTextureInfoAsync;
  81334. private _extensionsLoadTextureAsync;
  81335. private _extensionsLoadAnimationAsync;
  81336. private _extensionsLoadSkinAsync;
  81337. private _extensionsLoadUriAsync;
  81338. private _extensionsLoadBufferViewAsync;
  81339. private _extensionsLoadBufferAsync;
  81340. /**
  81341. * Helper method called by a loader extension to load an glTF extension.
  81342. * @param context The context when loading the asset
  81343. * @param property The glTF property to load the extension from
  81344. * @param extensionName The name of the extension to load
  81345. * @param actionAsync The action to run
  81346. * @returns The promise returned by actionAsync or null if the extension does not exist
  81347. */
  81348. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  81349. /**
  81350. * Helper method called by a loader extension to load a glTF extra.
  81351. * @param context The context when loading the asset
  81352. * @param property The glTF property to load the extra from
  81353. * @param extensionName The name of the extension to load
  81354. * @param actionAsync The action to run
  81355. * @returns The promise returned by actionAsync or null if the extra does not exist
  81356. */
  81357. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  81358. /**
  81359. * Checks for presence of an extension.
  81360. * @param name The name of the extension to check
  81361. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  81362. */
  81363. isExtensionUsed(name: string): boolean;
  81364. /**
  81365. * Increments the indentation level and logs a message.
  81366. * @param message The message to log
  81367. */
  81368. logOpen(message: string): void;
  81369. /**
  81370. * Decrements the indentation level.
  81371. */
  81372. logClose(): void;
  81373. /**
  81374. * Logs a message
  81375. * @param message The message to log
  81376. */
  81377. log(message: string): void;
  81378. /**
  81379. * Starts a performance counter.
  81380. * @param counterName The name of the performance counter
  81381. */
  81382. startPerformanceCounter(counterName: string): void;
  81383. /**
  81384. * Ends a performance counter.
  81385. * @param counterName The name of the performance counter
  81386. */
  81387. endPerformanceCounter(counterName: string): void;
  81388. }
  81389. }
  81390. declare module BABYLON.GLTF2.Loader.Extensions {
  81391. /** @hidden */
  81392. interface IEXTLightsImageBased_LightImageBased {
  81393. _babylonTexture?: BaseTexture;
  81394. _loaded?: Promise<void>;
  81395. }
  81396. /**
  81397. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  81398. */
  81399. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  81400. /**
  81401. * The name of this extension.
  81402. */
  81403. readonly name: string;
  81404. /**
  81405. * Defines whether this extension is enabled.
  81406. */
  81407. enabled: boolean;
  81408. private _loader;
  81409. private _lights?;
  81410. /** @hidden */
  81411. constructor(loader: GLTFLoader);
  81412. /** @hidden */
  81413. dispose(): void;
  81414. /** @hidden */
  81415. onLoading(): void;
  81416. /** @hidden */
  81417. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  81418. private _loadLightAsync;
  81419. }
  81420. }
  81421. declare module BABYLON.GLTF2.Loader.Extensions {
  81422. /**
  81423. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  81424. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  81425. * !!! Experimental Extension Subject to Changes !!!
  81426. */
  81427. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  81428. /**
  81429. * The name of this extension.
  81430. */
  81431. readonly name: string;
  81432. /**
  81433. * Defines whether this extension is enabled.
  81434. */
  81435. enabled: boolean;
  81436. private _loader;
  81437. /** @hidden */
  81438. constructor(loader: GLTFLoader);
  81439. /** @hidden */
  81440. dispose(): void;
  81441. /** @hidden */
  81442. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81443. }
  81444. }
  81445. declare module BABYLON.GLTF2.Loader.Extensions {
  81446. /**
  81447. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  81448. */
  81449. export class EXT_texture_webp implements IGLTFLoaderExtension {
  81450. /** The name of this extension. */
  81451. readonly name: string;
  81452. /** Defines whether this extension is enabled. */
  81453. enabled: boolean;
  81454. private _loader;
  81455. /** @hidden */
  81456. constructor(loader: GLTFLoader);
  81457. /** @hidden */
  81458. dispose(): void;
  81459. /** @hidden */
  81460. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81461. }
  81462. }
  81463. declare module BABYLON.GLTF2.Loader.Extensions {
  81464. /**
  81465. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  81466. */
  81467. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  81468. /**
  81469. * The name of this extension.
  81470. */
  81471. readonly name: string;
  81472. /**
  81473. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  81474. */
  81475. dracoCompression?: DracoCompression;
  81476. /**
  81477. * Defines whether this extension is enabled.
  81478. */
  81479. enabled: boolean;
  81480. private _loader;
  81481. /** @hidden */
  81482. constructor(loader: GLTFLoader);
  81483. /** @hidden */
  81484. dispose(): void;
  81485. /** @hidden */
  81486. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  81487. }
  81488. }
  81489. declare module BABYLON.GLTF2.Loader.Extensions {
  81490. /**
  81491. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  81492. */
  81493. export class KHR_lights implements IGLTFLoaderExtension {
  81494. /**
  81495. * The name of this extension.
  81496. */
  81497. readonly name: string;
  81498. /**
  81499. * Defines whether this extension is enabled.
  81500. */
  81501. enabled: boolean;
  81502. private _loader;
  81503. private _lights?;
  81504. /** @hidden */
  81505. constructor(loader: GLTFLoader);
  81506. /** @hidden */
  81507. dispose(): void;
  81508. /** @hidden */
  81509. onLoading(): void;
  81510. /** @hidden */
  81511. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81512. }
  81513. }
  81514. declare module BABYLON.GLTF2.Loader.Extensions {
  81515. /**
  81516. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  81517. */
  81518. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  81519. /**
  81520. * The name of this extension.
  81521. */
  81522. readonly name: string;
  81523. /**
  81524. * Defines whether this extension is enabled.
  81525. */
  81526. enabled: boolean;
  81527. /**
  81528. * Defines a number that determines the order the extensions are applied.
  81529. */
  81530. order: number;
  81531. private _loader;
  81532. /** @hidden */
  81533. constructor(loader: GLTFLoader);
  81534. /** @hidden */
  81535. dispose(): void;
  81536. /** @hidden */
  81537. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81538. private _loadSpecularGlossinessPropertiesAsync;
  81539. }
  81540. }
  81541. declare module BABYLON.GLTF2.Loader.Extensions {
  81542. /**
  81543. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  81544. */
  81545. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  81546. /**
  81547. * The name of this extension.
  81548. */
  81549. readonly name: string;
  81550. /**
  81551. * Defines whether this extension is enabled.
  81552. */
  81553. enabled: boolean;
  81554. /**
  81555. * Defines a number that determines the order the extensions are applied.
  81556. */
  81557. order: number;
  81558. private _loader;
  81559. /** @hidden */
  81560. constructor(loader: GLTFLoader);
  81561. /** @hidden */
  81562. dispose(): void;
  81563. /** @hidden */
  81564. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81565. private _loadUnlitPropertiesAsync;
  81566. }
  81567. }
  81568. declare module BABYLON.GLTF2.Loader.Extensions {
  81569. /**
  81570. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  81571. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  81572. * !!! Experimental Extension Subject to Changes !!!
  81573. */
  81574. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  81575. /**
  81576. * The name of this extension.
  81577. */
  81578. readonly name: string;
  81579. /**
  81580. * Defines whether this extension is enabled.
  81581. */
  81582. enabled: boolean;
  81583. /**
  81584. * Defines a number that determines the order the extensions are applied.
  81585. */
  81586. order: number;
  81587. private _loader;
  81588. /** @hidden */
  81589. constructor(loader: GLTFLoader);
  81590. /** @hidden */
  81591. dispose(): void;
  81592. /** @hidden */
  81593. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81594. private _loadClearCoatPropertiesAsync;
  81595. }
  81596. }
  81597. declare module BABYLON.GLTF2.Loader.Extensions {
  81598. /**
  81599. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  81600. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  81601. * !!! Experimental Extension Subject to Changes !!!
  81602. */
  81603. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  81604. /**
  81605. * The name of this extension.
  81606. */
  81607. readonly name: string;
  81608. /**
  81609. * Defines whether this extension is enabled.
  81610. */
  81611. enabled: boolean;
  81612. /**
  81613. * Defines a number that determines the order the extensions are applied.
  81614. */
  81615. order: number;
  81616. private _loader;
  81617. /** @hidden */
  81618. constructor(loader: GLTFLoader);
  81619. /** @hidden */
  81620. dispose(): void;
  81621. /** @hidden */
  81622. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81623. private _loadSheenPropertiesAsync;
  81624. }
  81625. }
  81626. declare module BABYLON.GLTF2.Loader.Extensions {
  81627. /**
  81628. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  81629. * !!! Experimental Extension Subject to Changes !!!
  81630. */
  81631. export class KHR_materials_specular implements IGLTFLoaderExtension {
  81632. /**
  81633. * The name of this extension.
  81634. */
  81635. readonly name: string;
  81636. /**
  81637. * Defines whether this extension is enabled.
  81638. */
  81639. enabled: boolean;
  81640. /**
  81641. * Defines a number that determines the order the extensions are applied.
  81642. */
  81643. order: number;
  81644. private _loader;
  81645. /** @hidden */
  81646. constructor(loader: GLTFLoader);
  81647. /** @hidden */
  81648. dispose(): void;
  81649. /** @hidden */
  81650. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81651. private _loadSpecularPropertiesAsync;
  81652. }
  81653. }
  81654. declare module BABYLON.GLTF2.Loader.Extensions {
  81655. /**
  81656. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  81657. * !!! Experimental Extension Subject to Changes !!!
  81658. */
  81659. export class KHR_materials_ior implements IGLTFLoaderExtension {
  81660. /**
  81661. * Default ior Value from the spec.
  81662. */
  81663. private static readonly _DEFAULT_IOR;
  81664. /**
  81665. * The name of this extension.
  81666. */
  81667. readonly name: string;
  81668. /**
  81669. * Defines whether this extension is enabled.
  81670. */
  81671. enabled: boolean;
  81672. /**
  81673. * Defines a number that determines the order the extensions are applied.
  81674. */
  81675. order: number;
  81676. private _loader;
  81677. /** @hidden */
  81678. constructor(loader: GLTFLoader);
  81679. /** @hidden */
  81680. dispose(): void;
  81681. /** @hidden */
  81682. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81683. private _loadIorPropertiesAsync;
  81684. }
  81685. }
  81686. declare module BABYLON.GLTF2.Loader.Extensions {
  81687. /**
  81688. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  81689. * !!! Experimental Extension Subject to Changes !!!
  81690. */
  81691. export class KHR_materials_variants implements IGLTFLoaderExtension {
  81692. /**
  81693. * The name of this extension.
  81694. */
  81695. readonly name: string;
  81696. /**
  81697. * Defines whether this extension is enabled.
  81698. */
  81699. enabled: boolean;
  81700. private _loader;
  81701. /** @hidden */
  81702. constructor(loader: GLTFLoader);
  81703. /** @hidden */
  81704. dispose(): void;
  81705. /**
  81706. * Gets the list of available variant names for this asset.
  81707. * @param rootMesh The glTF root mesh
  81708. * @returns the list of all the variant names for this model
  81709. */
  81710. static GetAvailableVariants(rootMesh: Mesh): string[];
  81711. /**
  81712. * Gets the list of available variant names for this asset.
  81713. * @param rootMesh The glTF root mesh
  81714. * @returns the list of all the variant names for this model
  81715. */
  81716. getAvailableVariants(rootMesh: Mesh): string[];
  81717. /**
  81718. * Select a variant given a variant name or a list of variant names.
  81719. * @param rootMesh The glTF root mesh
  81720. * @param variantName The variant name(s) to select.
  81721. */
  81722. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  81723. /**
  81724. * Select a variant given a variant name or a list of variant names.
  81725. * @param rootMesh The glTF root mesh
  81726. * @param variantName The variant name(s) to select.
  81727. */
  81728. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  81729. /**
  81730. * Reset back to the original before selecting a variant.
  81731. * @param rootMesh The glTF root mesh
  81732. */
  81733. static Reset(rootMesh: Mesh): void;
  81734. /**
  81735. * Reset back to the original before selecting a variant.
  81736. * @param rootMesh The glTF root mesh
  81737. */
  81738. reset(rootMesh: Mesh): void;
  81739. /**
  81740. * Gets the last selected variant name(s) or null if original.
  81741. * @param rootMesh The glTF root mesh
  81742. * @returns The selected variant name(s).
  81743. */
  81744. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  81745. /**
  81746. * Gets the last selected variant name(s) or null if original.
  81747. * @param rootMesh The glTF root mesh
  81748. * @returns The selected variant name(s).
  81749. */
  81750. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  81751. private static _GetExtensionMetadata;
  81752. /** @hidden */
  81753. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  81754. }
  81755. }
  81756. declare module BABYLON.GLTF2.Loader.Extensions {
  81757. /**
  81758. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  81759. * !!! Experimental Extension Subject to Changes !!!
  81760. */
  81761. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  81762. /**
  81763. * The name of this extension.
  81764. */
  81765. readonly name: string;
  81766. /**
  81767. * Defines whether this extension is enabled.
  81768. */
  81769. enabled: boolean;
  81770. /**
  81771. * Defines a number that determines the order the extensions are applied.
  81772. */
  81773. order: number;
  81774. private _loader;
  81775. /** @hidden */
  81776. constructor(loader: GLTFLoader);
  81777. /** @hidden */
  81778. dispose(): void;
  81779. /** @hidden */
  81780. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81781. private _loadTransparentPropertiesAsync;
  81782. }
  81783. }
  81784. declare module BABYLON.GLTF2.Loader.Extensions {
  81785. /**
  81786. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  81787. */
  81788. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  81789. /**
  81790. * The name of this extension.
  81791. */
  81792. readonly name: string;
  81793. /**
  81794. * Defines whether this extension is enabled.
  81795. */
  81796. enabled: boolean;
  81797. /** @hidden */
  81798. constructor(loader: GLTFLoader);
  81799. /** @hidden */
  81800. dispose(): void;
  81801. }
  81802. }
  81803. declare module BABYLON.GLTF2.Loader.Extensions {
  81804. /**
  81805. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  81806. * !!! Experimental Extension Subject to Changes !!!
  81807. */
  81808. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  81809. /** The name of this extension. */
  81810. readonly name: string;
  81811. /** Defines whether this extension is enabled. */
  81812. enabled: boolean;
  81813. private _loader;
  81814. /** @hidden */
  81815. constructor(loader: GLTFLoader);
  81816. /** @hidden */
  81817. dispose(): void;
  81818. /** @hidden */
  81819. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81820. }
  81821. }
  81822. declare module BABYLON.GLTF2.Loader.Extensions {
  81823. /**
  81824. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  81825. */
  81826. export class KHR_texture_transform implements IGLTFLoaderExtension {
  81827. /**
  81828. * The name of this extension.
  81829. */
  81830. readonly name: string;
  81831. /**
  81832. * Defines whether this extension is enabled.
  81833. */
  81834. enabled: boolean;
  81835. private _loader;
  81836. /** @hidden */
  81837. constructor(loader: GLTFLoader);
  81838. /** @hidden */
  81839. dispose(): void;
  81840. /** @hidden */
  81841. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81842. }
  81843. }
  81844. declare module BABYLON.GLTF2.Loader.Extensions {
  81845. /**
  81846. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  81847. * !!! Experimental Extension Subject to Changes !!!
  81848. */
  81849. export class KHR_xmp implements IGLTFLoaderExtension {
  81850. /**
  81851. * The name of this extension.
  81852. */
  81853. readonly name: string;
  81854. /**
  81855. * Defines whether this extension is enabled.
  81856. */
  81857. enabled: boolean;
  81858. /**
  81859. * Defines a number that determines the order the extensions are applied.
  81860. */
  81861. order: number;
  81862. private _loader;
  81863. /** @hidden */
  81864. constructor(loader: GLTFLoader);
  81865. /** @hidden */
  81866. dispose(): void;
  81867. /**
  81868. * Called after the loader state changes to LOADING.
  81869. */
  81870. onLoading(): void;
  81871. }
  81872. }
  81873. declare module BABYLON.GLTF2.Loader.Extensions {
  81874. /**
  81875. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  81876. */
  81877. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  81878. /**
  81879. * The name of this extension.
  81880. */
  81881. readonly name: string;
  81882. /**
  81883. * Defines whether this extension is enabled.
  81884. */
  81885. enabled: boolean;
  81886. private _loader;
  81887. private _clips;
  81888. private _emitters;
  81889. /** @hidden */
  81890. constructor(loader: GLTFLoader);
  81891. /** @hidden */
  81892. dispose(): void;
  81893. /** @hidden */
  81894. onLoading(): void;
  81895. /** @hidden */
  81896. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  81897. /** @hidden */
  81898. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81899. /** @hidden */
  81900. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  81901. private _loadClipAsync;
  81902. private _loadEmitterAsync;
  81903. private _getEventAction;
  81904. private _loadAnimationEventAsync;
  81905. }
  81906. }
  81907. declare module BABYLON.GLTF2.Loader.Extensions {
  81908. /**
  81909. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  81910. */
  81911. export class MSFT_lod implements IGLTFLoaderExtension {
  81912. /**
  81913. * The name of this extension.
  81914. */
  81915. readonly name: string;
  81916. /**
  81917. * Defines whether this extension is enabled.
  81918. */
  81919. enabled: boolean;
  81920. /**
  81921. * Defines a number that determines the order the extensions are applied.
  81922. */
  81923. order: number;
  81924. /**
  81925. * Maximum number of LODs to load, starting from the lowest LOD.
  81926. */
  81927. maxLODsToLoad: number;
  81928. /**
  81929. * Observable raised when all node LODs of one level are loaded.
  81930. * The event data is the index of the loaded LOD starting from zero.
  81931. * Dispose the loader to cancel the loading of the next level of LODs.
  81932. */
  81933. onNodeLODsLoadedObservable: Observable<number>;
  81934. /**
  81935. * Observable raised when all material LODs of one level are loaded.
  81936. * The event data is the index of the loaded LOD starting from zero.
  81937. * Dispose the loader to cancel the loading of the next level of LODs.
  81938. */
  81939. onMaterialLODsLoadedObservable: Observable<number>;
  81940. private _loader;
  81941. private _bufferLODs;
  81942. private _nodeIndexLOD;
  81943. private _nodeSignalLODs;
  81944. private _nodePromiseLODs;
  81945. private _nodeBufferLODs;
  81946. private _materialIndexLOD;
  81947. private _materialSignalLODs;
  81948. private _materialPromiseLODs;
  81949. private _materialBufferLODs;
  81950. /** @hidden */
  81951. constructor(loader: GLTFLoader);
  81952. /** @hidden */
  81953. dispose(): void;
  81954. /** @hidden */
  81955. onReady(): void;
  81956. /** @hidden */
  81957. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  81958. /** @hidden */
  81959. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81960. /** @hidden */
  81961. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  81962. /** @hidden */
  81963. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  81964. /** @hidden */
  81965. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  81966. private _loadBufferLOD;
  81967. /**
  81968. * Gets an array of LOD properties from lowest to highest.
  81969. */
  81970. private _getLODs;
  81971. private _disposeTransformNode;
  81972. private _disposeMaterials;
  81973. }
  81974. }
  81975. declare module BABYLON.GLTF2.Loader.Extensions {
  81976. /** @hidden */
  81977. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  81978. readonly name: string;
  81979. enabled: boolean;
  81980. private _loader;
  81981. constructor(loader: GLTFLoader);
  81982. dispose(): void;
  81983. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81984. }
  81985. }
  81986. declare module BABYLON.GLTF2.Loader.Extensions {
  81987. /** @hidden */
  81988. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  81989. readonly name: string;
  81990. enabled: boolean;
  81991. private _loader;
  81992. constructor(loader: GLTFLoader);
  81993. dispose(): void;
  81994. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81995. }
  81996. }
  81997. declare module BABYLON.GLTF2.Loader.Extensions {
  81998. /**
  81999. * Store glTF extras (if present) in BJS objects' metadata
  82000. */
  82001. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  82002. /**
  82003. * The name of this extension.
  82004. */
  82005. readonly name: string;
  82006. /**
  82007. * Defines whether this extension is enabled.
  82008. */
  82009. enabled: boolean;
  82010. private _loader;
  82011. private _assignExtras;
  82012. /** @hidden */
  82013. constructor(loader: GLTFLoader);
  82014. /** @hidden */
  82015. dispose(): void;
  82016. /** @hidden */
  82017. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82018. /** @hidden */
  82019. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  82020. /** @hidden */
  82021. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  82022. }
  82023. }
  82024. declare module BABYLON {
  82025. /**
  82026. * Class reading and parsing the MTL file bundled with the obj file.
  82027. */
  82028. export class MTLFileLoader {
  82029. /**
  82030. * Invert Y-Axis of referenced textures on load
  82031. */
  82032. static INVERT_TEXTURE_Y: boolean;
  82033. /**
  82034. * All material loaded from the mtl will be set here
  82035. */
  82036. materials: StandardMaterial[];
  82037. /**
  82038. * This function will read the mtl file and create each material described inside
  82039. * This function could be improve by adding :
  82040. * -some component missing (Ni, Tf...)
  82041. * -including the specific options available
  82042. *
  82043. * @param scene defines the scene the material will be created in
  82044. * @param data defines the mtl data to parse
  82045. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  82046. * @param forAssetContainer defines if the material should be registered in the scene
  82047. */
  82048. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  82049. /**
  82050. * Gets the texture for the material.
  82051. *
  82052. * If the material is imported from input file,
  82053. * We sanitize the url to ensure it takes the textre from aside the material.
  82054. *
  82055. * @param rootUrl The root url to load from
  82056. * @param value The value stored in the mtl
  82057. * @return The Texture
  82058. */
  82059. private static _getTexture;
  82060. }
  82061. }
  82062. declare module BABYLON {
  82063. /**
  82064. * Options for loading OBJ/MTL files
  82065. */
  82066. type MeshLoadOptions = {
  82067. /**
  82068. * Defines if UVs are optimized by default during load.
  82069. */
  82070. OptimizeWithUV: boolean;
  82071. /**
  82072. * Defines custom scaling of UV coordinates of loaded meshes.
  82073. */
  82074. UVScaling: Vector2;
  82075. /**
  82076. * Invert model on y-axis (does a model scaling inversion)
  82077. */
  82078. InvertY: boolean;
  82079. /**
  82080. * Invert Y-Axis of referenced textures on load
  82081. */
  82082. InvertTextureY: boolean;
  82083. /**
  82084. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  82085. */
  82086. ImportVertexColors: boolean;
  82087. /**
  82088. * Compute the normals for the model, even if normals are present in the file.
  82089. */
  82090. ComputeNormals: boolean;
  82091. /**
  82092. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  82093. */
  82094. SkipMaterials: boolean;
  82095. /**
  82096. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  82097. */
  82098. MaterialLoadingFailsSilently: boolean;
  82099. };
  82100. /**
  82101. * OBJ file type loader.
  82102. * This is a babylon scene loader plugin.
  82103. */
  82104. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  82105. /**
  82106. * Defines if UVs are optimized by default during load.
  82107. */
  82108. static OPTIMIZE_WITH_UV: boolean;
  82109. /**
  82110. * Invert model on y-axis (does a model scaling inversion)
  82111. */
  82112. static INVERT_Y: boolean;
  82113. /**
  82114. * Invert Y-Axis of referenced textures on load
  82115. */
  82116. static get INVERT_TEXTURE_Y(): boolean;
  82117. static set INVERT_TEXTURE_Y(value: boolean);
  82118. /**
  82119. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  82120. */
  82121. static IMPORT_VERTEX_COLORS: boolean;
  82122. /**
  82123. * Compute the normals for the model, even if normals are present in the file.
  82124. */
  82125. static COMPUTE_NORMALS: boolean;
  82126. /**
  82127. * Defines custom scaling of UV coordinates of loaded meshes.
  82128. */
  82129. static UV_SCALING: Vector2;
  82130. /**
  82131. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  82132. */
  82133. static SKIP_MATERIALS: boolean;
  82134. /**
  82135. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  82136. *
  82137. * Defaults to true for backwards compatibility.
  82138. */
  82139. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  82140. /**
  82141. * Defines the name of the plugin.
  82142. */
  82143. name: string;
  82144. /**
  82145. * Defines the extension the plugin is able to load.
  82146. */
  82147. extensions: string;
  82148. /** @hidden */
  82149. obj: RegExp;
  82150. /** @hidden */
  82151. group: RegExp;
  82152. /** @hidden */
  82153. mtllib: RegExp;
  82154. /** @hidden */
  82155. usemtl: RegExp;
  82156. /** @hidden */
  82157. smooth: RegExp;
  82158. /** @hidden */
  82159. vertexPattern: RegExp;
  82160. /** @hidden */
  82161. normalPattern: RegExp;
  82162. /** @hidden */
  82163. uvPattern: RegExp;
  82164. /** @hidden */
  82165. facePattern1: RegExp;
  82166. /** @hidden */
  82167. facePattern2: RegExp;
  82168. /** @hidden */
  82169. facePattern3: RegExp;
  82170. /** @hidden */
  82171. facePattern4: RegExp;
  82172. /** @hidden */
  82173. facePattern5: RegExp;
  82174. private _forAssetContainer;
  82175. private _meshLoadOptions;
  82176. /**
  82177. * Creates loader for .OBJ files
  82178. *
  82179. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  82180. */
  82181. constructor(meshLoadOptions?: MeshLoadOptions);
  82182. private static get currentMeshLoadOptions();
  82183. /**
  82184. * Calls synchronously the MTL file attached to this obj.
  82185. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  82186. * Without this function materials are not displayed in the first frame (but displayed after).
  82187. * In consequence it is impossible to get material information in your HTML file
  82188. *
  82189. * @param url The URL of the MTL file
  82190. * @param rootUrl
  82191. * @param onSuccess Callback function to be called when the MTL file is loaded
  82192. * @private
  82193. */
  82194. private _loadMTL;
  82195. /**
  82196. * Instantiates a OBJ file loader plugin.
  82197. * @returns the created plugin
  82198. */
  82199. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  82200. /**
  82201. * If the data string can be loaded directly.
  82202. *
  82203. * @param data string containing the file data
  82204. * @returns if the data can be loaded directly
  82205. */
  82206. canDirectLoad(data: string): boolean;
  82207. /**
  82208. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  82209. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  82210. * @param scene the scene the meshes should be added to
  82211. * @param data the OBJ data to load
  82212. * @param rootUrl root url to load from
  82213. * @param onProgress event that fires when loading progress has occured
  82214. * @param fileName Defines the name of the file to load
  82215. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  82216. */
  82217. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  82218. meshes: AbstractMesh[];
  82219. particleSystems: IParticleSystem[];
  82220. skeletons: Skeleton[];
  82221. animationGroups: AnimationGroup[];
  82222. }>;
  82223. /**
  82224. * Imports all objects from the loaded OBJ data and adds them to the scene
  82225. * @param scene the scene the objects should be added to
  82226. * @param data the OBJ data to load
  82227. * @param rootUrl root url to load from
  82228. * @param onProgress event that fires when loading progress has occured
  82229. * @param fileName Defines the name of the file to load
  82230. * @returns a promise which completes when objects have been loaded to the scene
  82231. */
  82232. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82233. /**
  82234. * Load into an asset container.
  82235. * @param scene The scene to load into
  82236. * @param data The data to import
  82237. * @param rootUrl The root url for scene and resources
  82238. * @param onProgress The callback when the load progresses
  82239. * @param fileName Defines the name of the file to load
  82240. * @returns The loaded asset container
  82241. */
  82242. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  82243. /**
  82244. * Read the OBJ file and create an Array of meshes.
  82245. * Each mesh contains all information given by the OBJ and the MTL file.
  82246. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  82247. *
  82248. * @param meshesNames
  82249. * @param scene Scene The scene where are displayed the data
  82250. * @param data String The content of the obj file
  82251. * @param rootUrl String The path to the folder
  82252. * @returns Array<AbstractMesh>
  82253. * @private
  82254. */
  82255. private _parseSolid;
  82256. }
  82257. }
  82258. declare module BABYLON {
  82259. /**
  82260. * STL file type loader.
  82261. * This is a babylon scene loader plugin.
  82262. */
  82263. export class STLFileLoader implements ISceneLoaderPlugin {
  82264. /** @hidden */
  82265. solidPattern: RegExp;
  82266. /** @hidden */
  82267. facetsPattern: RegExp;
  82268. /** @hidden */
  82269. normalPattern: RegExp;
  82270. /** @hidden */
  82271. vertexPattern: RegExp;
  82272. /**
  82273. * Defines the name of the plugin.
  82274. */
  82275. name: string;
  82276. /**
  82277. * Defines the extensions the stl loader is able to load.
  82278. * force data to come in as an ArrayBuffer
  82279. * we'll convert to string if it looks like it's an ASCII .stl
  82280. */
  82281. extensions: ISceneLoaderPluginExtensions;
  82282. /**
  82283. * Import meshes into a scene.
  82284. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  82285. * @param scene The scene to import into
  82286. * @param data The data to import
  82287. * @param rootUrl The root url for scene and resources
  82288. * @param meshes The meshes array to import into
  82289. * @param particleSystems The particle systems array to import into
  82290. * @param skeletons The skeletons array to import into
  82291. * @param onError The callback when import fails
  82292. * @returns True if successful or false otherwise
  82293. */
  82294. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  82295. /**
  82296. * Load into a scene.
  82297. * @param scene The scene to load into
  82298. * @param data The data to import
  82299. * @param rootUrl The root url for scene and resources
  82300. * @param onError The callback when import fails
  82301. * @returns true if successful or false otherwise
  82302. */
  82303. load(scene: Scene, data: any, rootUrl: string): boolean;
  82304. /**
  82305. * Load into an asset container.
  82306. * @param scene The scene to load into
  82307. * @param data The data to import
  82308. * @param rootUrl The root url for scene and resources
  82309. * @param onError The callback when import fails
  82310. * @returns The loaded asset container
  82311. */
  82312. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  82313. private _isBinary;
  82314. private _parseBinary;
  82315. private _parseASCII;
  82316. }
  82317. }
  82318. declare module BABYLON {
  82319. /**
  82320. * Class for generating OBJ data from a Babylon scene.
  82321. */
  82322. export class OBJExport {
  82323. /**
  82324. * Exports the geometry of a Mesh array in .OBJ file format (text)
  82325. * @param mesh defines the list of meshes to serialize
  82326. * @param materials defines if materials should be exported
  82327. * @param matlibname defines the name of the associated mtl file
  82328. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  82329. * @returns the OBJ content
  82330. */
  82331. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  82332. /**
  82333. * Exports the material(s) of a mesh in .MTL file format (text)
  82334. * @param mesh defines the mesh to extract the material from
  82335. * @returns the mtl content
  82336. */
  82337. static MTL(mesh: Mesh): string;
  82338. }
  82339. }
  82340. declare module BABYLON {
  82341. /** @hidden */
  82342. export var __IGLTFExporterExtension: number;
  82343. /**
  82344. * Interface for extending the exporter
  82345. * @hidden
  82346. */
  82347. export interface IGLTFExporterExtension {
  82348. /**
  82349. * The name of this extension
  82350. */
  82351. readonly name: string;
  82352. /**
  82353. * Defines whether this extension is enabled
  82354. */
  82355. enabled: boolean;
  82356. /**
  82357. * Defines whether this extension is required
  82358. */
  82359. required: boolean;
  82360. }
  82361. }
  82362. declare module BABYLON.GLTF2.Exporter {
  82363. /** @hidden */
  82364. export var __IGLTFExporterExtensionV2: number;
  82365. /**
  82366. * Interface for a glTF exporter extension
  82367. * @hidden
  82368. */
  82369. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  82370. /**
  82371. * Define this method to modify the default behavior before exporting a texture
  82372. * @param context The context when loading the asset
  82373. * @param babylonTexture The Babylon.js texture
  82374. * @param mimeType The mime-type of the generated image
  82375. * @returns A promise that resolves with the exported texture
  82376. */
  82377. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  82378. /**
  82379. * Define this method to get notified when a texture info is created
  82380. * @param context The context when loading the asset
  82381. * @param textureInfo The glTF texture info
  82382. * @param babylonTexture The Babylon.js texture
  82383. */
  82384. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  82385. /**
  82386. * Define this method to modify the default behavior when exporting texture info
  82387. * @param context The context when loading the asset
  82388. * @param meshPrimitive glTF mesh primitive
  82389. * @param babylonSubMesh Babylon submesh
  82390. * @param binaryWriter glTF serializer binary writer instance
  82391. * @returns nullable IMeshPrimitive promise
  82392. */
  82393. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  82394. /**
  82395. * Define this method to modify the default behavior when exporting a node
  82396. * @param context The context when exporting the node
  82397. * @param node glTF node
  82398. * @param babylonNode BabylonJS node
  82399. * @returns nullable INode promise
  82400. */
  82401. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  82402. [key: number]: number;
  82403. }): Promise<Nullable<INode>>;
  82404. /**
  82405. * Define this method to modify the default behavior when exporting a material
  82406. * @param material glTF material
  82407. * @param babylonMaterial BabylonJS material
  82408. * @returns nullable IMaterial promise
  82409. */
  82410. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  82411. /**
  82412. * Define this method to return additional textures to export from a material
  82413. * @param material glTF material
  82414. * @param babylonMaterial BabylonJS material
  82415. * @returns List of textures
  82416. */
  82417. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  82418. /** Gets a boolean indicating that this extension was used */
  82419. wasUsed: boolean;
  82420. /** Gets a boolean indicating that this extension is required for the file to work */
  82421. required: boolean;
  82422. /**
  82423. * Called after the exporter state changes to EXPORTING
  82424. */
  82425. onExporting?(): void;
  82426. }
  82427. }
  82428. declare module BABYLON.GLTF2.Exporter {
  82429. /**
  82430. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  82431. * @hidden
  82432. */
  82433. export class _GLTFMaterialExporter {
  82434. /**
  82435. * Represents the dielectric specular values for R, G and B
  82436. */
  82437. private static readonly _DielectricSpecular;
  82438. /**
  82439. * Allows the maximum specular power to be defined for material calculations
  82440. */
  82441. private static readonly _MaxSpecularPower;
  82442. /**
  82443. * Mapping to store textures
  82444. */
  82445. private _textureMap;
  82446. /**
  82447. * Numeric tolerance value
  82448. */
  82449. private static readonly _Epsilon;
  82450. /**
  82451. * Reference to the glTF Exporter
  82452. */
  82453. private _exporter;
  82454. constructor(exporter: _Exporter);
  82455. /**
  82456. * Specifies if two colors are approximately equal in value
  82457. * @param color1 first color to compare to
  82458. * @param color2 second color to compare to
  82459. * @param epsilon threshold value
  82460. */
  82461. private static FuzzyEquals;
  82462. /**
  82463. * Gets the materials from a Babylon scene and converts them to glTF materials
  82464. * @param scene babylonjs scene
  82465. * @param mimeType texture mime type
  82466. * @param images array of images
  82467. * @param textures array of textures
  82468. * @param materials array of materials
  82469. * @param imageData mapping of texture names to base64 textures
  82470. * @param hasTextureCoords specifies if texture coordinates are present on the material
  82471. */
  82472. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  82473. /**
  82474. * Makes a copy of the glTF material without the texture parameters
  82475. * @param originalMaterial original glTF material
  82476. * @returns glTF material without texture parameters
  82477. */
  82478. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  82479. /**
  82480. * Specifies if the material has any texture parameters present
  82481. * @param material glTF Material
  82482. * @returns boolean specifying if texture parameters are present
  82483. */
  82484. _hasTexturesPresent(material: IMaterial): boolean;
  82485. /**
  82486. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  82487. * @param babylonStandardMaterial
  82488. * @returns glTF Metallic Roughness Material representation
  82489. */
  82490. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  82491. /**
  82492. * Computes the metallic factor
  82493. * @param diffuse diffused value
  82494. * @param specular specular value
  82495. * @param oneMinusSpecularStrength one minus the specular strength
  82496. * @returns metallic value
  82497. */
  82498. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  82499. /**
  82500. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  82501. * @param glTFMaterial glTF material
  82502. * @param babylonMaterial Babylon material
  82503. */
  82504. private static _SetAlphaMode;
  82505. /**
  82506. * Converts a Babylon Standard Material to a glTF Material
  82507. * @param babylonStandardMaterial BJS Standard Material
  82508. * @param mimeType mime type to use for the textures
  82509. * @param images array of glTF image interfaces
  82510. * @param textures array of glTF texture interfaces
  82511. * @param materials array of glTF material interfaces
  82512. * @param imageData map of image file name to data
  82513. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82514. */
  82515. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  82516. private _finishMaterial;
  82517. /**
  82518. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  82519. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  82520. * @param mimeType mime type to use for the textures
  82521. * @param images array of glTF image interfaces
  82522. * @param textures array of glTF texture interfaces
  82523. * @param materials array of glTF material interfaces
  82524. * @param imageData map of image file name to data
  82525. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82526. */
  82527. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  82528. /**
  82529. * Converts an image typed array buffer to a base64 image
  82530. * @param buffer typed array buffer
  82531. * @param width width of the image
  82532. * @param height height of the image
  82533. * @param mimeType mimetype of the image
  82534. * @returns base64 image string
  82535. */
  82536. private _createBase64FromCanvasAsync;
  82537. /**
  82538. * Generates a white texture based on the specified width and height
  82539. * @param width width of the texture in pixels
  82540. * @param height height of the texture in pixels
  82541. * @param scene babylonjs scene
  82542. * @returns white texture
  82543. */
  82544. private _createWhiteTexture;
  82545. /**
  82546. * 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
  82547. * @param texture1 first texture to resize
  82548. * @param texture2 second texture to resize
  82549. * @param scene babylonjs scene
  82550. * @returns resized textures or null
  82551. */
  82552. private _resizeTexturesToSameDimensions;
  82553. /**
  82554. * Converts an array of pixels to a Float32Array
  82555. * Throws an error if the pixel format is not supported
  82556. * @param pixels - array buffer containing pixel values
  82557. * @returns Float32 of pixels
  82558. */
  82559. private _convertPixelArrayToFloat32;
  82560. /**
  82561. * Convert Specular Glossiness Textures to Metallic Roughness
  82562. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  82563. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  82564. * @param diffuseTexture texture used to store diffuse information
  82565. * @param specularGlossinessTexture texture used to store specular and glossiness information
  82566. * @param factors specular glossiness material factors
  82567. * @param mimeType the mime type to use for the texture
  82568. * @returns pbr metallic roughness interface or null
  82569. */
  82570. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  82571. /**
  82572. * Converts specular glossiness material properties to metallic roughness
  82573. * @param specularGlossiness interface with specular glossiness material properties
  82574. * @returns interface with metallic roughness material properties
  82575. */
  82576. private _convertSpecularGlossinessToMetallicRoughness;
  82577. /**
  82578. * Calculates the surface reflectance, independent of lighting conditions
  82579. * @param color Color source to calculate brightness from
  82580. * @returns number representing the perceived brightness, or zero if color is undefined
  82581. */
  82582. private _getPerceivedBrightness;
  82583. /**
  82584. * Returns the maximum color component value
  82585. * @param color
  82586. * @returns maximum color component value, or zero if color is null or undefined
  82587. */
  82588. private _getMaxComponent;
  82589. /**
  82590. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  82591. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  82592. * @param mimeType mime type to use for the textures
  82593. * @param images array of glTF image interfaces
  82594. * @param textures array of glTF texture interfaces
  82595. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  82596. * @param imageData map of image file name to data
  82597. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82598. * @returns glTF PBR Metallic Roughness factors
  82599. */
  82600. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  82601. private _getGLTFTextureSampler;
  82602. private _getGLTFTextureWrapMode;
  82603. private _getGLTFTextureWrapModesSampler;
  82604. /**
  82605. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  82606. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  82607. * @param mimeType mime type to use for the textures
  82608. * @param images array of glTF image interfaces
  82609. * @param textures array of glTF texture interfaces
  82610. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  82611. * @param imageData map of image file name to data
  82612. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82613. * @returns glTF PBR Metallic Roughness factors
  82614. */
  82615. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  82616. /**
  82617. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  82618. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  82619. * @param mimeType mime type to use for the textures
  82620. * @param images array of glTF image interfaces
  82621. * @param textures array of glTF texture interfaces
  82622. * @param materials array of glTF material interfaces
  82623. * @param imageData map of image file name to data
  82624. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82625. */
  82626. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  82627. private setMetallicRoughnessPbrMaterial;
  82628. private getPixelsFromTexture;
  82629. /**
  82630. * Extracts a texture from a Babylon texture into file data and glTF data
  82631. * @param babylonTexture Babylon texture to extract
  82632. * @param mimeType Mime Type of the babylonTexture
  82633. * @return glTF texture info, or null if the texture format is not supported
  82634. */
  82635. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  82636. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  82637. /**
  82638. * Builds a texture from base64 string
  82639. * @param base64Texture base64 texture string
  82640. * @param baseTextureName Name to use for the texture
  82641. * @param mimeType image mime type for the texture
  82642. * @param images array of images
  82643. * @param textures array of textures
  82644. * @param imageData map of image data
  82645. * @returns glTF texture info, or null if the texture format is not supported
  82646. */
  82647. private _getTextureInfoFromBase64;
  82648. }
  82649. }
  82650. declare module BABYLON {
  82651. /**
  82652. * Class for holding and downloading glTF file data
  82653. */
  82654. export class GLTFData {
  82655. /**
  82656. * Object which contains the file name as the key and its data as the value
  82657. */
  82658. glTFFiles: {
  82659. [fileName: string]: string | Blob;
  82660. };
  82661. /**
  82662. * Initializes the glTF file object
  82663. */
  82664. constructor();
  82665. /**
  82666. * Downloads the glTF data as files based on their names and data
  82667. */
  82668. downloadFiles(): void;
  82669. }
  82670. }
  82671. declare module BABYLON {
  82672. /**
  82673. * Holds a collection of exporter options and parameters
  82674. */
  82675. export interface IExportOptions {
  82676. /**
  82677. * Function which indicates whether a babylon node should be exported or not
  82678. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  82679. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  82680. */
  82681. shouldExportNode?(node: Node): boolean;
  82682. /**
  82683. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  82684. * @param metadata source metadata to read from
  82685. * @returns the data to store to glTF node extras
  82686. */
  82687. metadataSelector?(metadata: any): any;
  82688. /**
  82689. * The sample rate to bake animation curves
  82690. */
  82691. animationSampleRate?: number;
  82692. /**
  82693. * Begin serialization without waiting for the scene to be ready
  82694. */
  82695. exportWithoutWaitingForScene?: boolean;
  82696. /**
  82697. * Indicates if coordinate system swapping root nodes should be included in export
  82698. */
  82699. includeCoordinateSystemConversionNodes?: boolean;
  82700. }
  82701. /**
  82702. * Class for generating glTF data from a Babylon scene.
  82703. */
  82704. export class GLTF2Export {
  82705. /**
  82706. * Exports the geometry of the scene to .gltf file format asynchronously
  82707. * @param scene Babylon scene with scene hierarchy information
  82708. * @param filePrefix File prefix to use when generating the glTF file
  82709. * @param options Exporter options
  82710. * @returns Returns an object with a .gltf file and associates texture names
  82711. * as keys and their data and paths as values
  82712. */
  82713. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  82714. private static _PreExportAsync;
  82715. private static _PostExportAsync;
  82716. /**
  82717. * Exports the geometry of the scene to .glb file format asychronously
  82718. * @param scene Babylon scene with scene hierarchy information
  82719. * @param filePrefix File prefix to use when generating glb file
  82720. * @param options Exporter options
  82721. * @returns Returns an object with a .glb filename as key and data as value
  82722. */
  82723. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  82724. }
  82725. }
  82726. declare module BABYLON.GLTF2.Exporter {
  82727. /**
  82728. * @hidden
  82729. */
  82730. export class _GLTFUtilities {
  82731. /**
  82732. * Creates a buffer view based on the supplied arguments
  82733. * @param bufferIndex index value of the specified buffer
  82734. * @param byteOffset byte offset value
  82735. * @param byteLength byte length of the bufferView
  82736. * @param byteStride byte distance between conequential elements
  82737. * @param name name of the buffer view
  82738. * @returns bufferView for glTF
  82739. */
  82740. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  82741. /**
  82742. * Creates an accessor based on the supplied arguments
  82743. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  82744. * @param name The name of the accessor
  82745. * @param type The type of the accessor
  82746. * @param componentType The datatype of components in the attribute
  82747. * @param count The number of attributes referenced by this accessor
  82748. * @param byteOffset The offset relative to the start of the bufferView in bytes
  82749. * @param min Minimum value of each component in this attribute
  82750. * @param max Maximum value of each component in this attribute
  82751. * @returns accessor for glTF
  82752. */
  82753. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  82754. /**
  82755. * Calculates the minimum and maximum values of an array of position floats
  82756. * @param positions Positions array of a mesh
  82757. * @param vertexStart Starting vertex offset to calculate min and max values
  82758. * @param vertexCount Number of vertices to check for min and max values
  82759. * @returns min number array and max number array
  82760. */
  82761. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  82762. min: number[];
  82763. max: number[];
  82764. };
  82765. /**
  82766. * Converts a new right-handed Vector3
  82767. * @param vector vector3 array
  82768. * @returns right-handed Vector3
  82769. */
  82770. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  82771. /**
  82772. * Converts a Vector3 to right-handed
  82773. * @param vector Vector3 to convert to right-handed
  82774. */
  82775. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  82776. /**
  82777. * Converts a three element number array to right-handed
  82778. * @param vector number array to convert to right-handed
  82779. */
  82780. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  82781. /**
  82782. * Converts a new right-handed Vector3
  82783. * @param vector vector3 array
  82784. * @returns right-handed Vector3
  82785. */
  82786. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  82787. /**
  82788. * Converts a Vector3 to right-handed
  82789. * @param vector Vector3 to convert to right-handed
  82790. */
  82791. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  82792. /**
  82793. * Converts a three element number array to right-handed
  82794. * @param vector number array to convert to right-handed
  82795. */
  82796. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  82797. /**
  82798. * Converts a Vector4 to right-handed
  82799. * @param vector Vector4 to convert to right-handed
  82800. */
  82801. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  82802. /**
  82803. * Converts a Vector4 to right-handed
  82804. * @param vector Vector4 to convert to right-handed
  82805. */
  82806. static _GetRightHandedArray4FromRef(vector: number[]): void;
  82807. /**
  82808. * Converts a Quaternion to right-handed
  82809. * @param quaternion Source quaternion to convert to right-handed
  82810. */
  82811. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  82812. /**
  82813. * Converts a Quaternion to right-handed
  82814. * @param quaternion Source quaternion to convert to right-handed
  82815. */
  82816. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  82817. static _NormalizeTangentFromRef(tangent: Vector4): void;
  82818. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  82819. }
  82820. }
  82821. declare module BABYLON.GLTF2.Exporter {
  82822. /**
  82823. * Converts Babylon Scene into glTF 2.0.
  82824. * @hidden
  82825. */
  82826. export class _Exporter {
  82827. /**
  82828. * Stores the glTF to export
  82829. */
  82830. _glTF: IGLTF;
  82831. /**
  82832. * Stores all generated buffer views, which represents views into the main glTF buffer data
  82833. */
  82834. _bufferViews: IBufferView[];
  82835. /**
  82836. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  82837. */
  82838. _accessors: IAccessor[];
  82839. /**
  82840. * Stores all the generated nodes, which contains transform and/or mesh information per node
  82841. */
  82842. _nodes: INode[];
  82843. /**
  82844. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  82845. */
  82846. private _scenes;
  82847. /**
  82848. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  82849. */
  82850. private _meshes;
  82851. /**
  82852. * Stores all the generated material information, which represents the appearance of each primitive
  82853. */
  82854. _materials: IMaterial[];
  82855. _materialMap: {
  82856. [materialID: number]: number;
  82857. };
  82858. /**
  82859. * Stores all the generated texture information, which is referenced by glTF materials
  82860. */
  82861. _textures: ITexture[];
  82862. /**
  82863. * Stores all the generated image information, which is referenced by glTF textures
  82864. */
  82865. _images: IImage[];
  82866. /**
  82867. * Stores all the texture samplers
  82868. */
  82869. _samplers: ISampler[];
  82870. /**
  82871. * Stores all the generated glTF skins
  82872. */
  82873. _skins: ISkin[];
  82874. /**
  82875. * Stores all the generated animation samplers, which is referenced by glTF animations
  82876. */
  82877. /**
  82878. * Stores the animations for glTF models
  82879. */
  82880. private _animations;
  82881. /**
  82882. * Stores the total amount of bytes stored in the glTF buffer
  82883. */
  82884. private _totalByteLength;
  82885. /**
  82886. * Stores a reference to the Babylon scene containing the source geometry and material information
  82887. */
  82888. _babylonScene: Scene;
  82889. /**
  82890. * Stores a map of the image data, where the key is the file name and the value
  82891. * is the image data
  82892. */
  82893. _imageData: {
  82894. [fileName: string]: {
  82895. data: Uint8Array;
  82896. mimeType: ImageMimeType;
  82897. };
  82898. };
  82899. /**
  82900. * Stores a map of the unique id of a node to its index in the node array
  82901. */
  82902. _nodeMap: {
  82903. [key: number]: number;
  82904. };
  82905. /**
  82906. * Specifies if the source Babylon scene was left handed, and needed conversion.
  82907. */
  82908. _convertToRightHandedSystem: boolean;
  82909. /**
  82910. * Specifies if a Babylon node should be converted to right-handed on export
  82911. */
  82912. _convertToRightHandedSystemMap: {
  82913. [nodeId: number]: boolean;
  82914. };
  82915. _includeCoordinateSystemConversionNodes: boolean;
  82916. /**
  82917. * Baked animation sample rate
  82918. */
  82919. private _animationSampleRate;
  82920. private _options;
  82921. private _localEngine;
  82922. _glTFMaterialExporter: _GLTFMaterialExporter;
  82923. private _extensions;
  82924. private static _ExtensionNames;
  82925. private static _ExtensionFactories;
  82926. private _applyExtension;
  82927. private _applyExtensions;
  82928. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  82929. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  82930. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  82931. [key: number]: number;
  82932. }): Promise<Nullable<INode>>;
  82933. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  82934. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  82935. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  82936. private _forEachExtensions;
  82937. private _extensionsOnExporting;
  82938. /**
  82939. * Load glTF serializer extensions
  82940. */
  82941. private _loadExtensions;
  82942. /**
  82943. * Creates a glTF Exporter instance, which can accept optional exporter options
  82944. * @param babylonScene Babylon scene object
  82945. * @param options Options to modify the behavior of the exporter
  82946. */
  82947. constructor(babylonScene: Scene, options?: IExportOptions);
  82948. dispose(): void;
  82949. /**
  82950. * Registers a glTF exporter extension
  82951. * @param name Name of the extension to export
  82952. * @param factory The factory function that creates the exporter extension
  82953. */
  82954. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  82955. /**
  82956. * Un-registers an exporter extension
  82957. * @param name The name fo the exporter extension
  82958. * @returns A boolean indicating whether the extension has been un-registered
  82959. */
  82960. static UnregisterExtension(name: string): boolean;
  82961. /**
  82962. * Lazy load a local engine
  82963. */
  82964. _getLocalEngine(): Engine;
  82965. private reorderIndicesBasedOnPrimitiveMode;
  82966. /**
  82967. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  82968. * clock-wise during export to glTF
  82969. * @param submesh BabylonJS submesh
  82970. * @param primitiveMode Primitive mode of the mesh
  82971. * @param sideOrientation the winding order of the submesh
  82972. * @param vertexBufferKind The type of vertex attribute
  82973. * @param meshAttributeArray The vertex attribute data
  82974. * @param byteOffset The offset to the binary data
  82975. * @param binaryWriter The binary data for the glTF file
  82976. * @param convertToRightHandedSystem Converts the values to right-handed
  82977. */
  82978. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  82979. /**
  82980. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  82981. * clock-wise during export to glTF
  82982. * @param submesh BabylonJS submesh
  82983. * @param primitiveMode Primitive mode of the mesh
  82984. * @param sideOrientation the winding order of the submesh
  82985. * @param vertexBufferKind The type of vertex attribute
  82986. * @param meshAttributeArray The vertex attribute data
  82987. * @param byteOffset The offset to the binary data
  82988. * @param binaryWriter The binary data for the glTF file
  82989. * @param convertToRightHandedSystem Converts the values to right-handed
  82990. */
  82991. private reorderTriangleFillMode;
  82992. /**
  82993. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  82994. * clock-wise during export to glTF
  82995. * @param submesh BabylonJS submesh
  82996. * @param primitiveMode Primitive mode of the mesh
  82997. * @param sideOrientation the winding order of the submesh
  82998. * @param vertexBufferKind The type of vertex attribute
  82999. * @param meshAttributeArray The vertex attribute data
  83000. * @param byteOffset The offset to the binary data
  83001. * @param binaryWriter The binary data for the glTF file
  83002. * @param convertToRightHandedSystem Converts the values to right-handed
  83003. */
  83004. private reorderTriangleStripDrawMode;
  83005. /**
  83006. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  83007. * clock-wise during export to glTF
  83008. * @param submesh BabylonJS submesh
  83009. * @param primitiveMode Primitive mode of the mesh
  83010. * @param sideOrientation the winding order of the submesh
  83011. * @param vertexBufferKind The type of vertex attribute
  83012. * @param meshAttributeArray The vertex attribute data
  83013. * @param byteOffset The offset to the binary data
  83014. * @param binaryWriter The binary data for the glTF file
  83015. * @param convertToRightHandedSystem Converts the values to right-handed
  83016. */
  83017. private reorderTriangleFanMode;
  83018. /**
  83019. * Writes the vertex attribute data to binary
  83020. * @param vertices The vertices to write to the binary writer
  83021. * @param byteOffset The offset into the binary writer to overwrite binary data
  83022. * @param vertexAttributeKind The vertex attribute type
  83023. * @param meshAttributeArray The vertex attribute data
  83024. * @param binaryWriter The writer containing the binary data
  83025. * @param convertToRightHandedSystem Converts the values to right-handed
  83026. */
  83027. private writeVertexAttributeData;
  83028. /**
  83029. * Writes mesh attribute data to a data buffer
  83030. * Returns the bytelength of the data
  83031. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  83032. * @param meshAttributeArray Array containing the attribute data
  83033. * @param byteStride Specifies the space between data
  83034. * @param binaryWriter The buffer to write the binary data to
  83035. * @param convertToRightHandedSystem Converts the values to right-handed
  83036. */
  83037. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  83038. /**
  83039. * Generates glTF json data
  83040. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  83041. * @param glTFPrefix Text to use when prefixing a glTF file
  83042. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  83043. * @returns json data as string
  83044. */
  83045. private generateJSON;
  83046. /**
  83047. * Generates data for .gltf and .bin files based on the glTF prefix string
  83048. * @param glTFPrefix Text to use when prefixing a glTF file
  83049. * @param dispose Dispose the exporter
  83050. * @returns GLTFData with glTF file data
  83051. */
  83052. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  83053. /**
  83054. * Creates a binary buffer for glTF
  83055. * @returns array buffer for binary data
  83056. */
  83057. private _generateBinaryAsync;
  83058. /**
  83059. * Pads the number to a multiple of 4
  83060. * @param num number to pad
  83061. * @returns padded number
  83062. */
  83063. private _getPadding;
  83064. /**
  83065. * @hidden
  83066. */
  83067. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  83068. /**
  83069. * Sets the TRS for each node
  83070. * @param node glTF Node for storing the transformation data
  83071. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  83072. * @param convertToRightHandedSystem Converts the values to right-handed
  83073. */
  83074. private setNodeTransformation;
  83075. private getVertexBufferFromMesh;
  83076. /**
  83077. * Creates a bufferview based on the vertices type for the Babylon mesh
  83078. * @param kind Indicates the type of vertices data
  83079. * @param componentType Indicates the numerical type used to store the data
  83080. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  83081. * @param binaryWriter The buffer to write the bufferview data to
  83082. * @param convertToRightHandedSystem Converts the values to right-handed
  83083. */
  83084. private createBufferViewKind;
  83085. /**
  83086. * The primitive mode of the Babylon mesh
  83087. * @param babylonMesh The BabylonJS mesh
  83088. */
  83089. private getMeshPrimitiveMode;
  83090. /**
  83091. * Sets the primitive mode of the glTF mesh primitive
  83092. * @param meshPrimitive glTF mesh primitive
  83093. * @param primitiveMode The primitive mode
  83094. */
  83095. private setPrimitiveMode;
  83096. /**
  83097. * Sets the vertex attribute accessor based of the glTF mesh primitive
  83098. * @param meshPrimitive glTF mesh primitive
  83099. * @param attributeKind vertex attribute
  83100. * @returns boolean specifying if uv coordinates are present
  83101. */
  83102. private setAttributeKind;
  83103. /**
  83104. * Sets data for the primitive attributes of each submesh
  83105. * @param mesh glTF Mesh object to store the primitive attribute information
  83106. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  83107. * @param binaryWriter Buffer to write the attribute data to
  83108. * @param convertToRightHandedSystem Converts the values to right-handed
  83109. */
  83110. private setPrimitiveAttributesAsync;
  83111. /**
  83112. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  83113. * @param node The node to check
  83114. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  83115. */
  83116. private isBabylonCoordinateSystemConvertingNode;
  83117. /**
  83118. * Creates a glTF scene based on the array of meshes
  83119. * Returns the the total byte offset
  83120. * @param babylonScene Babylon scene to get the mesh data from
  83121. * @param binaryWriter Buffer to write binary data to
  83122. */
  83123. private createSceneAsync;
  83124. /**
  83125. * Creates a mapping of Node unique id to node index and handles animations
  83126. * @param babylonScene Babylon Scene
  83127. * @param nodes Babylon transform nodes
  83128. * @param binaryWriter Buffer to write binary data to
  83129. * @returns Node mapping of unique id to index
  83130. */
  83131. private createNodeMapAndAnimationsAsync;
  83132. /**
  83133. * Creates a glTF node from a Babylon mesh
  83134. * @param babylonMesh Source Babylon mesh
  83135. * @param binaryWriter Buffer for storing geometry data
  83136. * @param convertToRightHandedSystem Converts the values to right-handed
  83137. * @param nodeMap Node mapping of unique id to glTF node index
  83138. * @returns glTF node
  83139. */
  83140. private createNodeAsync;
  83141. /**
  83142. * Creates a glTF skin from a Babylon skeleton
  83143. * @param babylonScene Babylon Scene
  83144. * @param nodes Babylon transform nodes
  83145. * @param binaryWriter Buffer to write binary data to
  83146. * @returns Node mapping of unique id to index
  83147. */
  83148. private createSkinsAsync;
  83149. }
  83150. /**
  83151. * @hidden
  83152. *
  83153. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  83154. */
  83155. export class _BinaryWriter {
  83156. /**
  83157. * Array buffer which stores all binary data
  83158. */
  83159. private _arrayBuffer;
  83160. /**
  83161. * View of the array buffer
  83162. */
  83163. private _dataView;
  83164. /**
  83165. * byte offset of data in array buffer
  83166. */
  83167. private _byteOffset;
  83168. /**
  83169. * Initialize binary writer with an initial byte length
  83170. * @param byteLength Initial byte length of the array buffer
  83171. */
  83172. constructor(byteLength: number);
  83173. /**
  83174. * Resize the array buffer to the specified byte length
  83175. * @param byteLength
  83176. */
  83177. private resizeBuffer;
  83178. /**
  83179. * Get an array buffer with the length of the byte offset
  83180. * @returns ArrayBuffer resized to the byte offset
  83181. */
  83182. getArrayBuffer(): ArrayBuffer;
  83183. /**
  83184. * Get the byte offset of the array buffer
  83185. * @returns byte offset
  83186. */
  83187. getByteOffset(): number;
  83188. /**
  83189. * Stores an UInt8 in the array buffer
  83190. * @param entry
  83191. * @param byteOffset If defined, specifies where to set the value as an offset.
  83192. */
  83193. setUInt8(entry: number, byteOffset?: number): void;
  83194. /**
  83195. * Stores an UInt16 in the array buffer
  83196. * @param entry
  83197. * @param byteOffset If defined, specifies where to set the value as an offset.
  83198. */
  83199. setUInt16(entry: number, byteOffset?: number): void;
  83200. /**
  83201. * Gets an UInt32 in the array buffer
  83202. * @param entry
  83203. * @param byteOffset If defined, specifies where to set the value as an offset.
  83204. */
  83205. getUInt32(byteOffset: number): number;
  83206. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  83207. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  83208. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  83209. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  83210. /**
  83211. * Stores a Float32 in the array buffer
  83212. * @param entry
  83213. */
  83214. setFloat32(entry: number, byteOffset?: number): void;
  83215. /**
  83216. * Stores an UInt32 in the array buffer
  83217. * @param entry
  83218. * @param byteOffset If defined, specifies where to set the value as an offset.
  83219. */
  83220. setUInt32(entry: number, byteOffset?: number): void;
  83221. }
  83222. }
  83223. declare module BABYLON.GLTF2.Exporter {
  83224. /**
  83225. * @hidden
  83226. * Interface to store animation data.
  83227. */
  83228. export interface _IAnimationData {
  83229. /**
  83230. * Keyframe data.
  83231. */
  83232. inputs: number[];
  83233. /**
  83234. * Value data.
  83235. */
  83236. outputs: number[][];
  83237. /**
  83238. * Animation interpolation data.
  83239. */
  83240. samplerInterpolation: AnimationSamplerInterpolation;
  83241. /**
  83242. * Minimum keyframe value.
  83243. */
  83244. inputsMin: number;
  83245. /**
  83246. * Maximum keyframe value.
  83247. */
  83248. inputsMax: number;
  83249. }
  83250. /**
  83251. * @hidden
  83252. */
  83253. export interface _IAnimationInfo {
  83254. /**
  83255. * The target channel for the animation
  83256. */
  83257. animationChannelTargetPath: AnimationChannelTargetPath;
  83258. /**
  83259. * The glTF accessor type for the data.
  83260. */
  83261. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  83262. /**
  83263. * Specifies if quaternions should be used.
  83264. */
  83265. useQuaternion: boolean;
  83266. }
  83267. /**
  83268. * @hidden
  83269. * Utility class for generating glTF animation data from BabylonJS.
  83270. */
  83271. export class _GLTFAnimation {
  83272. /**
  83273. * @ignore
  83274. *
  83275. * Creates glTF channel animation from BabylonJS animation.
  83276. * @param babylonTransformNode - BabylonJS mesh.
  83277. * @param animation - animation.
  83278. * @param animationChannelTargetPath - The target animation channel.
  83279. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  83280. * @param useQuaternion - Specifies if quaternions are used.
  83281. * @returns nullable IAnimationData
  83282. */
  83283. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  83284. private static _DeduceAnimationInfo;
  83285. /**
  83286. * @ignore
  83287. * Create node animations from the transform node animations
  83288. * @param babylonNode
  83289. * @param runtimeGLTFAnimation
  83290. * @param idleGLTFAnimations
  83291. * @param nodeMap
  83292. * @param nodes
  83293. * @param binaryWriter
  83294. * @param bufferViews
  83295. * @param accessors
  83296. * @param convertToRightHandedSystem
  83297. * @param animationSampleRate
  83298. */
  83299. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  83300. [key: number]: number;
  83301. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  83302. /**
  83303. * @ignore
  83304. * Create node animations from the animation groups
  83305. * @param babylonScene
  83306. * @param glTFAnimations
  83307. * @param nodeMap
  83308. * @param nodes
  83309. * @param binaryWriter
  83310. * @param bufferViews
  83311. * @param accessors
  83312. * @param convertToRightHandedSystemMap
  83313. * @param animationSampleRate
  83314. */
  83315. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  83316. [key: number]: number;
  83317. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  83318. [nodeId: number]: boolean;
  83319. }, animationSampleRate: number): void;
  83320. private static AddAnimation;
  83321. /**
  83322. * Create a baked animation
  83323. * @param babylonTransformNode BabylonJS mesh
  83324. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  83325. * @param animationChannelTargetPath animation target channel
  83326. * @param minFrame minimum animation frame
  83327. * @param maxFrame maximum animation frame
  83328. * @param fps frames per second of the animation
  83329. * @param inputs input key frames of the animation
  83330. * @param outputs output key frame data of the animation
  83331. * @param convertToRightHandedSystem converts the values to right-handed
  83332. * @param useQuaternion specifies if quaternions should be used
  83333. */
  83334. private static _CreateBakedAnimation;
  83335. private static _ConvertFactorToVector3OrQuaternion;
  83336. private static _SetInterpolatedValue;
  83337. /**
  83338. * Creates linear animation from the animation key frames
  83339. * @param babylonTransformNode BabylonJS mesh
  83340. * @param animation BabylonJS animation
  83341. * @param animationChannelTargetPath The target animation channel
  83342. * @param frameDelta The difference between the last and first frame of the animation
  83343. * @param inputs Array to store the key frame times
  83344. * @param outputs Array to store the key frame data
  83345. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  83346. * @param useQuaternion Specifies if quaternions are used in the animation
  83347. */
  83348. private static _CreateLinearOrStepAnimation;
  83349. /**
  83350. * Creates cubic spline animation from the animation key frames
  83351. * @param babylonTransformNode BabylonJS mesh
  83352. * @param animation BabylonJS animation
  83353. * @param animationChannelTargetPath The target animation channel
  83354. * @param frameDelta The difference between the last and first frame of the animation
  83355. * @param inputs Array to store the key frame times
  83356. * @param outputs Array to store the key frame data
  83357. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  83358. * @param useQuaternion Specifies if quaternions are used in the animation
  83359. */
  83360. private static _CreateCubicSplineAnimation;
  83361. private static _GetBasePositionRotationOrScale;
  83362. /**
  83363. * Adds a key frame value
  83364. * @param keyFrame
  83365. * @param animation
  83366. * @param outputs
  83367. * @param animationChannelTargetPath
  83368. * @param basePositionRotationOrScale
  83369. * @param convertToRightHandedSystem
  83370. * @param useQuaternion
  83371. */
  83372. private static _AddKeyframeValue;
  83373. /**
  83374. * Determine the interpolation based on the key frames
  83375. * @param keyFrames
  83376. * @param animationChannelTargetPath
  83377. * @param useQuaternion
  83378. */
  83379. private static _DeduceInterpolation;
  83380. /**
  83381. * Adds an input tangent or output tangent to the output data
  83382. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  83383. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  83384. * @param outputs The animation data by keyframe
  83385. * @param animationChannelTargetPath The target animation channel
  83386. * @param interpolation The interpolation type
  83387. * @param keyFrame The key frame with the animation data
  83388. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  83389. * @param useQuaternion Specifies if quaternions are used
  83390. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  83391. */
  83392. private static AddSplineTangent;
  83393. /**
  83394. * Get the minimum and maximum key frames' frame values
  83395. * @param keyFrames animation key frames
  83396. * @returns the minimum and maximum key frame value
  83397. */
  83398. private static calculateMinMaxKeyFrames;
  83399. }
  83400. }
  83401. declare module BABYLON.GLTF2.Exporter {
  83402. /** @hidden */
  83403. export var textureTransformPixelShader: {
  83404. name: string;
  83405. shader: string;
  83406. };
  83407. }
  83408. declare module BABYLON.GLTF2.Exporter.Extensions {
  83409. /**
  83410. * @hidden
  83411. */
  83412. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  83413. private _recordedTextures;
  83414. /** Name of this extension */
  83415. readonly name: string;
  83416. /** Defines whether this extension is enabled */
  83417. enabled: boolean;
  83418. /** Defines whether this extension is required */
  83419. required: boolean;
  83420. /** Reference to the glTF exporter */
  83421. private _wasUsed;
  83422. constructor(exporter: _Exporter);
  83423. dispose(): void;
  83424. /** @hidden */
  83425. get wasUsed(): boolean;
  83426. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  83427. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  83428. /**
  83429. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  83430. * @param babylonTexture
  83431. * @param offset
  83432. * @param rotation
  83433. * @param scale
  83434. * @param scene
  83435. */
  83436. private _textureTransformTextureAsync;
  83437. }
  83438. }
  83439. declare module BABYLON.GLTF2.Exporter.Extensions {
  83440. /**
  83441. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  83442. */
  83443. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  83444. /** The name of this extension. */
  83445. readonly name: string;
  83446. /** Defines whether this extension is enabled. */
  83447. enabled: boolean;
  83448. /** Defines whether this extension is required */
  83449. required: boolean;
  83450. /** Reference to the glTF exporter */
  83451. private _exporter;
  83452. private _lights;
  83453. /** @hidden */
  83454. constructor(exporter: _Exporter);
  83455. /** @hidden */
  83456. dispose(): void;
  83457. /** @hidden */
  83458. get wasUsed(): boolean;
  83459. /** @hidden */
  83460. onExporting(): void;
  83461. /**
  83462. * Define this method to modify the default behavior when exporting a node
  83463. * @param context The context when exporting the node
  83464. * @param node glTF node
  83465. * @param babylonNode BabylonJS node
  83466. * @param nodeMap Node mapping of unique id to glTF node index
  83467. * @returns nullable INode promise
  83468. */
  83469. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83470. [key: number]: number;
  83471. }): Promise<Nullable<INode>>;
  83472. }
  83473. }
  83474. declare module BABYLON.GLTF2.Exporter.Extensions {
  83475. /**
  83476. * @hidden
  83477. */
  83478. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  83479. /** Name of this extension */
  83480. readonly name: string;
  83481. /** Defines whether this extension is enabled */
  83482. enabled: boolean;
  83483. /** Defines whether this extension is required */
  83484. required: boolean;
  83485. /** Reference to the glTF exporter */
  83486. private _textureInfos;
  83487. private _exportedTextures;
  83488. private _wasUsed;
  83489. constructor(exporter: _Exporter);
  83490. dispose(): void;
  83491. /** @hidden */
  83492. get wasUsed(): boolean;
  83493. private _getTextureIndex;
  83494. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  83495. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  83496. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  83497. }
  83498. }
  83499. declare module BABYLON.GLTF2.Exporter.Extensions {
  83500. /**
  83501. * @hidden
  83502. */
  83503. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  83504. /** Name of this extension */
  83505. readonly name: string;
  83506. /** Defines whether this extension is enabled */
  83507. enabled: boolean;
  83508. /** Defines whether this extension is required */
  83509. required: boolean;
  83510. private _wasUsed;
  83511. constructor(exporter: _Exporter);
  83512. /** @hidden */
  83513. get wasUsed(): boolean;
  83514. dispose(): void;
  83515. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  83516. }
  83517. }
  83518. declare module BABYLON {
  83519. /**
  83520. * Class for generating STL data from a Babylon scene.
  83521. */
  83522. export class STLExport {
  83523. /**
  83524. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  83525. * @param meshes list defines the mesh to serialize
  83526. * @param download triggers the automatic download of the file.
  83527. * @param fileName changes the downloads fileName.
  83528. * @param binary changes the STL to a binary type.
  83529. * @param isLittleEndian toggle for binary type exporter.
  83530. * @returns the STL as UTF8 string
  83531. */
  83532. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  83533. }
  83534. }
  83535. declare module "babylonjs-gltf2interface" {
  83536. export = BABYLON.GLTF2;
  83537. }
  83538. /**
  83539. * Module for glTF 2.0 Interface
  83540. */
  83541. declare module BABYLON.GLTF2 {
  83542. /**
  83543. * The datatype of the components in the attribute
  83544. */
  83545. const enum AccessorComponentType {
  83546. /**
  83547. * Byte
  83548. */
  83549. BYTE = 5120,
  83550. /**
  83551. * Unsigned Byte
  83552. */
  83553. UNSIGNED_BYTE = 5121,
  83554. /**
  83555. * Short
  83556. */
  83557. SHORT = 5122,
  83558. /**
  83559. * Unsigned Short
  83560. */
  83561. UNSIGNED_SHORT = 5123,
  83562. /**
  83563. * Unsigned Int
  83564. */
  83565. UNSIGNED_INT = 5125,
  83566. /**
  83567. * Float
  83568. */
  83569. FLOAT = 5126,
  83570. }
  83571. /**
  83572. * Specifies if the attirbute is a scalar, vector, or matrix
  83573. */
  83574. const enum AccessorType {
  83575. /**
  83576. * Scalar
  83577. */
  83578. SCALAR = "SCALAR",
  83579. /**
  83580. * Vector2
  83581. */
  83582. VEC2 = "VEC2",
  83583. /**
  83584. * Vector3
  83585. */
  83586. VEC3 = "VEC3",
  83587. /**
  83588. * Vector4
  83589. */
  83590. VEC4 = "VEC4",
  83591. /**
  83592. * Matrix2x2
  83593. */
  83594. MAT2 = "MAT2",
  83595. /**
  83596. * Matrix3x3
  83597. */
  83598. MAT3 = "MAT3",
  83599. /**
  83600. * Matrix4x4
  83601. */
  83602. MAT4 = "MAT4",
  83603. }
  83604. /**
  83605. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  83606. */
  83607. const enum AnimationChannelTargetPath {
  83608. /**
  83609. * Translation
  83610. */
  83611. TRANSLATION = "translation",
  83612. /**
  83613. * Rotation
  83614. */
  83615. ROTATION = "rotation",
  83616. /**
  83617. * Scale
  83618. */
  83619. SCALE = "scale",
  83620. /**
  83621. * Weights
  83622. */
  83623. WEIGHTS = "weights",
  83624. }
  83625. /**
  83626. * Interpolation algorithm
  83627. */
  83628. const enum AnimationSamplerInterpolation {
  83629. /**
  83630. * The animated values are linearly interpolated between keyframes
  83631. */
  83632. LINEAR = "LINEAR",
  83633. /**
  83634. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  83635. */
  83636. STEP = "STEP",
  83637. /**
  83638. * The animation's interpolation is computed using a cubic spline with specified tangents
  83639. */
  83640. CUBICSPLINE = "CUBICSPLINE",
  83641. }
  83642. /**
  83643. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  83644. */
  83645. const enum CameraType {
  83646. /**
  83647. * A perspective camera containing properties to create a perspective projection matrix
  83648. */
  83649. PERSPECTIVE = "perspective",
  83650. /**
  83651. * An orthographic camera containing properties to create an orthographic projection matrix
  83652. */
  83653. ORTHOGRAPHIC = "orthographic",
  83654. }
  83655. /**
  83656. * The mime-type of the image
  83657. */
  83658. const enum ImageMimeType {
  83659. /**
  83660. * JPEG Mime-type
  83661. */
  83662. JPEG = "image/jpeg",
  83663. /**
  83664. * PNG Mime-type
  83665. */
  83666. PNG = "image/png",
  83667. }
  83668. /**
  83669. * The alpha rendering mode of the material
  83670. */
  83671. const enum MaterialAlphaMode {
  83672. /**
  83673. * The alpha value is ignored and the rendered output is fully opaque
  83674. */
  83675. OPAQUE = "OPAQUE",
  83676. /**
  83677. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  83678. */
  83679. MASK = "MASK",
  83680. /**
  83681. * 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)
  83682. */
  83683. BLEND = "BLEND",
  83684. }
  83685. /**
  83686. * The type of the primitives to render
  83687. */
  83688. const enum MeshPrimitiveMode {
  83689. /**
  83690. * Points
  83691. */
  83692. POINTS = 0,
  83693. /**
  83694. * Lines
  83695. */
  83696. LINES = 1,
  83697. /**
  83698. * Line Loop
  83699. */
  83700. LINE_LOOP = 2,
  83701. /**
  83702. * Line Strip
  83703. */
  83704. LINE_STRIP = 3,
  83705. /**
  83706. * Triangles
  83707. */
  83708. TRIANGLES = 4,
  83709. /**
  83710. * Triangle Strip
  83711. */
  83712. TRIANGLE_STRIP = 5,
  83713. /**
  83714. * Triangle Fan
  83715. */
  83716. TRIANGLE_FAN = 6,
  83717. }
  83718. /**
  83719. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  83720. */
  83721. const enum TextureMagFilter {
  83722. /**
  83723. * Nearest
  83724. */
  83725. NEAREST = 9728,
  83726. /**
  83727. * Linear
  83728. */
  83729. LINEAR = 9729,
  83730. }
  83731. /**
  83732. * Minification filter. All valid values correspond to WebGL enums
  83733. */
  83734. const enum TextureMinFilter {
  83735. /**
  83736. * Nearest
  83737. */
  83738. NEAREST = 9728,
  83739. /**
  83740. * Linear
  83741. */
  83742. LINEAR = 9729,
  83743. /**
  83744. * Nearest Mip-Map Nearest
  83745. */
  83746. NEAREST_MIPMAP_NEAREST = 9984,
  83747. /**
  83748. * Linear Mipmap Nearest
  83749. */
  83750. LINEAR_MIPMAP_NEAREST = 9985,
  83751. /**
  83752. * Nearest Mipmap Linear
  83753. */
  83754. NEAREST_MIPMAP_LINEAR = 9986,
  83755. /**
  83756. * Linear Mipmap Linear
  83757. */
  83758. LINEAR_MIPMAP_LINEAR = 9987,
  83759. }
  83760. /**
  83761. * S (U) wrapping mode. All valid values correspond to WebGL enums
  83762. */
  83763. const enum TextureWrapMode {
  83764. /**
  83765. * Clamp to Edge
  83766. */
  83767. CLAMP_TO_EDGE = 33071,
  83768. /**
  83769. * Mirrored Repeat
  83770. */
  83771. MIRRORED_REPEAT = 33648,
  83772. /**
  83773. * Repeat
  83774. */
  83775. REPEAT = 10497,
  83776. }
  83777. /**
  83778. * glTF Property
  83779. */
  83780. interface IProperty {
  83781. /**
  83782. * Dictionary object with extension-specific objects
  83783. */
  83784. extensions?: {
  83785. [key: string]: any;
  83786. };
  83787. /**
  83788. * Application-Specific data
  83789. */
  83790. extras?: any;
  83791. }
  83792. /**
  83793. * glTF Child of Root Property
  83794. */
  83795. interface IChildRootProperty extends IProperty {
  83796. /**
  83797. * The user-defined name of this object
  83798. */
  83799. name?: string;
  83800. }
  83801. /**
  83802. * Indices of those attributes that deviate from their initialization value
  83803. */
  83804. interface IAccessorSparseIndices extends IProperty {
  83805. /**
  83806. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  83807. */
  83808. bufferView: number;
  83809. /**
  83810. * The offset relative to the start of the bufferView in bytes. Must be aligned
  83811. */
  83812. byteOffset?: number;
  83813. /**
  83814. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  83815. */
  83816. componentType: AccessorComponentType;
  83817. }
  83818. /**
  83819. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  83820. */
  83821. interface IAccessorSparseValues extends IProperty {
  83822. /**
  83823. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  83824. */
  83825. bufferView: number;
  83826. /**
  83827. * The offset relative to the start of the bufferView in bytes. Must be aligned
  83828. */
  83829. byteOffset?: number;
  83830. }
  83831. /**
  83832. * Sparse storage of attributes that deviate from their initialization value
  83833. */
  83834. interface IAccessorSparse extends IProperty {
  83835. /**
  83836. * The number of attributes encoded in this sparse accessor
  83837. */
  83838. count: number;
  83839. /**
  83840. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  83841. */
  83842. indices: IAccessorSparseIndices;
  83843. /**
  83844. * 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
  83845. */
  83846. values: IAccessorSparseValues;
  83847. }
  83848. /**
  83849. * 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
  83850. */
  83851. interface IAccessor extends IChildRootProperty {
  83852. /**
  83853. * The index of the bufferview
  83854. */
  83855. bufferView?: number;
  83856. /**
  83857. * The offset relative to the start of the bufferView in bytes
  83858. */
  83859. byteOffset?: number;
  83860. /**
  83861. * The datatype of components in the attribute
  83862. */
  83863. componentType: AccessorComponentType;
  83864. /**
  83865. * Specifies whether integer data values should be normalized
  83866. */
  83867. normalized?: boolean;
  83868. /**
  83869. * The number of attributes referenced by this accessor
  83870. */
  83871. count: number;
  83872. /**
  83873. * Specifies if the attribute is a scalar, vector, or matrix
  83874. */
  83875. type: AccessorType;
  83876. /**
  83877. * Maximum value of each component in this attribute
  83878. */
  83879. max?: number[];
  83880. /**
  83881. * Minimum value of each component in this attribute
  83882. */
  83883. min?: number[];
  83884. /**
  83885. * Sparse storage of attributes that deviate from their initialization value
  83886. */
  83887. sparse?: IAccessorSparse;
  83888. }
  83889. /**
  83890. * Targets an animation's sampler at a node's property
  83891. */
  83892. interface IAnimationChannel extends IProperty {
  83893. /**
  83894. * The index of a sampler in this animation used to compute the value for the target
  83895. */
  83896. sampler: number;
  83897. /**
  83898. * The index of the node and TRS property to target
  83899. */
  83900. target: IAnimationChannelTarget;
  83901. }
  83902. /**
  83903. * The index of the node and TRS property that an animation channel targets
  83904. */
  83905. interface IAnimationChannelTarget extends IProperty {
  83906. /**
  83907. * The index of the node to target
  83908. */
  83909. node: number;
  83910. /**
  83911. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  83912. */
  83913. path: AnimationChannelTargetPath;
  83914. }
  83915. /**
  83916. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  83917. */
  83918. interface IAnimationSampler extends IProperty {
  83919. /**
  83920. * The index of an accessor containing keyframe input values, e.g., time
  83921. */
  83922. input: number;
  83923. /**
  83924. * Interpolation algorithm
  83925. */
  83926. interpolation?: AnimationSamplerInterpolation;
  83927. /**
  83928. * The index of an accessor, containing keyframe output values
  83929. */
  83930. output: number;
  83931. }
  83932. /**
  83933. * A keyframe animation
  83934. */
  83935. interface IAnimation extends IChildRootProperty {
  83936. /**
  83937. * An array of channels, each of which targets an animation's sampler at a node's property
  83938. */
  83939. channels: IAnimationChannel[];
  83940. /**
  83941. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  83942. */
  83943. samplers: IAnimationSampler[];
  83944. }
  83945. /**
  83946. * Metadata about the glTF asset
  83947. */
  83948. interface IAsset extends IChildRootProperty {
  83949. /**
  83950. * A copyright message suitable for display to credit the content creator
  83951. */
  83952. copyright?: string;
  83953. /**
  83954. * Tool that generated this glTF model. Useful for debugging
  83955. */
  83956. generator?: string;
  83957. /**
  83958. * The glTF version that this asset targets
  83959. */
  83960. version: string;
  83961. /**
  83962. * The minimum glTF version that this asset targets
  83963. */
  83964. minVersion?: string;
  83965. }
  83966. /**
  83967. * A buffer points to binary geometry, animation, or skins
  83968. */
  83969. interface IBuffer extends IChildRootProperty {
  83970. /**
  83971. * 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
  83972. */
  83973. uri?: string;
  83974. /**
  83975. * The length of the buffer in bytes
  83976. */
  83977. byteLength: number;
  83978. }
  83979. /**
  83980. * A view into a buffer generally representing a subset of the buffer
  83981. */
  83982. interface IBufferView extends IChildRootProperty {
  83983. /**
  83984. * The index of the buffer
  83985. */
  83986. buffer: number;
  83987. /**
  83988. * The offset into the buffer in bytes
  83989. */
  83990. byteOffset?: number;
  83991. /**
  83992. * The lenth of the bufferView in bytes
  83993. */
  83994. byteLength: number;
  83995. /**
  83996. * The stride, in bytes
  83997. */
  83998. byteStride?: number;
  83999. }
  84000. /**
  84001. * An orthographic camera containing properties to create an orthographic projection matrix
  84002. */
  84003. interface ICameraOrthographic extends IProperty {
  84004. /**
  84005. * The floating-point horizontal magnification of the view. Must not be zero
  84006. */
  84007. xmag: number;
  84008. /**
  84009. * The floating-point vertical magnification of the view. Must not be zero
  84010. */
  84011. ymag: number;
  84012. /**
  84013. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  84014. */
  84015. zfar: number;
  84016. /**
  84017. * The floating-point distance to the near clipping plane
  84018. */
  84019. znear: number;
  84020. }
  84021. /**
  84022. * A perspective camera containing properties to create a perspective projection matrix
  84023. */
  84024. interface ICameraPerspective extends IProperty {
  84025. /**
  84026. * The floating-point aspect ratio of the field of view
  84027. */
  84028. aspectRatio?: number;
  84029. /**
  84030. * The floating-point vertical field of view in radians
  84031. */
  84032. yfov: number;
  84033. /**
  84034. * The floating-point distance to the far clipping plane
  84035. */
  84036. zfar?: number;
  84037. /**
  84038. * The floating-point distance to the near clipping plane
  84039. */
  84040. znear: number;
  84041. }
  84042. /**
  84043. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  84044. */
  84045. interface ICamera extends IChildRootProperty {
  84046. /**
  84047. * An orthographic camera containing properties to create an orthographic projection matrix
  84048. */
  84049. orthographic?: ICameraOrthographic;
  84050. /**
  84051. * A perspective camera containing properties to create a perspective projection matrix
  84052. */
  84053. perspective?: ICameraPerspective;
  84054. /**
  84055. * Specifies if the camera uses a perspective or orthographic projection
  84056. */
  84057. type: CameraType;
  84058. }
  84059. /**
  84060. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  84061. */
  84062. interface IImage extends IChildRootProperty {
  84063. /**
  84064. * 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
  84065. */
  84066. uri?: string;
  84067. /**
  84068. * The image's MIME type
  84069. */
  84070. mimeType?: ImageMimeType;
  84071. /**
  84072. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  84073. */
  84074. bufferView?: number;
  84075. }
  84076. /**
  84077. * Material Normal Texture Info
  84078. */
  84079. interface IMaterialNormalTextureInfo extends ITextureInfo {
  84080. /**
  84081. * The scalar multiplier applied to each normal vector of the normal texture
  84082. */
  84083. scale?: number;
  84084. }
  84085. /**
  84086. * Material Occlusion Texture Info
  84087. */
  84088. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  84089. /**
  84090. * A scalar multiplier controlling the amount of occlusion applied
  84091. */
  84092. strength?: number;
  84093. }
  84094. /**
  84095. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  84096. */
  84097. interface IMaterialPbrMetallicRoughness {
  84098. /**
  84099. * The material's base color factor
  84100. */
  84101. baseColorFactor?: number[];
  84102. /**
  84103. * The base color texture
  84104. */
  84105. baseColorTexture?: ITextureInfo;
  84106. /**
  84107. * The metalness of the material
  84108. */
  84109. metallicFactor?: number;
  84110. /**
  84111. * The roughness of the material
  84112. */
  84113. roughnessFactor?: number;
  84114. /**
  84115. * The metallic-roughness texture
  84116. */
  84117. metallicRoughnessTexture?: ITextureInfo;
  84118. }
  84119. /**
  84120. * The material appearance of a primitive
  84121. */
  84122. interface IMaterial extends IChildRootProperty {
  84123. /**
  84124. * 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
  84125. */
  84126. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  84127. /**
  84128. * The normal map texture
  84129. */
  84130. normalTexture?: IMaterialNormalTextureInfo;
  84131. /**
  84132. * The occlusion map texture
  84133. */
  84134. occlusionTexture?: IMaterialOcclusionTextureInfo;
  84135. /**
  84136. * The emissive map texture
  84137. */
  84138. emissiveTexture?: ITextureInfo;
  84139. /**
  84140. * 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
  84141. */
  84142. emissiveFactor?: number[];
  84143. /**
  84144. * The alpha rendering mode of the material
  84145. */
  84146. alphaMode?: MaterialAlphaMode;
  84147. /**
  84148. * The alpha cutoff value of the material
  84149. */
  84150. alphaCutoff?: number;
  84151. /**
  84152. * Specifies whether the material is double sided
  84153. */
  84154. doubleSided?: boolean;
  84155. }
  84156. /**
  84157. * Geometry to be rendered with the given material
  84158. */
  84159. interface IMeshPrimitive extends IProperty {
  84160. /**
  84161. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  84162. */
  84163. attributes: {
  84164. [name: string]: number;
  84165. };
  84166. /**
  84167. * The index of the accessor that contains the indices
  84168. */
  84169. indices?: number;
  84170. /**
  84171. * The index of the material to apply to this primitive when rendering
  84172. */
  84173. material?: number;
  84174. /**
  84175. * The type of primitives to render. All valid values correspond to WebGL enums
  84176. */
  84177. mode?: MeshPrimitiveMode;
  84178. /**
  84179. * 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
  84180. */
  84181. targets?: {
  84182. [name: string]: number;
  84183. }[];
  84184. }
  84185. /**
  84186. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  84187. */
  84188. interface IMesh extends IChildRootProperty {
  84189. /**
  84190. * An array of primitives, each defining geometry to be rendered with a material
  84191. */
  84192. primitives: IMeshPrimitive[];
  84193. /**
  84194. * Array of weights to be applied to the Morph Targets
  84195. */
  84196. weights?: number[];
  84197. }
  84198. /**
  84199. * A node in the node hierarchy
  84200. */
  84201. interface INode extends IChildRootProperty {
  84202. /**
  84203. * The index of the camera referenced by this node
  84204. */
  84205. camera?: number;
  84206. /**
  84207. * The indices of this node's children
  84208. */
  84209. children?: number[];
  84210. /**
  84211. * The index of the skin referenced by this node
  84212. */
  84213. skin?: number;
  84214. /**
  84215. * A floating-point 4x4 transformation matrix stored in column-major order
  84216. */
  84217. matrix?: number[];
  84218. /**
  84219. * The index of the mesh in this node
  84220. */
  84221. mesh?: number;
  84222. /**
  84223. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  84224. */
  84225. rotation?: number[];
  84226. /**
  84227. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  84228. */
  84229. scale?: number[];
  84230. /**
  84231. * The node's translation along the x, y, and z axes
  84232. */
  84233. translation?: number[];
  84234. /**
  84235. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  84236. */
  84237. weights?: number[];
  84238. }
  84239. /**
  84240. * Texture sampler properties for filtering and wrapping modes
  84241. */
  84242. interface ISampler extends IChildRootProperty {
  84243. /**
  84244. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  84245. */
  84246. magFilter?: TextureMagFilter;
  84247. /**
  84248. * Minification filter. All valid values correspond to WebGL enums
  84249. */
  84250. minFilter?: TextureMinFilter;
  84251. /**
  84252. * S (U) wrapping mode. All valid values correspond to WebGL enums
  84253. */
  84254. wrapS?: TextureWrapMode;
  84255. /**
  84256. * T (V) wrapping mode. All valid values correspond to WebGL enums
  84257. */
  84258. wrapT?: TextureWrapMode;
  84259. }
  84260. /**
  84261. * The root nodes of a scene
  84262. */
  84263. interface IScene extends IChildRootProperty {
  84264. /**
  84265. * The indices of each root node
  84266. */
  84267. nodes: number[];
  84268. }
  84269. /**
  84270. * Joints and matrices defining a skin
  84271. */
  84272. interface ISkin extends IChildRootProperty {
  84273. /**
  84274. * 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
  84275. */
  84276. inverseBindMatrices?: number;
  84277. /**
  84278. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  84279. */
  84280. skeleton?: number;
  84281. /**
  84282. * 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)
  84283. */
  84284. joints: number[];
  84285. }
  84286. /**
  84287. * A texture and its sampler
  84288. */
  84289. interface ITexture extends IChildRootProperty {
  84290. /**
  84291. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  84292. */
  84293. sampler?: number;
  84294. /**
  84295. * The index of the image used by this texture
  84296. */
  84297. source: number;
  84298. }
  84299. /**
  84300. * Reference to a texture
  84301. */
  84302. interface ITextureInfo extends IProperty {
  84303. /**
  84304. * The index of the texture
  84305. */
  84306. index: number;
  84307. /**
  84308. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  84309. */
  84310. texCoord?: number;
  84311. }
  84312. /**
  84313. * The root object for a glTF asset
  84314. */
  84315. interface IGLTF extends IProperty {
  84316. /**
  84317. * An array of accessors. An accessor is a typed view into a bufferView
  84318. */
  84319. accessors?: IAccessor[];
  84320. /**
  84321. * An array of keyframe animations
  84322. */
  84323. animations?: IAnimation[];
  84324. /**
  84325. * Metadata about the glTF asset
  84326. */
  84327. asset: IAsset;
  84328. /**
  84329. * An array of buffers. A buffer points to binary geometry, animation, or skins
  84330. */
  84331. buffers?: IBuffer[];
  84332. /**
  84333. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  84334. */
  84335. bufferViews?: IBufferView[];
  84336. /**
  84337. * An array of cameras
  84338. */
  84339. cameras?: ICamera[];
  84340. /**
  84341. * Names of glTF extensions used somewhere in this asset
  84342. */
  84343. extensionsUsed?: string[];
  84344. /**
  84345. * Names of glTF extensions required to properly load this asset
  84346. */
  84347. extensionsRequired?: string[];
  84348. /**
  84349. * An array of images. An image defines data used to create a texture
  84350. */
  84351. images?: IImage[];
  84352. /**
  84353. * An array of materials. A material defines the appearance of a primitive
  84354. */
  84355. materials?: IMaterial[];
  84356. /**
  84357. * An array of meshes. A mesh is a set of primitives to be rendered
  84358. */
  84359. meshes?: IMesh[];
  84360. /**
  84361. * An array of nodes
  84362. */
  84363. nodes?: INode[];
  84364. /**
  84365. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  84366. */
  84367. samplers?: ISampler[];
  84368. /**
  84369. * The index of the default scene
  84370. */
  84371. scene?: number;
  84372. /**
  84373. * An array of scenes
  84374. */
  84375. scenes?: IScene[];
  84376. /**
  84377. * An array of skins. A skin is defined by joints and matrices
  84378. */
  84379. skins?: ISkin[];
  84380. /**
  84381. * An array of textures
  84382. */
  84383. textures?: ITexture[];
  84384. }
  84385. /**
  84386. * The glTF validation results
  84387. * @ignore
  84388. */
  84389. interface IGLTFValidationResults {
  84390. info: {
  84391. generator: string;
  84392. hasAnimations: boolean;
  84393. hasDefaultScene: boolean;
  84394. hasMaterials: boolean;
  84395. hasMorphTargets: boolean;
  84396. hasSkins: boolean;
  84397. hasTextures: boolean;
  84398. maxAttributesUsed: number;
  84399. primitivesCount: number
  84400. };
  84401. issues: {
  84402. messages: Array<string>;
  84403. numErrors: number;
  84404. numHints: number;
  84405. numInfos: number;
  84406. numWarnings: number;
  84407. truncated: boolean
  84408. };
  84409. mimeType: string;
  84410. uri: string;
  84411. validatedAt: string;
  84412. validatorVersion: string;
  84413. }
  84414. /**
  84415. * The glTF validation options
  84416. */
  84417. interface IGLTFValidationOptions {
  84418. /** Uri to use */
  84419. uri?: string;
  84420. /** Function used to load external resources */
  84421. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  84422. /** Boolean indicating that we need to validate accessor data */
  84423. validateAccessorData?: boolean;
  84424. /** max number of issues allowed */
  84425. maxIssues?: number;
  84426. /** Ignored issues */
  84427. ignoredIssues?: Array<string>;
  84428. /** Value to override severy settings */
  84429. severityOverrides?: Object;
  84430. }
  84431. /**
  84432. * The glTF validator object
  84433. * @ignore
  84434. */
  84435. interface IGLTFValidator {
  84436. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  84437. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  84438. }
  84439. /**
  84440. * Interfaces from the EXT_lights_image_based extension
  84441. */
  84442. /** @hidden */
  84443. interface IEXTLightsImageBased_LightReferenceImageBased {
  84444. light: number;
  84445. }
  84446. /** @hidden */
  84447. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  84448. intensity: number;
  84449. rotation: number[];
  84450. specularImageSize: number;
  84451. specularImages: number[][];
  84452. irradianceCoefficients: number[][];
  84453. }
  84454. /** @hidden */
  84455. interface IEXTLightsImageBased {
  84456. lights: IEXTLightsImageBased_LightImageBased[];
  84457. }
  84458. /**
  84459. * Interfaces from the EXT_mesh_gpu_instancing extension
  84460. * !!! Experimental Extension Subject to Changes !!!
  84461. */
  84462. /** @hidden */
  84463. interface IEXTMeshGpuInstancing {
  84464. mesh?: number;
  84465. attributes: { [name: string]: number };
  84466. }
  84467. /**
  84468. * Interfaces from the KHR_draco_mesh_compression extension
  84469. */
  84470. /** @hidden */
  84471. interface IKHRDracoMeshCompression {
  84472. bufferView: number;
  84473. attributes: { [name: string]: number };
  84474. }
  84475. /**
  84476. * Interfaces from the KHR_lights_punctual extension
  84477. */
  84478. /** @hidden */
  84479. const enum IKHRLightsPunctual_LightType {
  84480. DIRECTIONAL = "directional",
  84481. POINT = "point",
  84482. SPOT = "spot"
  84483. }
  84484. /** @hidden */
  84485. interface IKHRLightsPunctual_LightReference {
  84486. light: number;
  84487. }
  84488. /** @hidden */
  84489. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  84490. type: IKHRLightsPunctual_LightType;
  84491. color?: number[];
  84492. intensity?: number;
  84493. range?: number;
  84494. spot?: {
  84495. innerConeAngle?: number;
  84496. outerConeAngle?: number;
  84497. };
  84498. }
  84499. /** @hidden */
  84500. interface IKHRLightsPunctual {
  84501. lights: IKHRLightsPunctual_Light[];
  84502. }
  84503. /**
  84504. * Interfaces from the KHR_materials_clearcoat extension
  84505. * !!! Experimental Extension Subject to Changes !!!
  84506. */
  84507. /** @hidden */
  84508. interface IKHRMaterialsClearcoat {
  84509. clearcoatFactor: number;
  84510. clearcoatTexture: ITextureInfo;
  84511. clearcoatRoughnessFactor: number;
  84512. clearcoatRoughnessTexture: ITextureInfo;
  84513. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  84514. }
  84515. /**
  84516. * Interfaces from the KHR_materials_ior extension
  84517. * !!! Experimental Extension Subject to Changes !!!
  84518. */
  84519. /** @hidden */
  84520. interface IKHRMaterialsIor {
  84521. ior: number;
  84522. }
  84523. /**
  84524. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  84525. */
  84526. /** @hidden */
  84527. interface IKHRMaterialsPbrSpecularGlossiness {
  84528. diffuseFactor: number[];
  84529. diffuseTexture: ITextureInfo;
  84530. specularFactor: number[];
  84531. glossinessFactor: number;
  84532. specularGlossinessTexture: ITextureInfo;
  84533. }
  84534. /**
  84535. * Interfaces from the KHR_materials_sheen extension
  84536. * !!! Experimental Extension Subject to Changes !!!
  84537. */
  84538. /** @hidden */
  84539. interface IKHRMaterialsSheen {
  84540. sheenColorFactor?: number[];
  84541. sheenTexture?: ITextureInfo;
  84542. sheenRoughnessFactor?: number;
  84543. }
  84544. /**
  84545. * Interfaces from the KHR_materials_specular extension
  84546. * !!! Experimental Extension Subject to Changes !!!
  84547. */
  84548. /** @hidden */
  84549. interface IKHRMaterialsSpecular {
  84550. specularFactor: number;
  84551. specularColorFactor: number[];
  84552. specularTexture: ITextureInfo;
  84553. }
  84554. /**
  84555. * Interfaces from the KHR_materials_transmission extension
  84556. * !!! Experimental Extension Subject to Changes !!!
  84557. */
  84558. /** @hidden */
  84559. interface IKHRMaterialsTransmission {
  84560. transmissionFactor?: number;
  84561. transmissionTexture?: ITextureInfo;
  84562. }
  84563. /**
  84564. * Interfaces from the KHR_materials_variants extension
  84565. * !!! Experimental Extension Subject to Changes !!!
  84566. */
  84567. /** @hidden */
  84568. interface IKHRMaterialVariants_Mapping {
  84569. variants: string[];
  84570. material: number;
  84571. }
  84572. /** @hidden */
  84573. interface IKHRMaterialVariants {
  84574. mapping: IKHRMaterialVariants_Mapping[];
  84575. }
  84576. /**
  84577. * Interfaces from the KHR_texture_basisu extension
  84578. * !!! Experimental Extension Subject to Changes !!!
  84579. */
  84580. /** @hidden */
  84581. interface IKHRTextureBasisU {
  84582. source: number;
  84583. }
  84584. /**
  84585. * Interfaces from the EXT_texture_webp extension
  84586. */
  84587. /** @hidden */
  84588. interface IEXTTextureWebP {
  84589. source: number;
  84590. }
  84591. /**
  84592. * Interfaces from the KHR_texture_transform extension
  84593. */
  84594. /** @hidden */
  84595. interface IKHRTextureTransform {
  84596. offset?: number[];
  84597. rotation?: number;
  84598. scale?: number[];
  84599. texCoord?: number;
  84600. }
  84601. /**
  84602. * Interfaces from the KHR_xmp extension
  84603. * !!! Experimental Extension Subject to Changes !!!
  84604. */
  84605. /** @hidden */
  84606. interface IKHRXmp_Data {
  84607. [key: string]: unknown;
  84608. }
  84609. /** @hidden */
  84610. interface IKHRXmp_Gltf {
  84611. packets: IKHRXmp_Data[];
  84612. }
  84613. /** @hidden */
  84614. interface IKHRXmp_Node {
  84615. packet: number;
  84616. }
  84617. /**
  84618. * Interfaces from the MSFT_audio_emitter extension
  84619. */
  84620. /** @hidden */
  84621. interface IMSFTAudioEmitter_ClipReference {
  84622. clip: number;
  84623. weight?: number;
  84624. }
  84625. /** @hidden */
  84626. interface IMSFTAudioEmitter_EmittersReference {
  84627. emitters: number[];
  84628. }
  84629. /** @hidden */
  84630. const enum IMSFTAudioEmitter_DistanceModel {
  84631. linear = "linear",
  84632. inverse = "inverse",
  84633. exponential = "exponential",
  84634. }
  84635. /** @hidden */
  84636. interface IMSFTAudioEmitter_Emitter {
  84637. name?: string;
  84638. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  84639. refDistance?: number;
  84640. maxDistance?: number;
  84641. rolloffFactor?: number;
  84642. innerAngle?: number;
  84643. outerAngle?: number;
  84644. loop?: boolean;
  84645. volume?: number;
  84646. clips: IMSFTAudioEmitter_ClipReference[];
  84647. }
  84648. /** @hidden */
  84649. const enum IMSFTAudioEmitter_AudioMimeType {
  84650. WAV = "audio/wav",
  84651. }
  84652. /** @hidden */
  84653. interface IMSFTAudioEmitter_Clip extends IProperty {
  84654. uri?: string;
  84655. bufferView?: number;
  84656. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  84657. }
  84658. /** @hidden */
  84659. const enum IMSFTAudioEmitter_AnimationEventAction {
  84660. play = "play",
  84661. pause = "pause",
  84662. stop = "stop",
  84663. }
  84664. /** @hidden */
  84665. interface IMSFTAudioEmitter_AnimationEvent {
  84666. action: IMSFTAudioEmitter_AnimationEventAction;
  84667. emitter: number;
  84668. time: number;
  84669. startOffset?: number;
  84670. }
  84671. /**
  84672. * Interfaces from the MSFT_lod extension
  84673. */
  84674. /** @hidden */
  84675. interface IMSFTLOD {
  84676. ids: number[];
  84677. }
  84678. }
  84679. declare module BABYLON {
  84680. /** @hidden */
  84681. export var cellPixelShader: {
  84682. name: string;
  84683. shader: string;
  84684. };
  84685. }
  84686. declare module BABYLON {
  84687. /** @hidden */
  84688. export var cellVertexShader: {
  84689. name: string;
  84690. shader: string;
  84691. };
  84692. }
  84693. declare module BABYLON {
  84694. export class CellMaterial extends BABYLON.PushMaterial {
  84695. private _diffuseTexture;
  84696. diffuseTexture: BABYLON.BaseTexture;
  84697. diffuseColor: BABYLON.Color3;
  84698. _computeHighLevel: boolean;
  84699. computeHighLevel: boolean;
  84700. private _disableLighting;
  84701. disableLighting: boolean;
  84702. private _maxSimultaneousLights;
  84703. maxSimultaneousLights: number;
  84704. constructor(name: string, scene: BABYLON.Scene);
  84705. needAlphaBlending(): boolean;
  84706. needAlphaTesting(): boolean;
  84707. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84708. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84709. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84710. getAnimatables(): BABYLON.IAnimatable[];
  84711. getActiveTextures(): BABYLON.BaseTexture[];
  84712. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84713. dispose(forceDisposeEffect?: boolean): void;
  84714. getClassName(): string;
  84715. clone(name: string): CellMaterial;
  84716. serialize(): any;
  84717. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  84718. }
  84719. }
  84720. declare module BABYLON {
  84721. export class CustomShaderStructure {
  84722. FragmentStore: string;
  84723. VertexStore: string;
  84724. constructor();
  84725. }
  84726. export class ShaderSpecialParts {
  84727. constructor();
  84728. Fragment_Begin: string;
  84729. Fragment_Definitions: string;
  84730. Fragment_MainBegin: string;
  84731. Fragment_Custom_Diffuse: string;
  84732. Fragment_Before_Lights: string;
  84733. Fragment_Before_Fog: string;
  84734. Fragment_Custom_Alpha: string;
  84735. Fragment_Before_FragColor: string;
  84736. Vertex_Begin: string;
  84737. Vertex_Definitions: string;
  84738. Vertex_MainBegin: string;
  84739. Vertex_Before_PositionUpdated: string;
  84740. Vertex_Before_NormalUpdated: string;
  84741. Vertex_After_WorldPosComputed: string;
  84742. Vertex_MainEnd: string;
  84743. }
  84744. export class CustomMaterial extends BABYLON.StandardMaterial {
  84745. static ShaderIndexer: number;
  84746. CustomParts: ShaderSpecialParts;
  84747. _isCreatedShader: boolean;
  84748. _createdShaderName: string;
  84749. _customUniform: string[];
  84750. _newUniforms: string[];
  84751. _newUniformInstances: {
  84752. [name: string]: any;
  84753. };
  84754. _newSamplerInstances: {
  84755. [name: string]: BABYLON.Texture;
  84756. };
  84757. _customAttributes: string[];
  84758. FragmentShader: string;
  84759. VertexShader: string;
  84760. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  84761. ReviewUniform(name: string, arr: string[]): string[];
  84762. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  84763. constructor(name: string, scene: BABYLON.Scene);
  84764. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  84765. AddAttribute(name: string): CustomMaterial;
  84766. Fragment_Begin(shaderPart: string): CustomMaterial;
  84767. Fragment_Definitions(shaderPart: string): CustomMaterial;
  84768. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  84769. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  84770. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  84771. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  84772. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  84773. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  84774. Vertex_Begin(shaderPart: string): CustomMaterial;
  84775. Vertex_Definitions(shaderPart: string): CustomMaterial;
  84776. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  84777. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  84778. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  84779. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  84780. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  84781. }
  84782. }
  84783. declare module BABYLON {
  84784. export class ShaderAlebdoParts {
  84785. constructor();
  84786. Fragment_Begin: string;
  84787. Fragment_Definitions: string;
  84788. Fragment_MainBegin: string;
  84789. Fragment_Custom_Albedo: string;
  84790. Fragment_Before_Lights: string;
  84791. Fragment_Custom_MetallicRoughness: string;
  84792. Fragment_Custom_MicroSurface: string;
  84793. Fragment_Before_Fog: string;
  84794. Fragment_Custom_Alpha: string;
  84795. Fragment_Before_FragColor: string;
  84796. Vertex_Begin: string;
  84797. Vertex_Definitions: string;
  84798. Vertex_MainBegin: string;
  84799. Vertex_Before_PositionUpdated: string;
  84800. Vertex_Before_NormalUpdated: string;
  84801. Vertex_After_WorldPosComputed: string;
  84802. Vertex_MainEnd: string;
  84803. }
  84804. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  84805. static ShaderIndexer: number;
  84806. CustomParts: ShaderAlebdoParts;
  84807. _isCreatedShader: boolean;
  84808. _createdShaderName: string;
  84809. _customUniform: string[];
  84810. _newUniforms: string[];
  84811. _newUniformInstances: {
  84812. [name: string]: any;
  84813. };
  84814. _newSamplerInstances: {
  84815. [name: string]: BABYLON.Texture;
  84816. };
  84817. _customAttributes: string[];
  84818. FragmentShader: string;
  84819. VertexShader: string;
  84820. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  84821. ReviewUniform(name: string, arr: string[]): string[];
  84822. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  84823. constructor(name: string, scene: BABYLON.Scene);
  84824. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  84825. AddAttribute(name: string): PBRCustomMaterial;
  84826. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  84827. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  84828. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  84829. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  84830. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  84831. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  84832. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  84833. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  84834. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  84835. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  84836. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  84837. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  84838. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  84839. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  84840. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  84841. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  84842. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  84843. }
  84844. }
  84845. declare module BABYLON {
  84846. /** @hidden */
  84847. export var firePixelShader: {
  84848. name: string;
  84849. shader: string;
  84850. };
  84851. }
  84852. declare module BABYLON {
  84853. /** @hidden */
  84854. export var fireVertexShader: {
  84855. name: string;
  84856. shader: string;
  84857. };
  84858. }
  84859. declare module BABYLON {
  84860. export class FireMaterial extends BABYLON.PushMaterial {
  84861. private _diffuseTexture;
  84862. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  84863. private _distortionTexture;
  84864. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  84865. private _opacityTexture;
  84866. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  84867. diffuseColor: BABYLON.Color3;
  84868. speed: number;
  84869. private _scaledDiffuse;
  84870. private _lastTime;
  84871. constructor(name: string, scene: BABYLON.Scene);
  84872. needAlphaBlending(): boolean;
  84873. needAlphaTesting(): boolean;
  84874. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84875. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84876. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84877. getAnimatables(): BABYLON.IAnimatable[];
  84878. getActiveTextures(): BABYLON.BaseTexture[];
  84879. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84880. getClassName(): string;
  84881. dispose(forceDisposeEffect?: boolean): void;
  84882. clone(name: string): FireMaterial;
  84883. serialize(): any;
  84884. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  84885. }
  84886. }
  84887. declare module BABYLON {
  84888. /** @hidden */
  84889. export var furPixelShader: {
  84890. name: string;
  84891. shader: string;
  84892. };
  84893. }
  84894. declare module BABYLON {
  84895. /** @hidden */
  84896. export var furVertexShader: {
  84897. name: string;
  84898. shader: string;
  84899. };
  84900. }
  84901. declare module BABYLON {
  84902. export class FurMaterial extends BABYLON.PushMaterial {
  84903. private _diffuseTexture;
  84904. diffuseTexture: BABYLON.BaseTexture;
  84905. private _heightTexture;
  84906. heightTexture: BABYLON.BaseTexture;
  84907. diffuseColor: BABYLON.Color3;
  84908. furLength: number;
  84909. furAngle: number;
  84910. furColor: BABYLON.Color3;
  84911. furOffset: number;
  84912. furSpacing: number;
  84913. furGravity: BABYLON.Vector3;
  84914. furSpeed: number;
  84915. furDensity: number;
  84916. furOcclusion: number;
  84917. furTexture: BABYLON.DynamicTexture;
  84918. private _disableLighting;
  84919. disableLighting: boolean;
  84920. private _maxSimultaneousLights;
  84921. maxSimultaneousLights: number;
  84922. highLevelFur: boolean;
  84923. _meshes: BABYLON.AbstractMesh[];
  84924. private _furTime;
  84925. constructor(name: string, scene: BABYLON.Scene);
  84926. get furTime(): number;
  84927. set furTime(furTime: number);
  84928. needAlphaBlending(): boolean;
  84929. needAlphaTesting(): boolean;
  84930. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84931. updateFur(): void;
  84932. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84933. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84934. getAnimatables(): BABYLON.IAnimatable[];
  84935. getActiveTextures(): BABYLON.BaseTexture[];
  84936. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84937. dispose(forceDisposeEffect?: boolean): void;
  84938. clone(name: string): FurMaterial;
  84939. serialize(): any;
  84940. getClassName(): string;
  84941. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  84942. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  84943. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  84944. }
  84945. }
  84946. declare module BABYLON {
  84947. /** @hidden */
  84948. export var gradientPixelShader: {
  84949. name: string;
  84950. shader: string;
  84951. };
  84952. }
  84953. declare module BABYLON {
  84954. /** @hidden */
  84955. export var gradientVertexShader: {
  84956. name: string;
  84957. shader: string;
  84958. };
  84959. }
  84960. declare module BABYLON {
  84961. export class GradientMaterial extends BABYLON.PushMaterial {
  84962. private _maxSimultaneousLights;
  84963. maxSimultaneousLights: number;
  84964. topColor: BABYLON.Color3;
  84965. topColorAlpha: number;
  84966. bottomColor: BABYLON.Color3;
  84967. bottomColorAlpha: number;
  84968. offset: number;
  84969. scale: number;
  84970. smoothness: number;
  84971. private _disableLighting;
  84972. disableLighting: boolean;
  84973. constructor(name: string, scene: BABYLON.Scene);
  84974. needAlphaBlending(): boolean;
  84975. needAlphaTesting(): boolean;
  84976. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84977. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84978. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84979. getAnimatables(): BABYLON.IAnimatable[];
  84980. dispose(forceDisposeEffect?: boolean): void;
  84981. clone(name: string): GradientMaterial;
  84982. serialize(): any;
  84983. getClassName(): string;
  84984. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  84985. }
  84986. }
  84987. declare module BABYLON {
  84988. /** @hidden */
  84989. export var gridPixelShader: {
  84990. name: string;
  84991. shader: string;
  84992. };
  84993. }
  84994. declare module BABYLON {
  84995. /** @hidden */
  84996. export var gridVertexShader: {
  84997. name: string;
  84998. shader: string;
  84999. };
  85000. }
  85001. declare module BABYLON {
  85002. /**
  85003. * The grid materials allows you to wrap any shape with a grid.
  85004. * Colors are customizable.
  85005. */
  85006. export class GridMaterial extends BABYLON.PushMaterial {
  85007. /**
  85008. * Main color of the grid (e.g. between lines)
  85009. */
  85010. mainColor: BABYLON.Color3;
  85011. /**
  85012. * Color of the grid lines.
  85013. */
  85014. lineColor: BABYLON.Color3;
  85015. /**
  85016. * The scale of the grid compared to unit.
  85017. */
  85018. gridRatio: number;
  85019. /**
  85020. * Allows setting an offset for the grid lines.
  85021. */
  85022. gridOffset: BABYLON.Vector3;
  85023. /**
  85024. * The frequency of thicker lines.
  85025. */
  85026. majorUnitFrequency: number;
  85027. /**
  85028. * The visibility of minor units in the grid.
  85029. */
  85030. minorUnitVisibility: number;
  85031. /**
  85032. * The grid opacity outside of the lines.
  85033. */
  85034. opacity: number;
  85035. /**
  85036. * Determine RBG output is premultiplied by alpha value.
  85037. */
  85038. preMultiplyAlpha: boolean;
  85039. private _opacityTexture;
  85040. opacityTexture: BABYLON.BaseTexture;
  85041. private _gridControl;
  85042. /**
  85043. * constructor
  85044. * @param name The name given to the material in order to identify it afterwards.
  85045. * @param scene The scene the material is used in.
  85046. */
  85047. constructor(name: string, scene: BABYLON.Scene);
  85048. /**
  85049. * Returns wehter or not the grid requires alpha blending.
  85050. */
  85051. needAlphaBlending(): boolean;
  85052. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  85053. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85054. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85055. /**
  85056. * Dispose the material and its associated resources.
  85057. * @param forceDisposeEffect will also dispose the used effect when true
  85058. */
  85059. dispose(forceDisposeEffect?: boolean): void;
  85060. clone(name: string): GridMaterial;
  85061. serialize(): any;
  85062. getClassName(): string;
  85063. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  85064. }
  85065. }
  85066. declare module BABYLON {
  85067. /** @hidden */
  85068. export var lavaPixelShader: {
  85069. name: string;
  85070. shader: string;
  85071. };
  85072. }
  85073. declare module BABYLON {
  85074. /** @hidden */
  85075. export var lavaVertexShader: {
  85076. name: string;
  85077. shader: string;
  85078. };
  85079. }
  85080. declare module BABYLON {
  85081. export class LavaMaterial extends BABYLON.PushMaterial {
  85082. private _diffuseTexture;
  85083. diffuseTexture: BABYLON.BaseTexture;
  85084. noiseTexture: BABYLON.BaseTexture;
  85085. fogColor: BABYLON.Color3;
  85086. speed: number;
  85087. movingSpeed: number;
  85088. lowFrequencySpeed: number;
  85089. fogDensity: number;
  85090. private _lastTime;
  85091. diffuseColor: BABYLON.Color3;
  85092. private _disableLighting;
  85093. disableLighting: boolean;
  85094. private _unlit;
  85095. unlit: boolean;
  85096. private _maxSimultaneousLights;
  85097. maxSimultaneousLights: number;
  85098. private _scaledDiffuse;
  85099. constructor(name: string, scene: BABYLON.Scene);
  85100. needAlphaBlending(): boolean;
  85101. needAlphaTesting(): boolean;
  85102. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85103. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85104. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85105. getAnimatables(): BABYLON.IAnimatable[];
  85106. getActiveTextures(): BABYLON.BaseTexture[];
  85107. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85108. dispose(forceDisposeEffect?: boolean): void;
  85109. clone(name: string): LavaMaterial;
  85110. serialize(): any;
  85111. getClassName(): string;
  85112. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  85113. }
  85114. }
  85115. declare module BABYLON {
  85116. /** @hidden */
  85117. export var mixPixelShader: {
  85118. name: string;
  85119. shader: string;
  85120. };
  85121. }
  85122. declare module BABYLON {
  85123. /** @hidden */
  85124. export var mixVertexShader: {
  85125. name: string;
  85126. shader: string;
  85127. };
  85128. }
  85129. declare module BABYLON {
  85130. export class MixMaterial extends BABYLON.PushMaterial {
  85131. /**
  85132. * Mix textures
  85133. */
  85134. private _mixTexture1;
  85135. mixTexture1: BABYLON.BaseTexture;
  85136. private _mixTexture2;
  85137. mixTexture2: BABYLON.BaseTexture;
  85138. /**
  85139. * Diffuse textures
  85140. */
  85141. private _diffuseTexture1;
  85142. diffuseTexture1: BABYLON.Texture;
  85143. private _diffuseTexture2;
  85144. diffuseTexture2: BABYLON.Texture;
  85145. private _diffuseTexture3;
  85146. diffuseTexture3: BABYLON.Texture;
  85147. private _diffuseTexture4;
  85148. diffuseTexture4: BABYLON.Texture;
  85149. private _diffuseTexture5;
  85150. diffuseTexture5: BABYLON.Texture;
  85151. private _diffuseTexture6;
  85152. diffuseTexture6: BABYLON.Texture;
  85153. private _diffuseTexture7;
  85154. diffuseTexture7: BABYLON.Texture;
  85155. private _diffuseTexture8;
  85156. diffuseTexture8: BABYLON.Texture;
  85157. /**
  85158. * Uniforms
  85159. */
  85160. diffuseColor: BABYLON.Color3;
  85161. specularColor: BABYLON.Color3;
  85162. specularPower: number;
  85163. private _disableLighting;
  85164. disableLighting: boolean;
  85165. private _maxSimultaneousLights;
  85166. maxSimultaneousLights: number;
  85167. constructor(name: string, scene: BABYLON.Scene);
  85168. needAlphaBlending(): boolean;
  85169. needAlphaTesting(): boolean;
  85170. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85171. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85172. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85173. getAnimatables(): BABYLON.IAnimatable[];
  85174. getActiveTextures(): BABYLON.BaseTexture[];
  85175. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85176. dispose(forceDisposeEffect?: boolean): void;
  85177. clone(name: string): MixMaterial;
  85178. serialize(): any;
  85179. getClassName(): string;
  85180. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  85181. }
  85182. }
  85183. declare module BABYLON {
  85184. /** @hidden */
  85185. export var normalPixelShader: {
  85186. name: string;
  85187. shader: string;
  85188. };
  85189. }
  85190. declare module BABYLON {
  85191. /** @hidden */
  85192. export var normalVertexShader: {
  85193. name: string;
  85194. shader: string;
  85195. };
  85196. }
  85197. declare module BABYLON {
  85198. export class NormalMaterial extends BABYLON.PushMaterial {
  85199. private _diffuseTexture;
  85200. diffuseTexture: BABYLON.BaseTexture;
  85201. diffuseColor: BABYLON.Color3;
  85202. private _disableLighting;
  85203. disableLighting: boolean;
  85204. private _maxSimultaneousLights;
  85205. maxSimultaneousLights: number;
  85206. constructor(name: string, scene: BABYLON.Scene);
  85207. needAlphaBlending(): boolean;
  85208. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  85209. needAlphaTesting(): boolean;
  85210. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85211. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85212. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85213. getAnimatables(): BABYLON.IAnimatable[];
  85214. getActiveTextures(): BABYLON.BaseTexture[];
  85215. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85216. dispose(forceDisposeEffect?: boolean): void;
  85217. clone(name: string): NormalMaterial;
  85218. serialize(): any;
  85219. getClassName(): string;
  85220. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  85221. }
  85222. }
  85223. declare module BABYLON {
  85224. /** @hidden */
  85225. export var shadowOnlyPixelShader: {
  85226. name: string;
  85227. shader: string;
  85228. };
  85229. }
  85230. declare module BABYLON {
  85231. /** @hidden */
  85232. export var shadowOnlyVertexShader: {
  85233. name: string;
  85234. shader: string;
  85235. };
  85236. }
  85237. declare module BABYLON {
  85238. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  85239. private _activeLight;
  85240. private _needAlphaBlending;
  85241. constructor(name: string, scene: BABYLON.Scene);
  85242. shadowColor: BABYLON.Color3;
  85243. needAlphaBlending(): boolean;
  85244. needAlphaTesting(): boolean;
  85245. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85246. get activeLight(): BABYLON.IShadowLight;
  85247. set activeLight(light: BABYLON.IShadowLight);
  85248. private _getFirstShadowLightForMesh;
  85249. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85250. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85251. clone(name: string): ShadowOnlyMaterial;
  85252. serialize(): any;
  85253. getClassName(): string;
  85254. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  85255. }
  85256. }
  85257. declare module BABYLON {
  85258. /** @hidden */
  85259. export var simplePixelShader: {
  85260. name: string;
  85261. shader: string;
  85262. };
  85263. }
  85264. declare module BABYLON {
  85265. /** @hidden */
  85266. export var simpleVertexShader: {
  85267. name: string;
  85268. shader: string;
  85269. };
  85270. }
  85271. declare module BABYLON {
  85272. export class SimpleMaterial extends BABYLON.PushMaterial {
  85273. private _diffuseTexture;
  85274. diffuseTexture: BABYLON.BaseTexture;
  85275. diffuseColor: BABYLON.Color3;
  85276. private _disableLighting;
  85277. disableLighting: boolean;
  85278. private _maxSimultaneousLights;
  85279. maxSimultaneousLights: number;
  85280. constructor(name: string, scene: BABYLON.Scene);
  85281. needAlphaBlending(): boolean;
  85282. needAlphaTesting(): boolean;
  85283. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85284. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85285. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85286. getAnimatables(): BABYLON.IAnimatable[];
  85287. getActiveTextures(): BABYLON.BaseTexture[];
  85288. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85289. dispose(forceDisposeEffect?: boolean): void;
  85290. clone(name: string): SimpleMaterial;
  85291. serialize(): any;
  85292. getClassName(): string;
  85293. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  85294. }
  85295. }
  85296. declare module BABYLON {
  85297. /** @hidden */
  85298. export var skyPixelShader: {
  85299. name: string;
  85300. shader: string;
  85301. };
  85302. }
  85303. declare module BABYLON {
  85304. /** @hidden */
  85305. export var skyVertexShader: {
  85306. name: string;
  85307. shader: string;
  85308. };
  85309. }
  85310. declare module BABYLON {
  85311. /**
  85312. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  85313. * @see https://doc.babylonjs.com/extensions/sky
  85314. */
  85315. export class SkyMaterial extends BABYLON.PushMaterial {
  85316. /**
  85317. * Defines the overall luminance of sky in interval ]0, 1[.
  85318. */
  85319. luminance: number;
  85320. /**
  85321. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  85322. */
  85323. turbidity: number;
  85324. /**
  85325. * Defines the sky appearance (light intensity).
  85326. */
  85327. rayleigh: number;
  85328. /**
  85329. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  85330. */
  85331. mieCoefficient: number;
  85332. /**
  85333. * Defines the amount of haze particles following the Mie scattering theory.
  85334. */
  85335. mieDirectionalG: number;
  85336. /**
  85337. * Defines the distance of the sun according to the active scene camera.
  85338. */
  85339. distance: number;
  85340. /**
  85341. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  85342. * "inclined".
  85343. */
  85344. inclination: number;
  85345. /**
  85346. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  85347. * an object direction and a reference direction.
  85348. */
  85349. azimuth: number;
  85350. /**
  85351. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  85352. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  85353. */
  85354. sunPosition: BABYLON.Vector3;
  85355. /**
  85356. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  85357. * .sunPosition property.
  85358. */
  85359. useSunPosition: boolean;
  85360. /**
  85361. * Defines an offset vector used to get a horizon offset.
  85362. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  85363. */
  85364. cameraOffset: BABYLON.Vector3;
  85365. private _cameraPosition;
  85366. /**
  85367. * Instantiates a new sky material.
  85368. * This material allows to create dynamic and texture free
  85369. * effects for skyboxes by taking care of the atmosphere state.
  85370. * @see https://doc.babylonjs.com/extensions/sky
  85371. * @param name Define the name of the material in the scene
  85372. * @param scene Define the scene the material belong to
  85373. */
  85374. constructor(name: string, scene: BABYLON.Scene);
  85375. /**
  85376. * Specifies if the material will require alpha blending
  85377. * @returns a boolean specifying if alpha blending is needed
  85378. */
  85379. needAlphaBlending(): boolean;
  85380. /**
  85381. * Specifies if this material should be rendered in alpha test mode
  85382. * @returns false as the sky material doesn't need alpha testing.
  85383. */
  85384. needAlphaTesting(): boolean;
  85385. /**
  85386. * Get the texture used for alpha test purpose.
  85387. * @returns null as the sky material has no texture.
  85388. */
  85389. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85390. /**
  85391. * Get if the submesh is ready to be used and all its information available.
  85392. * Child classes can use it to update shaders
  85393. * @param mesh defines the mesh to check
  85394. * @param subMesh defines which submesh to check
  85395. * @param useInstances specifies that instances should be used
  85396. * @returns a boolean indicating that the submesh is ready or not
  85397. */
  85398. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85399. /**
  85400. * Binds the submesh to this material by preparing the effect and shader to draw
  85401. * @param world defines the world transformation matrix
  85402. * @param mesh defines the mesh containing the submesh
  85403. * @param subMesh defines the submesh to bind the material to
  85404. */
  85405. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85406. /**
  85407. * Get the list of animatables in the material.
  85408. * @returns the list of animatables object used in the material
  85409. */
  85410. getAnimatables(): BABYLON.IAnimatable[];
  85411. /**
  85412. * Disposes the material
  85413. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85414. */
  85415. dispose(forceDisposeEffect?: boolean): void;
  85416. /**
  85417. * Makes a duplicate of the material, and gives it a new name
  85418. * @param name defines the new name for the duplicated material
  85419. * @returns the cloned material
  85420. */
  85421. clone(name: string): SkyMaterial;
  85422. /**
  85423. * Serializes this material in a JSON representation
  85424. * @returns the serialized material object
  85425. */
  85426. serialize(): any;
  85427. /**
  85428. * Gets the current class name of the material e.g. "SkyMaterial"
  85429. * Mainly use in serialization.
  85430. * @returns the class name
  85431. */
  85432. getClassName(): string;
  85433. /**
  85434. * Creates a sky material from parsed material data
  85435. * @param source defines the JSON representation of the material
  85436. * @param scene defines the hosting scene
  85437. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  85438. * @returns a new sky material
  85439. */
  85440. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  85441. }
  85442. }
  85443. declare module BABYLON {
  85444. /** @hidden */
  85445. export var terrainPixelShader: {
  85446. name: string;
  85447. shader: string;
  85448. };
  85449. }
  85450. declare module BABYLON {
  85451. /** @hidden */
  85452. export var terrainVertexShader: {
  85453. name: string;
  85454. shader: string;
  85455. };
  85456. }
  85457. declare module BABYLON {
  85458. export class TerrainMaterial extends BABYLON.PushMaterial {
  85459. private _mixTexture;
  85460. mixTexture: BABYLON.BaseTexture;
  85461. private _diffuseTexture1;
  85462. diffuseTexture1: BABYLON.Texture;
  85463. private _diffuseTexture2;
  85464. diffuseTexture2: BABYLON.Texture;
  85465. private _diffuseTexture3;
  85466. diffuseTexture3: BABYLON.Texture;
  85467. private _bumpTexture1;
  85468. bumpTexture1: BABYLON.Texture;
  85469. private _bumpTexture2;
  85470. bumpTexture2: BABYLON.Texture;
  85471. private _bumpTexture3;
  85472. bumpTexture3: BABYLON.Texture;
  85473. diffuseColor: BABYLON.Color3;
  85474. specularColor: BABYLON.Color3;
  85475. specularPower: number;
  85476. private _disableLighting;
  85477. disableLighting: boolean;
  85478. private _maxSimultaneousLights;
  85479. maxSimultaneousLights: number;
  85480. constructor(name: string, scene: BABYLON.Scene);
  85481. needAlphaBlending(): boolean;
  85482. needAlphaTesting(): boolean;
  85483. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85484. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85485. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85486. getAnimatables(): BABYLON.IAnimatable[];
  85487. getActiveTextures(): BABYLON.BaseTexture[];
  85488. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85489. dispose(forceDisposeEffect?: boolean): void;
  85490. clone(name: string): TerrainMaterial;
  85491. serialize(): any;
  85492. getClassName(): string;
  85493. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  85494. }
  85495. }
  85496. declare module BABYLON {
  85497. /** @hidden */
  85498. export var triplanarPixelShader: {
  85499. name: string;
  85500. shader: string;
  85501. };
  85502. }
  85503. declare module BABYLON {
  85504. /** @hidden */
  85505. export var triplanarVertexShader: {
  85506. name: string;
  85507. shader: string;
  85508. };
  85509. }
  85510. declare module BABYLON {
  85511. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  85512. mixTexture: BABYLON.BaseTexture;
  85513. private _diffuseTextureX;
  85514. diffuseTextureX: BABYLON.BaseTexture;
  85515. private _diffuseTextureY;
  85516. diffuseTextureY: BABYLON.BaseTexture;
  85517. private _diffuseTextureZ;
  85518. diffuseTextureZ: BABYLON.BaseTexture;
  85519. private _normalTextureX;
  85520. normalTextureX: BABYLON.BaseTexture;
  85521. private _normalTextureY;
  85522. normalTextureY: BABYLON.BaseTexture;
  85523. private _normalTextureZ;
  85524. normalTextureZ: BABYLON.BaseTexture;
  85525. tileSize: number;
  85526. diffuseColor: BABYLON.Color3;
  85527. specularColor: BABYLON.Color3;
  85528. specularPower: number;
  85529. private _disableLighting;
  85530. disableLighting: boolean;
  85531. private _maxSimultaneousLights;
  85532. maxSimultaneousLights: number;
  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): TriPlanarMaterial;
  85544. serialize(): any;
  85545. getClassName(): string;
  85546. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  85547. }
  85548. }
  85549. declare module BABYLON {
  85550. /** @hidden */
  85551. export var waterPixelShader: {
  85552. name: string;
  85553. shader: string;
  85554. };
  85555. }
  85556. declare module BABYLON {
  85557. /** @hidden */
  85558. export var waterVertexShader: {
  85559. name: string;
  85560. shader: string;
  85561. };
  85562. }
  85563. declare module BABYLON {
  85564. export class WaterMaterial extends BABYLON.PushMaterial {
  85565. renderTargetSize: BABYLON.Vector2;
  85566. private _bumpTexture;
  85567. bumpTexture: BABYLON.BaseTexture;
  85568. diffuseColor: BABYLON.Color3;
  85569. specularColor: BABYLON.Color3;
  85570. specularPower: number;
  85571. private _disableLighting;
  85572. disableLighting: boolean;
  85573. private _maxSimultaneousLights;
  85574. maxSimultaneousLights: number;
  85575. /**
  85576. * @param {number}: Represents the wind force
  85577. */
  85578. windForce: number;
  85579. /**
  85580. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  85581. */
  85582. windDirection: BABYLON.Vector2;
  85583. /**
  85584. * @param {number}: Wave height, represents the height of the waves
  85585. */
  85586. waveHeight: number;
  85587. /**
  85588. * @param {number}: Bump height, represents the bump height related to the bump map
  85589. */
  85590. bumpHeight: number;
  85591. /**
  85592. * @param {boolean}: Add a smaller moving bump to less steady waves.
  85593. */
  85594. private _bumpSuperimpose;
  85595. bumpSuperimpose: boolean;
  85596. /**
  85597. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  85598. */
  85599. private _fresnelSeparate;
  85600. fresnelSeparate: boolean;
  85601. /**
  85602. * @param {boolean}: bump Waves modify the reflection.
  85603. */
  85604. private _bumpAffectsReflection;
  85605. bumpAffectsReflection: boolean;
  85606. /**
  85607. * @param {number}: The water color blended with the refraction (near)
  85608. */
  85609. waterColor: BABYLON.Color3;
  85610. /**
  85611. * @param {number}: The blend factor related to the water color
  85612. */
  85613. colorBlendFactor: number;
  85614. /**
  85615. * @param {number}: The water color blended with the reflection (far)
  85616. */
  85617. waterColor2: BABYLON.Color3;
  85618. /**
  85619. * @param {number}: The blend factor related to the water color (reflection, far)
  85620. */
  85621. colorBlendFactor2: number;
  85622. /**
  85623. * @param {number}: Represents the maximum length of a wave
  85624. */
  85625. waveLength: number;
  85626. /**
  85627. * @param {number}: Defines the waves speed
  85628. */
  85629. waveSpeed: number;
  85630. /**
  85631. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  85632. * will avoid calculating useless pixels in the pixel shader of the water material.
  85633. */
  85634. disableClipPlane: boolean;
  85635. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  85636. private _mesh;
  85637. private _refractionRTT;
  85638. private _reflectionRTT;
  85639. private _reflectionTransform;
  85640. private _lastTime;
  85641. private _lastDeltaTime;
  85642. private _useLogarithmicDepth;
  85643. private _waitingRenderList;
  85644. private _imageProcessingConfiguration;
  85645. private _imageProcessingObserver;
  85646. /**
  85647. * Gets a boolean indicating that current material needs to register RTT
  85648. */
  85649. get hasRenderTargetTextures(): boolean;
  85650. /**
  85651. * Constructor
  85652. */
  85653. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  85654. get useLogarithmicDepth(): boolean;
  85655. set useLogarithmicDepth(value: boolean);
  85656. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  85657. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  85658. addToRenderList(node: any): void;
  85659. enableRenderTargets(enable: boolean): void;
  85660. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  85661. get renderTargetsEnabled(): boolean;
  85662. needAlphaBlending(): boolean;
  85663. needAlphaTesting(): boolean;
  85664. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85665. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85666. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85667. private _createRenderTargets;
  85668. getAnimatables(): BABYLON.IAnimatable[];
  85669. getActiveTextures(): BABYLON.BaseTexture[];
  85670. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85671. dispose(forceDisposeEffect?: boolean): void;
  85672. clone(name: string): WaterMaterial;
  85673. serialize(): any;
  85674. getClassName(): string;
  85675. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  85676. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  85677. }
  85678. }
  85679. declare module BABYLON {
  85680. /** @hidden */
  85681. export var asciiartPixelShader: {
  85682. name: string;
  85683. shader: string;
  85684. };
  85685. }
  85686. declare module BABYLON {
  85687. /**
  85688. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  85689. *
  85690. * It basically takes care rendering the font front the given font size to a texture.
  85691. * This is used later on in the postprocess.
  85692. */
  85693. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  85694. private _font;
  85695. private _text;
  85696. private _charSize;
  85697. /**
  85698. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  85699. */
  85700. get charSize(): number;
  85701. /**
  85702. * Create a new instance of the Ascii Art FontTexture class
  85703. * @param name the name of the texture
  85704. * @param font the font to use, use the W3C CSS notation
  85705. * @param text the caracter set to use in the rendering.
  85706. * @param scene the scene that owns the texture
  85707. */
  85708. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  85709. /**
  85710. * Gets the max char width of a font.
  85711. * @param font the font to use, use the W3C CSS notation
  85712. * @return the max char width
  85713. */
  85714. private getFontWidth;
  85715. /**
  85716. * Gets the max char height of a font.
  85717. * @param font the font to use, use the W3C CSS notation
  85718. * @return the max char height
  85719. */
  85720. private getFontHeight;
  85721. /**
  85722. * Clones the current AsciiArtTexture.
  85723. * @return the clone of the texture.
  85724. */
  85725. clone(): AsciiArtFontTexture;
  85726. /**
  85727. * Parses a json object representing the texture and returns an instance of it.
  85728. * @param source the source JSON representation
  85729. * @param scene the scene to create the texture for
  85730. * @return the parsed texture
  85731. */
  85732. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  85733. }
  85734. /**
  85735. * Option available in the Ascii Art Post Process.
  85736. */
  85737. export interface IAsciiArtPostProcessOptions {
  85738. /**
  85739. * The font to use following the w3c font definition.
  85740. */
  85741. font?: string;
  85742. /**
  85743. * The character set to use in the postprocess.
  85744. */
  85745. characterSet?: string;
  85746. /**
  85747. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  85748. * This number is defined between 0 and 1;
  85749. */
  85750. mixToTile?: number;
  85751. /**
  85752. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  85753. * This number is defined between 0 and 1;
  85754. */
  85755. mixToNormal?: number;
  85756. }
  85757. /**
  85758. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  85759. *
  85760. * Simmply add it to your scene and let the nerd that lives in you have fun.
  85761. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  85762. */
  85763. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  85764. /**
  85765. * The font texture used to render the char in the post process.
  85766. */
  85767. private _asciiArtFontTexture;
  85768. /**
  85769. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  85770. * This number is defined between 0 and 1;
  85771. */
  85772. mixToTile: number;
  85773. /**
  85774. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  85775. * This number is defined between 0 and 1;
  85776. */
  85777. mixToNormal: number;
  85778. /**
  85779. * Instantiates a new Ascii Art Post Process.
  85780. * @param name the name to give to the postprocess
  85781. * @camera the camera to apply the post process to.
  85782. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  85783. */
  85784. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  85785. }
  85786. }
  85787. declare module BABYLON {
  85788. /** @hidden */
  85789. export var digitalrainPixelShader: {
  85790. name: string;
  85791. shader: string;
  85792. };
  85793. }
  85794. declare module BABYLON {
  85795. /**
  85796. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  85797. *
  85798. * It basically takes care rendering the font front the given font size to a texture.
  85799. * This is used later on in the postprocess.
  85800. */
  85801. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  85802. private _font;
  85803. private _text;
  85804. private _charSize;
  85805. /**
  85806. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  85807. */
  85808. get charSize(): number;
  85809. /**
  85810. * Create a new instance of the Digital Rain FontTexture class
  85811. * @param name the name of the texture
  85812. * @param font the font to use, use the W3C CSS notation
  85813. * @param text the caracter set to use in the rendering.
  85814. * @param scene the scene that owns the texture
  85815. */
  85816. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  85817. /**
  85818. * Gets the max char width of a font.
  85819. * @param font the font to use, use the W3C CSS notation
  85820. * @return the max char width
  85821. */
  85822. private getFontWidth;
  85823. /**
  85824. * Gets the max char height of a font.
  85825. * @param font the font to use, use the W3C CSS notation
  85826. * @return the max char height
  85827. */
  85828. private getFontHeight;
  85829. /**
  85830. * Clones the current DigitalRainFontTexture.
  85831. * @return the clone of the texture.
  85832. */
  85833. clone(): DigitalRainFontTexture;
  85834. /**
  85835. * Parses a json object representing the texture and returns an instance of it.
  85836. * @param source the source JSON representation
  85837. * @param scene the scene to create the texture for
  85838. * @return the parsed texture
  85839. */
  85840. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  85841. }
  85842. /**
  85843. * Option available in the Digital Rain Post Process.
  85844. */
  85845. export interface IDigitalRainPostProcessOptions {
  85846. /**
  85847. * The font to use following the w3c font definition.
  85848. */
  85849. font?: string;
  85850. /**
  85851. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  85852. * This number is defined between 0 and 1;
  85853. */
  85854. mixToTile?: number;
  85855. /**
  85856. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  85857. * This number is defined between 0 and 1;
  85858. */
  85859. mixToNormal?: number;
  85860. }
  85861. /**
  85862. * DigitalRainPostProcess helps rendering everithing in digital rain.
  85863. *
  85864. * Simmply add it to your scene and let the nerd that lives in you have fun.
  85865. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  85866. */
  85867. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  85868. /**
  85869. * The font texture used to render the char in the post process.
  85870. */
  85871. private _digitalRainFontTexture;
  85872. /**
  85873. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  85874. * This number is defined between 0 and 1;
  85875. */
  85876. mixToTile: number;
  85877. /**
  85878. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  85879. * This number is defined between 0 and 1;
  85880. */
  85881. mixToNormal: number;
  85882. /**
  85883. * Instantiates a new Digital Rain Post Process.
  85884. * @param name the name to give to the postprocess
  85885. * @camera the camera to apply the post process to.
  85886. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  85887. */
  85888. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  85889. }
  85890. }
  85891. declare module BABYLON {
  85892. /** @hidden */
  85893. export var brickProceduralTexturePixelShader: {
  85894. name: string;
  85895. shader: string;
  85896. };
  85897. }
  85898. declare module BABYLON {
  85899. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  85900. private _numberOfBricksHeight;
  85901. private _numberOfBricksWidth;
  85902. private _jointColor;
  85903. private _brickColor;
  85904. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85905. updateShaderUniforms(): void;
  85906. get numberOfBricksHeight(): number;
  85907. set numberOfBricksHeight(value: number);
  85908. get numberOfBricksWidth(): number;
  85909. set numberOfBricksWidth(value: number);
  85910. get jointColor(): BABYLON.Color3;
  85911. set jointColor(value: BABYLON.Color3);
  85912. get brickColor(): BABYLON.Color3;
  85913. set brickColor(value: BABYLON.Color3);
  85914. /**
  85915. * Serializes this brick procedural texture
  85916. * @returns a serialized brick procedural texture object
  85917. */
  85918. serialize(): any;
  85919. /**
  85920. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  85921. * @param parsedTexture defines parsed texture data
  85922. * @param scene defines the current scene
  85923. * @param rootUrl defines the root URL containing brick procedural texture information
  85924. * @returns a parsed Brick Procedural BABYLON.Texture
  85925. */
  85926. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  85927. }
  85928. }
  85929. declare module BABYLON {
  85930. /** @hidden */
  85931. export var cloudProceduralTexturePixelShader: {
  85932. name: string;
  85933. shader: string;
  85934. };
  85935. }
  85936. declare module BABYLON {
  85937. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  85938. private _skyColor;
  85939. private _cloudColor;
  85940. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85941. updateShaderUniforms(): void;
  85942. get skyColor(): BABYLON.Color4;
  85943. set skyColor(value: BABYLON.Color4);
  85944. get cloudColor(): BABYLON.Color4;
  85945. set cloudColor(value: BABYLON.Color4);
  85946. /**
  85947. * Serializes this cloud procedural texture
  85948. * @returns a serialized cloud procedural texture object
  85949. */
  85950. serialize(): any;
  85951. /**
  85952. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  85953. * @param parsedTexture defines parsed texture data
  85954. * @param scene defines the current scene
  85955. * @param rootUrl defines the root URL containing cloud procedural texture information
  85956. * @returns a parsed Cloud Procedural BABYLON.Texture
  85957. */
  85958. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  85959. }
  85960. }
  85961. declare module BABYLON {
  85962. /** @hidden */
  85963. export var fireProceduralTexturePixelShader: {
  85964. name: string;
  85965. shader: string;
  85966. };
  85967. }
  85968. declare module BABYLON {
  85969. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  85970. private _time;
  85971. private _speed;
  85972. private _autoGenerateTime;
  85973. private _fireColors;
  85974. private _alphaThreshold;
  85975. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85976. updateShaderUniforms(): void;
  85977. render(useCameraPostProcess?: boolean): void;
  85978. static get PurpleFireColors(): BABYLON.Color3[];
  85979. static get GreenFireColors(): BABYLON.Color3[];
  85980. static get RedFireColors(): BABYLON.Color3[];
  85981. static get BlueFireColors(): BABYLON.Color3[];
  85982. get autoGenerateTime(): boolean;
  85983. set autoGenerateTime(value: boolean);
  85984. get fireColors(): BABYLON.Color3[];
  85985. set fireColors(value: BABYLON.Color3[]);
  85986. get time(): number;
  85987. set time(value: number);
  85988. get speed(): BABYLON.Vector2;
  85989. set speed(value: BABYLON.Vector2);
  85990. get alphaThreshold(): number;
  85991. set alphaThreshold(value: number);
  85992. /**
  85993. * Serializes this fire procedural texture
  85994. * @returns a serialized fire procedural texture object
  85995. */
  85996. serialize(): any;
  85997. /**
  85998. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  85999. * @param parsedTexture defines parsed texture data
  86000. * @param scene defines the current scene
  86001. * @param rootUrl defines the root URL containing fire procedural texture information
  86002. * @returns a parsed Fire Procedural BABYLON.Texture
  86003. */
  86004. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  86005. }
  86006. }
  86007. declare module BABYLON {
  86008. /** @hidden */
  86009. export var grassProceduralTexturePixelShader: {
  86010. name: string;
  86011. shader: string;
  86012. };
  86013. }
  86014. declare module BABYLON {
  86015. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  86016. private _grassColors;
  86017. private _groundColor;
  86018. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86019. updateShaderUniforms(): void;
  86020. get grassColors(): BABYLON.Color3[];
  86021. set grassColors(value: BABYLON.Color3[]);
  86022. get groundColor(): BABYLON.Color3;
  86023. set groundColor(value: BABYLON.Color3);
  86024. /**
  86025. * Serializes this grass procedural texture
  86026. * @returns a serialized grass procedural texture object
  86027. */
  86028. serialize(): any;
  86029. /**
  86030. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  86031. * @param parsedTexture defines parsed texture data
  86032. * @param scene defines the current scene
  86033. * @param rootUrl defines the root URL containing grass procedural texture information
  86034. * @returns a parsed Grass Procedural BABYLON.Texture
  86035. */
  86036. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  86037. }
  86038. }
  86039. declare module BABYLON {
  86040. /** @hidden */
  86041. export var marbleProceduralTexturePixelShader: {
  86042. name: string;
  86043. shader: string;
  86044. };
  86045. }
  86046. declare module BABYLON {
  86047. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  86048. private _numberOfTilesHeight;
  86049. private _numberOfTilesWidth;
  86050. private _amplitude;
  86051. private _jointColor;
  86052. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86053. updateShaderUniforms(): void;
  86054. get numberOfTilesHeight(): number;
  86055. set numberOfTilesHeight(value: number);
  86056. get amplitude(): number;
  86057. set amplitude(value: number);
  86058. get numberOfTilesWidth(): number;
  86059. set numberOfTilesWidth(value: number);
  86060. get jointColor(): BABYLON.Color3;
  86061. set jointColor(value: BABYLON.Color3);
  86062. /**
  86063. * Serializes this marble procedural texture
  86064. * @returns a serialized marble procedural texture object
  86065. */
  86066. serialize(): any;
  86067. /**
  86068. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  86069. * @param parsedTexture defines parsed texture data
  86070. * @param scene defines the current scene
  86071. * @param rootUrl defines the root URL containing marble procedural texture information
  86072. * @returns a parsed Marble Procedural BABYLON.Texture
  86073. */
  86074. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  86075. }
  86076. }
  86077. declare module BABYLON {
  86078. /** @hidden */
  86079. export var normalMapProceduralTexturePixelShader: {
  86080. name: string;
  86081. shader: string;
  86082. };
  86083. }
  86084. declare module BABYLON {
  86085. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  86086. private _baseTexture;
  86087. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86088. updateShaderUniforms(): void;
  86089. render(useCameraPostProcess?: boolean): void;
  86090. resize(size: any, generateMipMaps: any): void;
  86091. get baseTexture(): BABYLON.Texture;
  86092. set baseTexture(texture: BABYLON.Texture);
  86093. /**
  86094. * Serializes this normal map procedural texture
  86095. * @returns a serialized normal map procedural texture object
  86096. */
  86097. serialize(): any;
  86098. /**
  86099. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  86100. * @param parsedTexture defines parsed texture data
  86101. * @param scene defines the current scene
  86102. * @param rootUrl defines the root URL containing normal map procedural texture information
  86103. * @returns a parsed Normal Map Procedural BABYLON.Texture
  86104. */
  86105. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  86106. }
  86107. }
  86108. declare module BABYLON {
  86109. /** @hidden */
  86110. export var perlinNoiseProceduralTexturePixelShader: {
  86111. name: string;
  86112. shader: string;
  86113. };
  86114. }
  86115. declare module BABYLON {
  86116. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  86117. time: number;
  86118. timeScale: number;
  86119. translationSpeed: number;
  86120. private _currentTranslation;
  86121. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86122. updateShaderUniforms(): void;
  86123. render(useCameraPostProcess?: boolean): void;
  86124. resize(size: any, generateMipMaps: any): void;
  86125. /**
  86126. * Serializes this perlin noise procedural texture
  86127. * @returns a serialized perlin noise procedural texture object
  86128. */
  86129. serialize(): any;
  86130. /**
  86131. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  86132. * @param parsedTexture defines parsed texture data
  86133. * @param scene defines the current scene
  86134. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  86135. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  86136. */
  86137. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  86138. }
  86139. }
  86140. declare module BABYLON {
  86141. /** @hidden */
  86142. export var roadProceduralTexturePixelShader: {
  86143. name: string;
  86144. shader: string;
  86145. };
  86146. }
  86147. declare module BABYLON {
  86148. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  86149. private _roadColor;
  86150. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86151. updateShaderUniforms(): void;
  86152. get roadColor(): BABYLON.Color3;
  86153. set roadColor(value: BABYLON.Color3);
  86154. /**
  86155. * Serializes this road procedural texture
  86156. * @returns a serialized road procedural texture object
  86157. */
  86158. serialize(): any;
  86159. /**
  86160. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  86161. * @param parsedTexture defines parsed texture data
  86162. * @param scene defines the current scene
  86163. * @param rootUrl defines the root URL containing road procedural texture information
  86164. * @returns a parsed Road Procedural BABYLON.Texture
  86165. */
  86166. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  86167. }
  86168. }
  86169. declare module BABYLON {
  86170. /** @hidden */
  86171. export var starfieldProceduralTexturePixelShader: {
  86172. name: string;
  86173. shader: string;
  86174. };
  86175. }
  86176. declare module BABYLON {
  86177. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  86178. private _time;
  86179. private _alpha;
  86180. private _beta;
  86181. private _zoom;
  86182. private _formuparam;
  86183. private _stepsize;
  86184. private _tile;
  86185. private _brightness;
  86186. private _darkmatter;
  86187. private _distfading;
  86188. private _saturation;
  86189. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86190. updateShaderUniforms(): void;
  86191. get time(): number;
  86192. set time(value: number);
  86193. get alpha(): number;
  86194. set alpha(value: number);
  86195. get beta(): number;
  86196. set beta(value: number);
  86197. get formuparam(): number;
  86198. set formuparam(value: number);
  86199. get stepsize(): number;
  86200. set stepsize(value: number);
  86201. get zoom(): number;
  86202. set zoom(value: number);
  86203. get tile(): number;
  86204. set tile(value: number);
  86205. get brightness(): number;
  86206. set brightness(value: number);
  86207. get darkmatter(): number;
  86208. set darkmatter(value: number);
  86209. get distfading(): number;
  86210. set distfading(value: number);
  86211. get saturation(): number;
  86212. set saturation(value: number);
  86213. /**
  86214. * Serializes this starfield procedural texture
  86215. * @returns a serialized starfield procedural texture object
  86216. */
  86217. serialize(): any;
  86218. /**
  86219. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  86220. * @param parsedTexture defines parsed texture data
  86221. * @param scene defines the current scene
  86222. * @param rootUrl defines the root URL containing startfield procedural texture information
  86223. * @returns a parsed Starfield Procedural BABYLON.Texture
  86224. */
  86225. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  86226. }
  86227. }
  86228. declare module BABYLON {
  86229. /** @hidden */
  86230. export var woodProceduralTexturePixelShader: {
  86231. name: string;
  86232. shader: string;
  86233. };
  86234. }
  86235. declare module BABYLON {
  86236. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  86237. private _ampScale;
  86238. private _woodColor;
  86239. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86240. updateShaderUniforms(): void;
  86241. get ampScale(): number;
  86242. set ampScale(value: number);
  86243. get woodColor(): BABYLON.Color3;
  86244. set woodColor(value: BABYLON.Color3);
  86245. /**
  86246. * Serializes this wood procedural texture
  86247. * @returns a serialized wood procedural texture object
  86248. */
  86249. serialize(): any;
  86250. /**
  86251. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  86252. * @param parsedTexture defines parsed texture data
  86253. * @param scene defines the current scene
  86254. * @param rootUrl defines the root URL containing wood procedural texture information
  86255. * @returns a parsed Wood Procedural BABYLON.Texture
  86256. */
  86257. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  86258. }
  86259. }